Tcl Source Code

Artifact [5d91929e02]
Login

Artifact 5d91929e02ff3bda153901631271628464433db5:

Attachment "1380662.patch" to ticket [1380662fff] added by dgp 2006-02-10 03:42:48.
Index: generic/tclIO.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIO.c,v
retrieving revision 1.103
diff -u -r1.103 tclIO.c
--- generic/tclIO.c	13 Dec 2005 22:43:17 -0000	1.103
+++ generic/tclIO.c	9 Feb 2006 20:32:11 -0000
@@ -1272,8 +1272,10 @@
     }
 
     if (statePtr == NULL) {
-	Tcl_AppendResult(interp, "couldn't find state for channel \"",
-		Tcl_GetChannelName(prevChan), "\"", NULL);
+	if (interp) {
+	    Tcl_AppendResult(interp, "couldn't find state for channel \"",
+		    Tcl_GetChannelName(prevChan), "\"", NULL);
+	}
 	return (Tcl_Channel) NULL;
     }
 
@@ -1291,9 +1293,11 @@
      */
 
     if ((mask & (statePtr->flags & (TCL_READABLE | TCL_WRITABLE))) == 0) {
-	Tcl_AppendResult(interp,
-		"reading and writing both disallowed for channel \"",
-		Tcl_GetChannelName(prevChan), "\"", NULL);
+	if (interp) {
+	    Tcl_AppendResult(interp,
+		    "reading and writing both disallowed for channel \"",
+		    Tcl_GetChannelName(prevChan), "\"", NULL);
+	}
 	return (Tcl_Channel) NULL;
     }
 
@@ -1312,8 +1316,10 @@
 
 	if (Tcl_Flush((Tcl_Channel) prevChanPtr) != TCL_OK) {
 	    statePtr->csPtr = csPtr;
-	    Tcl_AppendResult(interp, "could not flush channel \"",
-		    Tcl_GetChannelName(prevChan), "\"", NULL);
+	    if (interp) {
+		Tcl_AppendResult(interp, "could not flush channel \"",
+			Tcl_GetChannelName(prevChan), "\"", NULL);
+	    }
 	    return (Tcl_Channel) NULL;
 	}
 
@@ -1462,7 +1468,7 @@
 		 * to the regular message if nothing was found in the
 		 * bypasses.
 		 */
-		if (!TclChanCaughtErrorBypass(interp, chan)) {
+		if (!TclChanCaughtErrorBypass(interp, chan) && interp) {
 		    Tcl_AppendResult(interp, "could not flush channel \"",
 			    Tcl_GetChannelName((Tcl_Channel) chanPtr), "\"",
 			    NULL);
@@ -2404,7 +2410,9 @@
 	    Tcl_DecrRefCount(statePtr->chanMsg);
 	    statePtr->chanMsg = NULL;
 	}
-	Tcl_SetChannelErrorInterp(interp,statePtr->unreportedMsg);
+	if (interp) {
+	    Tcl_SetChannelErrorInterp(interp,statePtr->unreportedMsg);
+	}
     }
     if (errorCode == 0) {
 	errorCode = result;
@@ -2736,8 +2744,10 @@
     }
 
     if (statePtr->flags & CHANNEL_INCLOSE) {
-	Tcl_AppendResult(interp, "Illegal recursive call to close ",
-		"through close-handler of channel", NULL);
+	if (interp) {
+	    Tcl_AppendResult(interp, "Illegal recursive call to close ",
+		    "through close-handler of channel", NULL);
+	}
 	return TCL_ERROR;
     }
     statePtr->flags |= CHANNEL_INCLOSE;
@@ -7853,13 +7863,17 @@
     outStatePtr = outPtr->state;
 
     if (inStatePtr->csPtr) {
-	Tcl_AppendResult(interp, "channel \"",
-		Tcl_GetChannelName(inChan), "\" is busy", NULL);
+	if (interp) {
+	    Tcl_AppendResult(interp, "channel \"",
+		    Tcl_GetChannelName(inChan), "\" is busy", NULL);
+	}
 	return TCL_ERROR;
     }
     if (outStatePtr->csPtr) {
-	Tcl_AppendResult(interp, "channel \"",
-		Tcl_GetChannelName(outChan), "\" is busy", NULL);
+	if (interp) {
+	    Tcl_AppendResult(interp, "channel \"",
+		    Tcl_GetChannelName(outChan), "\" is busy", NULL);
+	}
 	return TCL_ERROR;
     }
 
@@ -8165,7 +8179,7 @@
      */
 
     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 reference to the
@@ -8189,12 +8203,14 @@
 	Tcl_Release((ClientData) interp);
     } else {
 	StopCopy(csPtr);
-	if (errObj) {
-	    Tcl_SetObjResult(interp, errObj);
-	    result = TCL_ERROR;
-	} else {
-	    Tcl_ResetResult(interp);
-	    Tcl_SetObjResult(interp, Tcl_NewIntObj(total));
+	if (interp) {
+	    if (errObj) {
+		Tcl_SetObjResult(interp, errObj);
+		result = TCL_ERROR;
+	    } else {
+		Tcl_ResetResult(interp);
+		Tcl_SetObjResult(interp, Tcl_NewIntObj(total));
+	    }
 	}
     }
     return result;
Index: generic/tclIORChan.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIORChan.c,v
retrieving revision 1.12
diff -u -r1.12 tclIORChan.c
--- generic/tclIORChan.c	13 Dec 2005 22:43:17 -0000	1.12
+++ generic/tclIORChan.c	9 Feb 2006 20:32:12 -0000
@@ -845,6 +845,9 @@
     if (Tcl_ListObjGetElements(interp, msgObj, &lc, &lv) != TCL_OK) {
 	Tcl_Panic("TclChanCaughtErrorBypass: Bad syntax of caught result");
     }
+    if (interp == NULL) {
+	return;
+    }
 
     explicitResult = lc & 1;		/* Odd number of values? */
     numOptions = lc - explicitResult;
Index: generic/tclIOUtil.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIOUtil.c,v
retrieving revision 1.127
diff -u -r1.127 tclIOUtil.c
--- generic/tclIOUtil.c	15 Dec 2005 04:08:33 -0000	1.127
+++ generic/tclIOUtil.c	9 Feb 2006 20:32:12 -0000
@@ -1906,7 +1906,9 @@
 
     msg = Tcl_ErrnoMsg(errno);
     id = Tcl_ErrnoId();
-    Tcl_SetErrorCode(interp, "POSIX", id, msg, NULL);
+    if (interp) {
+	Tcl_SetErrorCode(interp, "POSIX", id, msg, NULL);
+    }
     return msg;
 }