summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2011-08-25 12:03:56 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2011-08-25 12:03:56 (GMT)
commitf5577bc0ca1c7f01baac7f612ad52f3526ffe327 (patch)
treed5a8067cf4b83a338c420ea363bf359d3f33dcbf
parentdd0f607950cf1416722aa14bd13506278ec6dd2c (diff)
parent545f0cffe802c26b1779eb2f9ca6c4ade8c8c654 (diff)
downloadtcl-f5577bc0ca1c7f01baac7f612ad52f3526ffe327.zip
tcl-f5577bc0ca1c7f01baac7f612ad52f3526ffe327.tar.gz
tcl-f5577bc0ca1c7f01baac7f612ad52f3526ffe327.tar.bz2
Merge to feature branch
-rw-r--r--generic/tclStringObj.c25
-rw-r--r--tests/string.test3
2 files changed, 28 insertions, 0 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 993a694..9cb973e 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -2661,6 +2661,31 @@ TclStringObjReverse(
Tcl_Obj *resultPtr = objPtr;
char c;
+ /* Special case: Pure Unicode array */
+ if ((objPtr->typePtr == &tclStringType) && !objPtr->bytes) {
+ String *strPtr = GET_STRING(objPtr);
+ if (strPtr->hasUnicode) {
+ String *dstStrPtr = stringAlloc(strPtr->numChars);
+ Tcl_UniChar *chars = strPtr->unicode;
+ Tcl_UniChar *dstChars = dstStrPtr->unicode + strPtr->numChars;
+
+ resultPtr = Tcl_NewObj();
+ resultPtr->bytes = NULL;
+ SET_STRING(resultPtr, dstStrPtr);
+ resultPtr->typePtr = &tclStringType;
+ dstStrPtr->maxChars = strPtr->numChars;
+ dstStrPtr->unicode[strPtr->numChars] = 0;
+ dstStrPtr->numChars = strPtr->numChars;
+ dstStrPtr->hasUnicode = 1;
+ dstStrPtr->allocated = 0;
+
+ while (--dstChars >= dstStrPtr->unicode) {
+ *dstChars = *chars++;
+ }
+ return resultPtr;
+ }
+ }
+
src = TclGetString(objPtr);
if (Tcl_IsShared(objPtr)) {
resultPtr = Tcl_NewObj();
diff --git a/tests/string.test b/tests/string.test
index 1a62a66..92f544e 100644
--- a/tests/string.test
+++ b/tests/string.test
@@ -1623,6 +1623,9 @@ test string-24.12 {string reverse command - corner case} {
set y \udead
string is ascii [string reverse $x$y]
} 0
+test string-24.13 {string reverse command - pure Unicode string} {
+ string reverse [string range \ubeef\udead\ubeef\udead\ubeef\udead 1 5]
+} \udead\ubeef\udead\ubeef\udead
test string-25.1 {string is list} {
string is list {a b c}