diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-02-15 16:13:15 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-02-15 16:13:15 (GMT) |
commit | c6e348a28b0d74bc880f56b2f2db6f8c97f1b6ca (patch) | |
tree | eb9367fd41589fb3a37dc89007851926dbfe6cd4 /generic/tclUtil.c | |
parent | 13b1a0635f7e5f4c9fce04fe3474d16418d57522 (diff) | |
download | tcl-c6e348a28b0d74bc880f56b2f2db6f8c97f1b6ca.zip tcl-c6e348a28b0d74bc880f56b2f2db6f8c97f1b6ca.tar.gz tcl-c6e348a28b0d74bc880f56b2f2db6f8c97f1b6ca.tar.bz2 |
Fix [d43f96c1a8]: string trimright is broken for Emoji
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r-- | generic/tclUtil.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c index d7baedd..0e3449d 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -1686,7 +1686,7 @@ TclTrimRight( * rely on (trim[numTrim] == '\0'). */ { const char *pp, *p = bytes + numBytes; - Tcl_UniChar ch1 = 0; + int ch1, ch2; /* Empty strings -> nothing to do */ if ((numBytes == 0) || (numTrim == 0)) { @@ -1700,12 +1700,14 @@ TclTrimRight( do { const char *q = trim; int pInc = 0, bytesLeft = numTrim; - Tcl_UniChar ch2 = 0; pp = TclUtfPrev(p, bytes); +#if TCL_UTF_MAX <= 4 + pp = TclUtfPrev(pp, bytes); +#endif do { pp += pInc; - pInc = TclUtfToUniChar(pp, &ch1); + pInc = TclUtfToUCS4(pp, &ch1); } while (pp + pInc < p); /* @@ -1713,7 +1715,7 @@ TclTrimRight( */ do { - int qInc = TclUtfToUniChar(q, &ch2); + int qInc = TclUtfToUCS4(q, &ch2); if (ch1 == ch2) { break; @@ -1766,7 +1768,7 @@ TclTrimLeft( * rely on (trim[numTrim] == '\0'). */ { const char *p = bytes; - Tcl_UniChar ch1 = 0; + int ch1, ch2; /* Empty strings -> nothing to do */ if ((numBytes == 0) || (numTrim == 0)) { @@ -1778,8 +1780,7 @@ TclTrimLeft( */ do { - Tcl_UniChar ch2 = 0; - int pInc = TclUtfToUniChar(p, &ch1); + int pInc = TclUtfToUCS4(p, &ch1); const char *q = trim; int bytesLeft = numTrim; @@ -1788,7 +1789,7 @@ TclTrimLeft( */ do { - int qInc = TclUtfToUniChar(q, &ch2); + int qInc = TclUtfToUCS4(q, &ch2); if (ch1 == ch2) { break; |