summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-18 22:11:45 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-05-18 22:11:45 (GMT)
commit5204a77ccd7306b8ed7c3c264c88171f68180efd (patch)
treee07445a1c633235ea04deb169124d7d12867f71c /generic
parent1d435ce1f0cd4775332957c719ee82d78bf926b7 (diff)
downloadtk-5204a77ccd7306b8ed7c3c264c88171f68180efd.zip
tk-5204a77ccd7306b8ed7c3c264c88171f68180efd.tar.gz
tk-5204a77ccd7306b8ed7c3c264c88171f68180efd.tar.bz2
Eliminate two Tcl_UtfNext() calls, because the UtfToUniChar() variants are more likely to do the right thing when surrogates are involved.
Diffstat (limited to 'generic')
-rw-r--r--generic/tkFont.c4
-rw-r--r--generic/tkSelect.c3
2 files changed, 4 insertions, 3 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 0ec79a6..bf35626 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -2743,8 +2743,8 @@ Tk_CharBbox(
x += chunkPtr->x;
}
if (widthPtr != NULL) {
- Tk_MeasureChars(tkfont, end, Tcl_UtfNext(end) - end,
- -1, 0, &w);
+ int ch;
+ Tk_MeasureChars(tkfont, end, TkUtfToUniChar(end, &ch), -1, 0, &w);
}
goto check;
}
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index c64c93f..5c71465 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -1400,11 +1400,12 @@ HandleTclCommand(
cmdInfoPtr->charOffset += Tcl_NumUtfChars(string, -1);
cmdInfoPtr->buffer[0] = '\0';
} else {
+ Tcl_UniChar ch = 0;
p = string;
string += count;
numChars = 0;
while (p < string) {
- p = Tcl_UtfNext(p);
+ p += Tcl_UtfToUniChar(p, &ch);
numChars++;
}
cmdInfoPtr->charOffset += numChars;