Attachment "2803109.patch" to
ticket [2803109fff]
added by
dgp
2009-06-09 11:23:00.
Index: generic/tclStringObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStringObj.c,v
retrieving revision 1.122
diff -u -r1.122 tclStringObj.c
--- generic/tclStringObj.c 7 Apr 2009 18:45:54 -0000 1.122
+++ generic/tclStringObj.c 9 Jun 2009 04:21:55 -0000
@@ -855,11 +855,6 @@
* 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 @@
* 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 @@
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 @@
* trailing null.
*/
+ if (objPtr->bytes == NULL) {
+ objPtr->length = 0;
+ }
oldLength = objPtr->length;
newLength = numBytes + oldLength;
if (newLength < 0) {
@@ -2653,10 +2641,6 @@
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 @@
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