summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2009-02-15 16:49:40 (GMT)
committerdgp <dgp@users.sourceforge.net>2009-02-15 16:49:40 (GMT)
commitcf9a0cad9436ae952feb777e2e5e5c931e37d73e (patch)
tree409c5ec79adad133af5f16b1b6507a2eb4194056 /generic
parent9325ac89905cf6cadf12491e007de22301362651 (diff)
downloadtcl-cf9a0cad9436ae952feb777e2e5e5c931e37d73e.zip
tcl-cf9a0cad9436ae952feb777e2e5e5c931e37d73e.tar.gz
tcl-cf9a0cad9436ae952feb777e2e5e5c931e37d73e.tar.bz2
* generic/tclStringObj.c: Removed limitation in
Tcl_AppendObjToObj where the char length of the result was only computed if the appended string was all single byte characters. This limitation was in place to dodge a bug in Tcl_GetUniChar. With that bug gone, we can take advantage of always recording the length of append results when we know it.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclStringObj.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 9112572..2b1a658 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.105 2009/02/14 23:07:17 dgp Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.106 2009/02/15 16:49:40 dgp Exp $ */
#include "tclInt.h"
#include "tommath.h"
@@ -1203,7 +1203,7 @@ Tcl_AppendObjToObj(
Tcl_Obj *appendObjPtr) /* Object to append. */
{
String *stringPtr;
- int length, numChars, allOneByteChars;
+ int length, numChars, appendNumChars = -1;
const char *bytes;
/*
@@ -1280,24 +1280,19 @@ Tcl_AppendObjToObj(
* characters in the final (appended-to) object.
*/
+ /* TODO: Check that append to self works */
bytes = TclGetStringFromObj(appendObjPtr, &length);
- allOneByteChars = 0;
numChars = stringPtr->numChars;
if ((numChars >= 0) && (appendObjPtr->typePtr == &tclStringType)) {
- stringPtr = GET_STRING(appendObjPtr);
- /* TODO why is the == length test needed here? */
- if ((stringPtr->numChars >= 0) && (stringPtr->numChars == length)) {
- numChars += stringPtr->numChars;
- allOneByteChars = 1;
- }
+ String *appendStringPtr = GET_STRING(appendObjPtr);
+ appendNumChars = appendStringPtr->numChars;
}
AppendUtfToUtfRep(objPtr, bytes, length);
- if (allOneByteChars) {
- stringPtr = GET_STRING(objPtr);
- stringPtr->numChars = numChars;
+ if (numChars >= 0 && appendNumChars >= 0) {
+ stringPtr->numChars = numChars + appendNumChars;
}
}