summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2009-06-10 14:44:29 (GMT)
committerdgp <dgp@users.sourceforge.net>2009-06-10 14:44:29 (GMT)
commit2a3653593e13fea9eee1652863db7b373b0b3fa7 (patch)
tree615d5bdbba079825e29d64713a15356e6f4259dc /generic/tclStringObj.c
parent77651df52750776dce287030cc8a1d2c0bf61385 (diff)
downloadtcl-2a3653593e13fea9eee1652863db7b373b0b3fa7.zip
tcl-2a3653593e13fea9eee1652863db7b373b0b3fa7.tar.gz
tcl-2a3653593e13fea9eee1652863db7b373b0b3fa7.tar.bz2
* generic/tclStringObj.c: Corrected failures to deal with the
"pure unicode" representation of an empty string. Thanks to Julian Noble for reporting the problem. [Bug 2803109]
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 7bd7526..ded77e9 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -33,7 +33,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStringObj.c,v 1.122 2009/04/07 18:45:54 dgp Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.123 2009/06/10 14:44:29 dgp Exp $ */
#include "tclInt.h"
#include "tommath.h"
@@ -855,11 +855,6 @@ Tcl_SetObjLength(
* Can only get here when objPtr->bytes == NULL.
* No need to invalidate the string rep.
*/
-
- if (length == 0) {
- /* For the empty string case, set the string rep. */
- TclInitStringRep(objPtr, tclEmptyStringRep, 0);
- }
}
}
@@ -970,11 +965,6 @@ Tcl_AttemptSetObjLength(
* Can only get here when objPtr->bytes == NULL.
* No need to invalidate the string rep.
*/
-
- if (length == 0) {
- /* For the empty string case, set the string rep. */
- TclInitStringRep(objPtr, tclEmptyStringRep, 0);
- }
}
return 1;
}
@@ -1056,11 +1046,6 @@ SetUnicodeObj(
TclInvalidateStringRep(objPtr);
stringPtr->allocated = 0;
-
- if (numChars == 0) {
- /* For the empty string case, set the string rep. */
- TclInitStringRep(objPtr, tclEmptyStringRep, 0);
- }
}
/*
@@ -1533,6 +1518,9 @@ AppendUtfToUtfRep(
* trailing null.
*/
+ if (objPtr->bytes == NULL) {
+ objPtr->length = 0;
+ }
oldLength = objPtr->length;
newLength = numBytes + oldLength;
if (newLength < 0) {
@@ -2653,10 +2641,6 @@ ExtendUnicodeRepWithString(
bytes += TclUtfToUniChar(bytes, dst);
}
*dst = 0;
- if (needed == 0) {
- /* For the empty string case, set the string rep. */
- TclInitStringRep(objPtr, tclEmptyStringRep, 0);
- }
}
/*
@@ -2828,8 +2812,12 @@ UpdateStringOfString(
Tcl_Obj *objPtr) /* Object with string rep to update. */
{
String *stringPtr = GET_STRING(objPtr);
- (void) ExtendStringRepWithUnicode(objPtr, stringPtr->unicode,
- stringPtr->numChars);
+ if (stringPtr->numChars == 0) {
+ TclInitStringRep(objPtr, tclEmptyStringRep, 0);
+ } else {
+ (void) ExtendStringRepWithUnicode(objPtr, stringPtr->unicode,
+ stringPtr->numChars);
+ }
}
static int