From 5204a77ccd7306b8ed7c3c264c88171f68180efd Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 18 May 2020 22:11:45 +0000 Subject: Eliminate two Tcl_UtfNext() calls, because the UtfToUniChar() variants are more likely to do the right thing when surrogates are involved. --- generic/tkFont.c | 4 ++-- generic/tkSelect.c | 3 ++- 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; -- cgit v0.12