summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2011-06-06 22:06:07 (GMT)
committerdgp <dgp@users.sourceforge.net>2011-06-06 22:06:07 (GMT)
commit6594906a3948d6ffb7d51ba989ac3754f2ff230e (patch)
treee97a209a0de1adc679dbf9d5c4c146263ac0a0e9
parent41e0b7430523cf029f1d8d906d237d9b3ba443fd (diff)
parent1561619c55815e32523818007685d998b7fc7ea8 (diff)
downloadtk-6594906a3948d6ffb7d51ba989ac3754f2ff230e.zip
tk-6594906a3948d6ffb7d51ba989ac3754f2ff230e.tar.gz
tk-6594906a3948d6ffb7d51ba989ac3754f2ff230e.tar.bz2
Restore proper NUL output to the [console]. [Bug 2546087]
-rw-r--r--ChangeLog5
-rw-r--r--generic/tkConsole.c18
-rw-r--r--library/console.tcl2
3 files changed, 23 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8414253..f4a8cc8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-06 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tkConsole.c: Restore proper NUL output to the [console].
+ * library/console.tcl: [Bug 2546087]
+
2011-04-22 Peter Spjuth <peter.spjuth@gmail.com>
* generic/tkCanvPoly.c: [Bug 3291543] There was a crash if dchars
diff --git a/generic/tkConsole.c b/generic/tkConsole.c
index cb16ca2..0335e76 100644
--- a/generic/tkConsole.c
+++ b/generic/tkConsole.c
@@ -513,8 +513,22 @@ ConsoleOutput(
Tcl_Interp *consoleInterp = info->consoleInterp;
if (consoleInterp && !Tcl_InterpDeleted(consoleInterp)) {
+ Tcl_DString ds;
+ Tcl_Encoding utf8 = Tcl_GetEncoding(NULL, "utf-8");
+
+ /*
+ * Not checking for utf8 == NULL. Did not check for TCL_ERROR
+ * from Tcl_SetChannelOption() in Tk_InitConsoleChannels() either.
+ * Assumption is utf-8 Tcl_Encoding is reliably present.
+ */
+
+ CONST char *bytes
+ = Tcl_ExternalToUtfDString(utf8, buf, toWrite, &ds);
+ int numBytes = Tcl_DStringLength(&ds);
Tcl_Obj *cmd = Tcl_NewStringObj("tk::ConsoleOutput", -1);
+ Tcl_FreeEncoding(utf8);
+
if (data->type == TCL_STDERR) {
Tcl_ListObjAppendElement(NULL, cmd,
Tcl_NewStringObj("stderr", -1));
@@ -523,7 +537,9 @@ ConsoleOutput(
Tcl_NewStringObj("stdout", -1));
}
Tcl_ListObjAppendElement(NULL, cmd,
- Tcl_NewStringObj(buf, toWrite));
+ Tcl_NewStringObj(bytes, numBytes));
+
+ Tcl_DStringFree(&ds);
Tcl_IncrRefCount(cmd);
Tcl_GlobalEvalObj(consoleInterp, cmd);
Tcl_DecrRefCount(cmd);
diff --git a/library/console.tcl b/library/console.tcl
index d9c788b..5df7927 100644
--- a/library/console.tcl
+++ b/library/console.tcl
@@ -677,7 +677,7 @@ proc ::tk::ConsoleInsert {w s} {
proc ::tk::ConsoleOutput {dest string} {
set w .console
- $w insert output [string map {\0 \u25a1} $string] $dest
+ $w insert output $string $dest
::tk::console::ConstrainBuffer $w $::tk::console::maxLines
$w see insert
}