diff options
author | dgp <dgp@users.sourceforge.net> | 2020-04-13 02:31:03 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2020-04-13 02:31:03 (GMT) |
commit | 3d83ad9ffdbb147e16375f37652aaed1bfc77335 (patch) | |
tree | 12482c154fafb3a9d7d36d758cc9e9e63c090eba /generic | |
parent | a7989b0e58febbaf59a73a11cca96881dc525b18 (diff) | |
parent | d1a1538c301096e5be710310329fa391a61a3b33 (diff) | |
download | tcl-3d83ad9ffdbb147e16375f37652aaed1bfc77335.zip tcl-3d83ad9ffdbb147e16375f37652aaed1bfc77335.tar.gz tcl-3d83ad9ffdbb147e16375f37652aaed1bfc77335.tar.bz2 |
merge 8.5
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclUtil.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 01f1d34..2a08db1 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -1570,8 +1570,12 @@ static inline int TrimRight( const char *bytes, /* String to be trimmed... */ int numBytes, /* ...and its length in bytes */ + /* Calls to TclUtfToUniChar() in this routine + * rely on (bytes[numBytes] == '\0'). */ const char *trim, /* String of trim characters... */ int numTrim) /* ...and its length in bytes */ + /* Calls to TclUtfToUniChar() in this routine + * rely on (trim[numTrim] == '\0'). */ { const char *pp, *p = bytes + numBytes; @@ -1579,10 +1583,13 @@ TrimRight( do { Tcl_UniChar ch1; const char *q = trim; - int bytesLeft = numTrim; + int pInc = 0, bytesLeft = numTrim; pp = Tcl_UtfPrev(p, bytes); - (void)TclUtfToUniChar(pp, &ch1); + do { + pp += pInc; + pInc = TclUtfToUniChar(pp, &ch1); + } while (pp + pInc < p); /* Inner loop: scan trim string for match to current character */ do { @@ -1601,7 +1608,8 @@ TrimRight( /* No match; trim task done; *p is last non-trimmed char */ break; } - } while ((p = pp) > bytes); + p = pp; + } while (p > bytes); return numBytes - (p - bytes); } |