diff options
-rw-r--r-- | generic/tclAlloc.c | 2 | ||||
-rw-r--r-- | generic/tclBinary.c | 2 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 2 | ||||
-rw-r--r-- | generic/tclOptimize.c | 2 | ||||
-rw-r--r-- | generic/tclParse.c | 2 | ||||
-rw-r--r-- | generic/tclUtf.c | 24 |
6 files changed, 18 insertions, 16 deletions
diff --git a/generic/tclAlloc.c b/generic/tclAlloc.c index f4755b3..6187ce2 100644 --- a/generic/tclAlloc.c +++ b/generic/tclAlloc.c @@ -345,7 +345,7 @@ TclpAlloc( nextf[bucket] = overPtr->next; overPtr->overMagic0 = overPtr->overMagic1 = MAGIC; - overPtr->bucketIndex = (unsigned char) bucket; + overPtr->bucketIndex = UCHAR(bucket); #ifdef MSTATS numMallocs[bucket]++; diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 52ef457..8f4f6ab 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.c @@ -2617,7 +2617,7 @@ BinaryEncodeUu( unsigned char *data, *start, *cursor; int offset, count, rawLength, n, i, j, bits, index; int lineLength = 61; - const unsigned char SingleNewline[] = { (unsigned char) '\n' }; + const unsigned char SingleNewline[] = { UCHAR('\n') }; const unsigned char *wrapchar = SingleNewline; int wrapcharlen = sizeof(SingleNewline); enum { OPT_MAXLEN, OPT_WRAPCHAR }; diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 7516208..298b3b7 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -1409,7 +1409,7 @@ StringIndexCmd( */ if (TclIsPureByteArray(objv[1])) { - unsigned char uch = (unsigned char) ch; + unsigned char uch = UCHAR(ch); Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(&uch, 1)); } else { diff --git a/generic/tclOptimize.c b/generic/tclOptimize.c index 827d89d..03daa40 100644 --- a/generic/tclOptimize.c +++ b/generic/tclOptimize.c @@ -34,7 +34,7 @@ static void TrimUnreachable(CompileEnv *envPtr); #define AddrLength(address) \ (tclInstructionTable[*(unsigned char *)(address)].numBytes) #define InstLength(instruction) \ - (tclInstructionTable[(unsigned char)(instruction)].numBytes) + (tclInstructionTable[UCHAR(instruction)].numBytes) /* * ---------------------------------------------------------------------- diff --git a/generic/tclParse.c b/generic/tclParse.c index 23a07cf..25304407 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -911,7 +911,7 @@ TclParseBackslash( /* * Keep only the last byte (2 hex digits). */ - result = (unsigned char) result; + result = UCHAR(result); } break; case 'u': diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 9792071..7524aa0 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -86,7 +86,7 @@ static const unsigned char totalBytes[256] = { */ static int UtfCount(int ch); -static int Invalid(unsigned char *src); +static int Invalid(const char *src); static int UCS4ToUpper(int ch); static int UCS4ToTitle(int ch); @@ -161,9 +161,9 @@ static const unsigned char bounds[28] = { static int Invalid( - unsigned char *src) /* Points to lead byte of a UTF-8 byte sequence */ + const char *src) /* Points to lead byte of a UTF-8 byte sequence */ { - unsigned char byte = *src; + unsigned char byte = UCHAR(*src); int index; if ((byte & 0xC3) != 0xC0) { @@ -171,7 +171,7 @@ Invalid( return 0; } index = (byte - 0xC0) >> 1; - if (src[1] < bounds[index] || src[1] > bounds[index+1]) { + if (UCHAR(src[1]) < bounds[index] || UCHAR(src[1]) > bounds[index+1]) { /* Out of bounds - report invalid. */ return 1; } @@ -734,9 +734,14 @@ const char * Tcl_UtfNext( const char *src) /* The current location in the string. */ { - int left = totalBytes[UCHAR(*src)]; - const char *next = src + 1; + int left; + const char *next; + if (Invalid(src)) { + return src + 1; + } + left = totalBytes[UCHAR(*src)]; + next = src + 1; while (--left) { if ((*next & 0xC0) != 0x80) { /* @@ -748,9 +753,6 @@ Tcl_UtfNext( } next++; } - if (Invalid((unsigned char *)src)) { - return src + 1; - } return next; } @@ -785,7 +787,7 @@ Tcl_UtfPrev( /* If we cannot find a lead byte that might * start a prefix of a valid UTF byte sequence, * we will fallback to a one-byte back step */ - unsigned char *look = (unsigned char *)fallback; + const char *look = fallback; /* Start search at the fallback position */ /* Quick boundary case exit. */ @@ -794,7 +796,7 @@ Tcl_UtfPrev( } do { - unsigned char byte = look[0]; + unsigned char byte = UCHAR(look[0]); if (byte < 0x80) { /* |