summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-28 15:23:51 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-28 15:23:51 (GMT)
commit01a22f1c5755b9d734b8aa885b738b0054f45185 (patch)
treeb99060601d2f1e90ea4668882bb51a34242c5310
parent41883cbddfa57f2b27197042f807763f31b4ecd0 (diff)
downloadtcl-01a22f1c5755b9d734b8aa885b738b0054f45185.zip
tcl-01a22f1c5755b9d734b8aa885b738b0054f45185.tar.gz
tcl-01a22f1c5755b9d734b8aa885b738b0054f45185.tar.bz2
Proposed fix for [0df5906dd7]
-rw-r--r--generic/tclMain.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/generic/tclMain.c b/generic/tclMain.c
index 628deaa..906c197 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.c
@@ -29,6 +29,7 @@
*/
static const char DEFAULT_PRIMARY_PROMPT[] = "% ";
+static const char ENCODING_ERROR[] = "\n\t(encoding error in stderr)";
/*
* This file can be compiled on Windows in UNICODE mode, as well as on all
@@ -249,7 +250,9 @@ Tcl_SourceRCFile(
if (Tcl_EvalFile(interp, fullName) != TCL_OK) {
chan = Tcl_GetStdChannel(TCL_STDERR);
if (chan) {
- Tcl_WriteObj(chan, Tcl_GetObjResult(interp));
+ if (Tcl_WriteObj(chan, Tcl_GetObjResult(interp)) < 0) {
+ Tcl_WriteChars(chan, ENCODING_ERROR, -1);
+ }
Tcl_WriteChars(chan, "\n", 1);
}
}
@@ -375,7 +378,9 @@ Tcl_MainEx(
if (chan) {
Tcl_WriteChars(chan,
"application-specific initialization failed: ", -1);
- Tcl_WriteObj(chan, Tcl_GetObjResult(interp));
+ if (Tcl_WriteObj(chan, Tcl_GetObjResult(interp)) < 0) {
+ Tcl_WriteChars(chan, ENCODING_ERROR, -1);
+ }
Tcl_WriteChars(chan, "\n", 1);
}
}
@@ -415,7 +420,9 @@ Tcl_MainEx(
Tcl_DecrRefCount(keyPtr);
if (valuePtr) {
- Tcl_WriteObj(chan, valuePtr);
+ if (Tcl_WriteObj(chan, valuePtr) < 0) {
+ Tcl_WriteChars(chan, ENCODING_ERROR, -1);
+ }
}
Tcl_WriteChars(chan, "\n", 1);
Tcl_DecrRefCount(options);
@@ -528,7 +535,9 @@ Tcl_MainEx(
if (code != TCL_OK) {
chan = Tcl_GetStdChannel(TCL_STDERR);
if (chan) {
- Tcl_WriteObj(chan, Tcl_GetObjResult(interp));
+ if (Tcl_WriteObj(chan, Tcl_GetObjResult(interp)) < 0) {
+ Tcl_WriteChars(chan, ENCODING_ERROR, -1);
+ }
Tcl_WriteChars(chan, "\n", 1);
}
} else if (is.tty) {
@@ -537,7 +546,9 @@ Tcl_MainEx(
(void)Tcl_GetStringFromObj(resultPtr, &length);
chan = Tcl_GetStdChannel(TCL_STDOUT);
if ((length > 0) && chan) {
- Tcl_WriteObj(chan, resultPtr);
+ if (Tcl_WriteObj(chan, resultPtr) < 0) {
+ Tcl_WriteChars(chan, ENCODING_ERROR, -1);
+ }
Tcl_WriteChars(chan, "\n", 1);
}
Tcl_DecrRefCount(resultPtr);
@@ -802,7 +813,9 @@ StdinProc(
chan = Tcl_GetStdChannel(TCL_STDERR);
if (chan != NULL) {
- Tcl_WriteObj(chan, Tcl_GetObjResult(interp));
+ if (Tcl_WriteObj(chan, Tcl_GetObjResult(interp)) < 0) {
+ Tcl_WriteChars(chan, ENCODING_ERROR, -1);
+ }
Tcl_WriteChars(chan, "\n", 1);
}
} else if (isPtr->tty) {
@@ -812,7 +825,9 @@ StdinProc(
Tcl_IncrRefCount(resultPtr);
(void)Tcl_GetStringFromObj(resultPtr, &length);
if ((length > 0) && (chan != NULL)) {
- Tcl_WriteObj(chan, resultPtr);
+ if (Tcl_WriteObj(chan, resultPtr) < 0) {
+ Tcl_WriteChars(chan, ENCODING_ERROR, -1);
+ }
Tcl_WriteChars(chan, "\n", 1);
}
Tcl_DecrRefCount(resultPtr);
@@ -883,7 +898,9 @@ Prompt(
"\n (script that generates prompt)");
chan = Tcl_GetStdChannel(TCL_STDERR);
if (chan != NULL) {
- Tcl_WriteObj(chan, Tcl_GetObjResult(interp));
+ if (Tcl_WriteObj(chan, Tcl_GetObjResult(interp)) < 0) {
+ Tcl_WriteChars(chan, ENCODING_ERROR, -1);
+ }
Tcl_WriteChars(chan, "\n", 1);
}
goto defaultPrompt;