From 4de1b924a8f4f41a574d576427acfea490cd06ca Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 17 Apr 2020 11:02:19 +0000 Subject: Fix implementation of Tcl_UtfAtIndex() for TCL_UTF_MAX=6 (There's no test-case for this in the core-8-6-branch, but there is in core-8-branch). --- generic/tclUtf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generic/tclUtf.c b/generic/tclUtf.c index 94fa5f6..1ba474e 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -971,14 +971,16 @@ Tcl_UtfAtIndex( register int index) /* The position of the desired character. */ { while (index-- > 0) { - const char *next = TclUtfNext(src); + const char *next = TclUtfNext(src); +#if TCL_UTF_MAX <= 4 /* * 4-byte sequences generate two UCS-2 code units in the * UTF-16 representation, so in the current indexing scheme * we need to account for an extra index (total of two). */ index -= ((next - src) > 3); +#endif src = next; } -- cgit v0.12