summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-02-16 08:10:34 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-02-16 08:10:34 (GMT)
commit34580421592530f8a2cbfb7c2e4b1fd65a427f8e (patch)
tree039aa6f19528384e559d2d4c611882689d50a33a
parent0d58cca19add2b455623c3e7399d7797ae8400e6 (diff)
downloadtcl-34580421592530f8a2cbfb7c2e4b1fd65a427f8e.zip
tcl-34580421592530f8a2cbfb7c2e4b1fd65a427f8e.tar.gz
tcl-34580421592530f8a2cbfb7c2e4b1fd65a427f8e.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.c2
-rw-r--r--generic/tclUtil.c8
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) {