summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclStringObj.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 41ecf137..e724e9b 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.29 2003/02/11 18:35:11 hobbs Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.30 2003/02/15 02:14:33 hobbs Exp $ */
#include "tclInt.h"
@@ -376,7 +376,7 @@ Tcl_GetCharLength(objPtr)
*/
if (stringPtr->numChars == -1) {
- register int i = 0, len = objPtr->length;
+ register int i = objPtr->length;
register unsigned char *str = (unsigned char *) objPtr->bytes;
/*
@@ -386,13 +386,14 @@ Tcl_GetCharLength(objPtr)
stringPtr->numChars = Tcl_NumUtfChars(objPtr->bytes, objPtr->length);
*/
- while ((i < len) && (*str < 0xC0)) { i++; str++; }
- stringPtr->numChars = i;
- if (i < len) {
- stringPtr->numChars += Tcl_NumUtfChars(objPtr->bytes + i, len - i);
+ while (i && (*str < 0xC0)) { i--; str++; }
+ stringPtr->numChars = objPtr->length - i;
+ if (i) {
+ stringPtr->numChars += Tcl_NumUtfChars(objPtr->bytes
+ + (objPtr->length - i), i);
}
- if (stringPtr->numChars == len) {
+ if (stringPtr->numChars == objPtr->length) {
/*
* Since we've just calculated the number of chars, and all