From ed8749e3d8e96b45b6296e804b00af547a0aaf04 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 6 Apr 2020 20:33:35 +0000 Subject: Fix [dd010cadfb]: [string trim] mishandles surrogates --- generic/tclUtil.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 842c55a..89b9f90 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -1725,7 +1725,7 @@ TrimRight( { const char *p = bytes + numBytes; int pInc; - Tcl_UniChar ch1 = 0, ch2 = 0; + int ch1, ch2; /* * Outer loop: iterate over string to be trimmed. @@ -1736,14 +1736,14 @@ TrimRight( int bytesLeft = numTrim; p = Tcl_UtfPrev(p, bytes); - pInc = TclUtfToUniChar(p, &ch1); + pInc = TclUtfToUCS4(p, &ch1); /* * Inner loop: scan trim string for match to current character. */ do { - int qInc = TclUtfToUniChar(q, &ch2); + int qInc = TclUtfToUCS4(q, &ch2); if (ch1 == ch2) { break; @@ -1823,14 +1823,14 @@ TrimLeft( int numTrim) /* ...and its length in bytes */ { const char *p = bytes; - Tcl_UniChar ch1 = 0, ch2 = 0; + int ch1, ch2; /* * Outer loop: iterate over string to be trimmed. */ do { - int pInc = TclUtfToUniChar(p, &ch1); + int pInc = TclUtfToUCS4(p, &ch1); const char *q = trim; int bytesLeft = numTrim; @@ -1839,7 +1839,7 @@ TrimLeft( */ do { - int qInc = TclUtfToUniChar(q, &ch2); + int qInc = TclUtfToUCS4(q, &ch2); if (ch1 == ch2) { break; -- cgit v0.12