summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-04-23 23:23:00 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-04-23 23:23:00 (GMT)
commit4519681dcd20c967abbe68795911c77c317fab4f (patch)
tree7a5656d244da5d8eb7769606adb04b414df91919 /generic
parent9acb063268f48f19e3c67a877f2c83e15fd1019d (diff)
downloadtcl-4519681dcd20c967abbe68795911c77c317fab4f.zip
tcl-4519681dcd20c967abbe68795911c77c317fab4f.tar.gz
tcl-4519681dcd20c967abbe68795911c77c317fab4f.tar.bz2
Bug-fix in Tcl_UtfAtIndex (for TCL_UTF_MAX=4 only). With test-case (in "string totitle") demonstrating the bug.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclUtf.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 0d88d36..c08464b 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -762,10 +762,18 @@ Tcl_UtfAtIndex(
register int index) /* The position of the desired character. */
{
Tcl_UniChar ch = 0;
+ int len = 1;
while (index-- > 0) {
+ len = TclUtfToUniChar(src, &ch);
+ src += len;
+ }
+#if TCL_UTF_MAX == 4
+ if (!len) {
+ /* Index points at character following High Surrogate */
src += TclUtfToUniChar(src, &ch);
}
+#endif
return src;
}