diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-02-16 08:10:34 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-02-16 08:10:34 (GMT) |
| commit | d97e25b2ad96e4be2e23c349c2d0e6d44cab07e4 (patch) | |
| tree | 039aa6f19528384e559d2d4c611882689d50a33a | |
| parent | c6e348a28b0d74bc880f56b2f2db6f8c97f1b6ca (diff) | |
| download | tcl-d97e25b2ad96e4be2e23c349c2d0e6d44cab07e4.zip tcl-d97e25b2ad96e4be2e23c349c2d0e6d44cab07e4.tar.gz tcl-d97e25b2ad96e4be2e23c349c2d0e6d44cab07e4.tar.bz2 | |
Fix Tcl_UtfPrev for TCL_UTF_MAX>3, so it can jump back over Emoji. Backported from 8.7, no change for TCL_UTF_MAX=3.
This way, the previous fix can be slightly more simplified, and working for TCL_UTF_MAX>3 too.
| -rw-r--r-- | generic/tclUtf.c | 2 | ||||
| -rw-r--r-- | generic/tclUtil.c | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 5ae977a..f99c497 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -888,7 +888,7 @@ Tcl_UtfPrev( /* Continue the search backwards... */ look--; - } while (trailBytesSeen < 3); + } while (trailBytesSeen < (TCL_UTF_MAX < 4 ? 3 : 4)); /* * We've seen 3 trail bytes, so we know there will not be a diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 0e3449d..450f3bf 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -1702,7 +1702,7 @@ TclTrimRight( int pInc = 0, bytesLeft = numTrim; pp = TclUtfPrev(p, bytes); -#if TCL_UTF_MAX <= 4 +#if TCL_UTF_MAX < 4 pp = TclUtfPrev(pp, bytes); #endif do { @@ -1715,14 +1715,14 @@ TclTrimRight( */ do { - int qInc = TclUtfToUCS4(q, &ch2); + pInc = TclUtfToUCS4(q, &ch2); if (ch1 == ch2) { break; } - q += qInc; - bytesLeft -= qInc; + q += pInc; + bytesLeft -= pInc; } while (bytesLeft); if (bytesLeft == 0) { |
