diff options
author | dgp <dgp@users.sourceforge.net> | 2020-04-24 17:18:23 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2020-04-24 17:18:23 (GMT) |
commit | 59343a872e8587e5da4eb52956d453af67535f5e (patch) | |
tree | 2dbbc6350b10bf44362146411a7ec5b2bae979a8 | |
parent | cfdcea56833526b4caba822ff1ea8771dd2833b8 (diff) | |
download | tcl-59343a872e8587e5da4eb52956d453af67535f5e.zip tcl-59343a872e8587e5da4eb52956d453af67535f5e.tar.gz tcl-59343a872e8587e5da4eb52956d453af67535f5e.tar.bz2 |
Revert the parts of [76213b3f72] that converted callers of Tcl_UtfToUniChar
into callers of Tcl_UtfNext. With this reversion, any future divergence
between those two will not harm these callers. Retain the tests, and retain
the new implementation of Tcl_UtfNext itself and its new macro form.
-rw-r--r-- | generic/tclCompExpr.c | 5 | ||||
-rw-r--r-- | generic/tclUtf.c | 11 |
2 files changed, 10 insertions, 6 deletions
diff --git a/generic/tclCompExpr.c b/generic/tclCompExpr.c index 42321af..27d7503 100644 --- a/generic/tclCompExpr.c +++ b/generic/tclCompExpr.c @@ -1801,6 +1801,7 @@ ParseLexeme( { const char *end; int scanned; + Tcl_UniChar ch; Tcl_Obj *literal = NULL; unsigned char byte; @@ -1978,12 +1979,12 @@ ParseLexeme( if (!TclIsBareword(*start) || *start == '_') { if (Tcl_UtfCharComplete(start, numBytes)) { - scanned = TclUtfNext(start) - start; + scanned = Tcl_UtfToUniChar(start, &ch); } else { char utfBytes[TCL_UTF_MAX]; memcpy(utfBytes, start, (size_t) numBytes); utfBytes[numBytes] = '\0'; - scanned = TclUtfNext(utfBytes) - utfBytes; + scanned = Tcl_UtfToUniChar(utfBytes, &ch); } *lexemePtr = INVALID; Tcl_DecrRefCount(literal); diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 550d528..9579eb3 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -507,6 +507,7 @@ Tcl_NumUtfChars( int length) /* The length of the string in bytes, or -1 * for strlen(string). */ { + Tcl_UniChar ch; register int i = 0; /* @@ -518,19 +519,19 @@ Tcl_NumUtfChars( if (length < 0) { while ((*src != '\0') && (i < INT_MAX)) { - src = TclUtfNext(src); + src += TclUtfToUniChar(src, &ch); i++; } } else { register const char *endPtr = src + length - TCL_UTF_MAX; while (src < endPtr) { - src = TclUtfNext(src); + src += TclUtfToUniChar(src, &ch); i++; } endPtr += TCL_UTF_MAX; while ((src < endPtr) && Tcl_UtfCharComplete(src, endPtr - src)) { - src = TclUtfNext(src); + src += TclUtfToUniChar(src, &ch); i++; } if (src < endPtr) { @@ -858,9 +859,11 @@ Tcl_UtfAtIndex( register CONST char *src, /* The UTF-8 string. */ register int index) /* The position of the desired character. */ { + Tcl_UniChar ch; + while (index > 0) { index--; - src = TclUtfNext(src); + src += TclUtfToUniChar(src, &ch); } return src; } |