diff options
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 66 |
1 files changed, 41 insertions, 25 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index e0cf01a..852af2b 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIO.c,v 1.61.2.17 2005/11/18 19:38:02 hobbs Exp $ + * RCS: @(#) $Id: tclIO.c,v 1.61.2.18 2006/02/15 16:04:27 dgp Exp $ */ #include "tclInt.h" @@ -1310,8 +1310,10 @@ Tcl_StackChannel(interp, typePtr, instanceData, mask, prevChan) } if (statePtr == NULL) { - Tcl_AppendResult(interp, "couldn't find state for channel \"", - Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, "couldn't find state for channel \"", + Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + } return (Tcl_Channel) NULL; } @@ -1329,9 +1331,11 @@ Tcl_StackChannel(interp, typePtr, instanceData, mask, prevChan) */ if ((mask & (statePtr->flags & (TCL_READABLE | TCL_WRITABLE))) == 0) { - Tcl_AppendResult(interp, - "reading and writing both disallowed for channel \"", - Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, + "reading and writing both disallowed for channel \"", + Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + } return (Tcl_Channel) NULL; } @@ -1350,8 +1354,10 @@ Tcl_StackChannel(interp, typePtr, instanceData, mask, prevChan) if (Tcl_Flush((Tcl_Channel) prevChanPtr) != TCL_OK) { statePtr->csPtr = csPtr; - Tcl_AppendResult(interp, "could not flush channel \"", - Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, "could not flush channel \"", + Tcl_GetChannelName(prevChan), "\"", (char *) NULL); + } return (Tcl_Channel) NULL; } @@ -1477,9 +1483,11 @@ Tcl_UnstackChannel (interp, chan) if (Tcl_Flush((Tcl_Channel) chanPtr) != TCL_OK) { statePtr->csPtr = csPtr; - Tcl_AppendResult(interp, "could not flush channel \"", - Tcl_GetChannelName((Tcl_Channel) chanPtr), "\"", - (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, "could not flush channel \"", + Tcl_GetChannelName((Tcl_Channel) chanPtr), "\"", + (char *) NULL); + } return TCL_ERROR; } @@ -2562,9 +2570,11 @@ Tcl_Close(interp, chan) } if (statePtr->flags & CHANNEL_INCLOSE) { - Tcl_AppendResult(interp, - "Illegal recursive call to close through close-handler of channel", - (char *) NULL); + if (interp) { + Tcl_AppendResult(interp, + "Illegal recursive call to close through close-handler of channel", + (char *) NULL); + } return TCL_ERROR; } statePtr->flags |= CHANNEL_INCLOSE; @@ -7574,13 +7584,17 @@ TclCopyChannel(interp, inChan, outChan, toRead, cmdPtr) outStatePtr = outPtr->state; if (inStatePtr->csPtr) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", - Tcl_GetChannelName(inChan), "\" is busy", NULL); + if (interp) { + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", + Tcl_GetChannelName(inChan), "\" is busy", NULL); + } return TCL_ERROR; } if (outStatePtr->csPtr) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", - Tcl_GetChannelName(outChan), "\" is busy", NULL); + if (interp) { + Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "channel \"", + Tcl_GetChannelName(outChan), "\" is busy", NULL); + } return TCL_ERROR; } @@ -7882,7 +7896,7 @@ CopyData(csPtr, mask) */ total = csPtr->total; - if (cmdPtr) { + if (cmdPtr && interp) { /* * Get a private copy of the command so we can mutate it * by adding arguments. Note that StopCopy frees our saved @@ -7906,12 +7920,14 @@ CopyData(csPtr, mask) Tcl_Release((ClientData) interp); } else { StopCopy(csPtr); - if (errObj) { - Tcl_SetObjResult(interp, errObj); - result = TCL_ERROR; - } else { - Tcl_ResetResult(interp); - Tcl_SetIntObj(Tcl_GetObjResult(interp), total); + if (interp) { + if (errObj) { + Tcl_SetObjResult(interp, errObj); + result = TCL_ERROR; + } else { + Tcl_ResetResult(interp); + Tcl_SetIntObj(Tcl_GetObjResult(interp), total); + } } } return result; |