summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-10-07 08:40:23 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-10-07 08:40:23 (GMT)
commit236c0f4ffd3ac7f1cef522c0c0e00b9e72cf995f (patch)
treefe0feaa7c3072b1c0a3936dd8f3179b9fa43d0df /generic
parent2738bd34505c7fa7a1d68fe8f5bbaa2f5d35c12c (diff)
downloadtcl-236c0f4ffd3ac7f1cef522c0c0e00b9e72cf995f.zip
tcl-236c0f4ffd3ac7f1cef522c0c0e00b9e72cf995f.tar.gz
tcl-236c0f4ffd3ac7f1cef522c0c0e00b9e72cf995f.tar.bz2
Fix surrogate handling in PrintSourceToObj(), differenciating for TCL_UTF_MAX = 6 (androwish) and TCL_UTF_MAX = 4 (tip-389-impl). No effect when TCL_UTF_MAX = 3.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclDisassemble.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c
index 15502e7..86f0e1d 100644
--- a/generic/tclDisassemble.c
+++ b/generic/tclDisassemble.c
@@ -833,8 +833,19 @@ PrintSourceToObj(
continue;
default:
#if TCL_UTF_MAX > 4
- if ((int) ch > 0xffff) {
- Tcl_AppendPrintfToObj(appendObj, "\\U%08x", (int) ch);
+ if (ch > 0xffff) {
+ Tcl_AppendPrintfToObj(appendObj, "\\U%08x", ch);
+ i += 10;
+ } else
+#elif TCL_UTF_MAX > 3
+ /* If len == 0, this means we have a char > 0xffff, resulting in
+ * TclUtfToUniChar producing a surrogate pair. We want to output
+ * this pair as a single Unicode character.
+ */
+ if (len == 0) {
+ int upper = ((ch & 0x3ff) + 1) << 10;
+ len = TclUtfToUniChar(p, &ch);
+ Tcl_AppendPrintfToObj(appendObj, "\\U%08x", upper + (ch & 0x3ff));
i += 10;
} else
#endif