diff options
| author | apnadkarni <apnmbx-wits@yahoo.com> | 2023-09-29 02:41:46 (GMT) |
|---|---|---|
| committer | apnadkarni <apnmbx-wits@yahoo.com> | 2023-09-29 02:41:46 (GMT) |
| commit | f5219a0f832f0f126d36f5f9094f96d1eddd1cb9 (patch) | |
| tree | db9dacc31bcec3dfd4c066e91762da351ac5de78 | |
| parent | bd10908764185f1cd2156ea68f00bab232761aca (diff) | |
| parent | e2e75c4389e2535cb9a46fd23e020aa35cce7887 (diff) | |
| download | tcl-f5219a0f832f0f126d36f5f9094f96d1eddd1cb9.zip tcl-f5219a0f832f0f126d36f5f9094f96d1eddd1cb9.tar.gz tcl-f5219a0f832f0f126d36f5f9094f96d1eddd1cb9.tar.bz2 | |
Merge 8.7"
| -rw-r--r-- | generic/tclEvent.c | 32 | ||||
| -rw-r--r-- | generic/tclMain.c | 33 |
2 files changed, 46 insertions, 19 deletions
diff --git a/generic/tclEvent.c b/generic/tclEvent.c index 541e708..0cf0df1 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -97,6 +97,8 @@ static int inExit = 0; static int subsystemsInitialized = 0; +static const char ENCODING_ERROR[] = "\n\t(encoding error in stderr)"; + /* * This variable contains the application wide exit handler. It will be called * by Tcl_Exit instead of the C-runtime exit if this variable is set to a @@ -294,9 +296,13 @@ HandleBgErrors( Tcl_WriteChars(errChannel, "error in background error handler:\n", -1); if (valuePtr) { - Tcl_WriteObj(errChannel, valuePtr); + if (Tcl_WriteObj(errChannel, valuePtr) < 0) { + Tcl_WriteChars(errChannel, ENCODING_ERROR, -1); + } } else { - Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp)); + if (Tcl_WriteObj(errChannel, Tcl_GetObjResult(interp)) < 0) { + Tcl_WriteChars(errChannel, ENCODING_ERROR, -1); + } } Tcl_WriteChars(errChannel, "\n", 1); Tcl_Flush(errChannel); @@ -483,18 +489,22 @@ TclDefaultBgErrorHandlerObjCmd( if (Tcl_FindCommand(interp, "bgerror", NULL, TCL_GLOBAL_ONLY) == NULL) { Tcl_RestoreInterpState(interp, saved); - Tcl_WriteObj(errChannel, Tcl_GetVar2Ex(interp, - "errorInfo", NULL, TCL_GLOBAL_ONLY)); + if (Tcl_WriteObj(errChannel, Tcl_GetVar2Ex(interp, + "errorInfo", NULL, TCL_GLOBAL_ONLY)) < 0) { + Tcl_WriteChars(errChannel, ENCODING_ERROR, -1); + } Tcl_WriteChars(errChannel, "\n", -1); } else { Tcl_DiscardInterpState(saved); - Tcl_WriteChars(errChannel, - "bgerror failed to handle background error.\n", -1); - Tcl_WriteChars(errChannel, " Original error: ", -1); - Tcl_WriteObj(errChannel, tempObjv[1]); - Tcl_WriteChars(errChannel, "\n", -1); - Tcl_WriteChars(errChannel, " Error in bgerror: ", -1); - Tcl_WriteObj(errChannel, resultPtr); + Tcl_WriteChars(errChannel, "bgerror failed to handle" + " background error.\n Original error: ", -1); + if (Tcl_WriteObj(errChannel, tempObjv[1]) < 0) { + Tcl_WriteChars(errChannel, ENCODING_ERROR, -1); + } + Tcl_WriteChars(errChannel, "\n Error in bgerror: ", -1); + if (Tcl_WriteObj(errChannel, resultPtr) < 0) { + Tcl_WriteChars(errChannel, ENCODING_ERROR, -1); + } Tcl_WriteChars(errChannel, "\n", -1); } Tcl_DecrRefCount(resultPtr); 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; |
