summaryrefslogtreecommitdiffstats
path: root/generic/tclTest.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2003-10-08 14:24:40 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2003-10-08 14:24:40 (GMT)
commit4ba38844faf91c00b0df311fbfa958e36a216475 (patch)
tree1a14dc708ecdaf3d05c05e8ee7e0b36d4778eb67 /generic/tclTest.c
parentdf6d45b4f6b62d1991c8aee5e5df8f841a28fb1f (diff)
downloadtcl-4ba38844faf91c00b0df311fbfa958e36a216475.zip
tcl-4ba38844faf91c00b0df311fbfa958e36a216475.tar.gz
tcl-4ba38844faf91c00b0df311fbfa958e36a216475.tar.bz2
Made Tcl_NumUtfChars do the right thing with \u0000 when guessing the length
because of a negative 'length' parameter. [Bug 769812]
Diffstat (limited to 'generic/tclTest.c')
-rw-r--r--generic/tclTest.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 6d04c6e..8f322fc 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclTest.c,v 1.67 2003/04/16 23:33:44 dgp Exp $
+ * RCS: @(#) $Id: tclTest.c,v 1.68 2003/10/08 14:24:41 dkf Exp $
*/
#define TCL_TEST
@@ -420,6 +420,9 @@ static Tcl_Obj* SimpleListVolumes _ANSI_ARGS_ ((void));
static int SimplePathInFilesystem _ANSI_ARGS_ ((
Tcl_Obj *pathPtr, ClientData *clientDataPtr));
static Tcl_Obj* SimpleCopy _ANSI_ARGS_ ((Tcl_Obj *pathPtr));
+static int TestNumUtfCharsCmd _ANSI_ARGS_((ClientData clientData,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj *CONST objv[]));
static Tcl_Filesystem testReportingFilesystem = {
"reporting",
@@ -654,6 +657,9 @@ Tcltest_Init(interp)
Tcl_CreateObjCommand(interp, "testsetobjerrorcode",
TestsetobjerrorcodeCmd, (ClientData) 0,
(Tcl_CmdDeleteProc *) NULL);
+ Tcl_CreateObjCommand(interp, "testnumutfchars",
+ TestNumUtfCharsCmd, (ClientData) 0,
+ (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "testsetplatform", TestsetplatformCmd,
(ClientData) 0, (Tcl_CmdDeleteProc *) NULL);
Tcl_CreateCommand(interp, "teststaticpkg", TeststaticpkgCmd,
@@ -6413,4 +6419,24 @@ SimpleListVolumes(void)
Tcl_IncrRefCount(retVal);
return retVal;
}
-
+
+/*
+ * Used to check correct string-length determining in Tcl_NumUtfChars
+ */
+static int
+TestNumUtfCharsCmd(clientData, interp, objc, objv)
+ ClientData clientData;
+ Tcl_Interp *interp;
+ int objc;
+ Tcl_Obj *CONST objv[];
+{
+ if (objc > 1) {
+ int len = -1;
+ if (objc > 2) {
+ (void) Tcl_GetStringFromObj(objv[1], &len);
+ }
+ len = Tcl_NumUtfChars(Tcl_GetString(objv[1]), len);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(len));
+ }
+ return TCL_OK;
+}