summaryrefslogtreecommitdiffstats
path: root/generic
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)
commite7704f85aa81ff101952d41f121bb52631052981 (patch)
tree62ac6c2f0bc7a13ce0ee6042cde892978fa60a5f /generic
parent76a8030f939360bd39bc940842f79175c47ed828 (diff)
parenta72ae0f931f9ac8a78ef7b78f854ae68e66f9dd1 (diff)
downloadtcl-e7704f85aa81ff101952d41f121bb52631052981.zip
tcl-e7704f85aa81ff101952d41f121bb52631052981.tar.gz
tcl-e7704f85aa81ff101952d41f121bb52631052981.tar.bz2
merge trunk
Diffstat (limited to 'generic')
-rw-r--r--generic/tclDisassemble.c26
-rw-r--r--generic/tclExecute.c28
2 files changed, 46 insertions, 8 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);
+ }
}
/*
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index ac78370..89305e6 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -5905,14 +5905,34 @@ TEBCresume(
trim2 = 0;
}
createTrimmedString:
+ /*
+ * Careful here; trim set often contains non-ASCII characters so we
+ * take care when printing. [Bug 971cb4f1db]
+ */
+
+#ifdef TCL_COMPILE_DEBUG
+ if (traceInstructions) {
+ TRACE(("\"%.30s\" ", O2S(valuePtr)));
+ TclPrintObject(stdout, value2Ptr, 30);
+ printf(" => ");
+ }
+#endif
if (trim1 == 0 && trim2 == 0) {
- TRACE_WITH_OBJ(("\"%.30s\" \"%.30s\" => ",
- O2S(valuePtr), O2S(value2Ptr)), valuePtr);
+#ifdef TCL_COMPILE_DEBUG
+ if (traceInstructions) {
+ TclPrintObject(stdout, valuePtr, 30);
+ printf("\n");
+ }
+#endif
NEXT_INST_F(1, 1, 0);
} else {
objResultPtr = Tcl_NewStringObj(string1+trim1, length-trim1-trim2);
- TRACE_WITH_OBJ(("\"%.30s\" \"%.30s\" => ",
- O2S(valuePtr), O2S(value2Ptr)), objResultPtr);
+#ifdef TCL_COMPILE_DEBUG
+ if (traceInstructions) {
+ TclPrintObject(stdout, objResultPtr, 30);
+ printf("\n");
+ }
+#endif
NEXT_INST_F(1, 2, 1);
}
}