summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclTestObj.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/generic/tclTestObj.c b/generic/tclTestObj.c
index c9a910a..66657d9 100644
--- a/generic/tclTestObj.c
+++ b/generic/tclTestObj.c
@@ -1269,7 +1269,7 @@ TeststringobjCmd(
static const char *const options[] = {
"append", "appendstrings", "get", "get2", "length", "length2",
"set", "set2", "setlength", "maxchars", "range", "appendself",
- "appendself2", NULL
+ "appendself2", "newunicode", NULL
};
if (objc < 3) {
@@ -1513,7 +1513,24 @@ TeststringobjCmd(
Tcl_AppendUnicodeToObj(varPtr[varIndex], unicode + length, size - length);
Tcl_SetObjResult(interp, varPtr[varIndex]);
break;
- }
+ case 13: /* newunicode*/
+ unicode = (unsigned short *) ckalloc((objc - 3) * sizeof(unsigned short));
+ for (i = 0; i < (objc - 3); ++i) {
+ int val;
+ if (Tcl_GetIntFromObj(interp, objv[i + 3], &val) != TCL_OK) {
+ break;
+ }
+ unicode[i] = (unsigned short)val;
+ }
+ if (i < (objc-3)) {
+ ckfree(unicode);
+ return TCL_ERROR;
+ }
+ SetVarToObj(varPtr, varIndex, Tcl_NewUnicodeObj(unicode, objc - 3));
+ Tcl_SetObjResult(interp, varPtr[varIndex]);
+ ckfree(unicode);
+ break;
+ }
return TCL_OK;
}