summaryrefslogtreecommitdiffstats
path: root/generic/tclDisassemble.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2014-02-04 09:09:06 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2014-02-04 09:09:06 (GMT)
commit14b32b82e117e3d6196985feca9750ad489f63cb (patch)
tree62ac6c2f0bc7a13ce0ee6042cde892978fa60a5f /generic/tclDisassemble.c
parent3f60452ac247a5915e3cca2e2845e73fd2d4ba54 (diff)
parent5be047220df93fa607f1ccdd007b46c55ee78664 (diff)
downloadtcl-14b32b82e117e3d6196985feca9750ad489f63cb.zip
tcl-14b32b82e117e3d6196985feca9750ad489f63cb.tar.gz
tcl-14b32b82e117e3d6196985feca9750ad489f63cb.tar.bz2
merge trunk
Diffstat (limited to 'generic/tclDisassemble.c')
-rw-r--r--generic/tclDisassemble.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/generic/tclDisassemble.c b/generic/tclDisassemble.c
index b818f18..00b5549 100644
--- a/generic/tclDisassemble.c
+++ b/generic/tclDisassemble.c
@@ -785,7 +785,7 @@ PrintSourceToObj(
int maxChars) /* Maximum number of chars to print. */
{
register const char *p;
- register int i = 0;
+ register int i = 0, len;
if (stringPtr == NULL) {
Tcl_AppendToObj(appendObj, "\"\"", -1);
@@ -794,32 +794,50 @@ PrintSourceToObj(
Tcl_AppendToObj(appendObj, "\"", -1);
p = stringPtr;
- for (; (*p != '\0') && (i < maxChars); p++, i++) {
- switch (*p) {
+ for (; (*p != '\0') && (i < maxChars); p+=len) {
+ Tcl_UniChar ch;
+
+ len = TclUtfToUniChar(p, &ch);
+ switch (ch) {
case '"':
Tcl_AppendToObj(appendObj, "\\\"", -1);
+ i += 2;
continue;
case '\f':
Tcl_AppendToObj(appendObj, "\\f", -1);
+ i += 2;
continue;
case '\n':
Tcl_AppendToObj(appendObj, "\\n", -1);
+ i += 2;
continue;
case '\r':
Tcl_AppendToObj(appendObj, "\\r", -1);
+ i += 2;
continue;
case '\t':
Tcl_AppendToObj(appendObj, "\\t", -1);
+ i += 2;
continue;
case '\v':
Tcl_AppendToObj(appendObj, "\\v", -1);
+ i += 2;
continue;
default:
- Tcl_AppendPrintfToObj(appendObj, "%c", *p);
+ if (ch < 0x20 || ch >= 0x7f) {
+ Tcl_AppendPrintfToObj(appendObj, "\\u%04x", ch);
+ i += 6;
+ } else {
+ Tcl_AppendPrintfToObj(appendObj, "%c", ch);
+ i++;
+ }
continue;
}
}
Tcl_AppendToObj(appendObj, "\"", -1);
+ if (*p != '\0') {
+ Tcl_AppendToObj(appendObj, "...", -1);
+ }
}
/*