? fcmd.diff
Index: tclUnixFCmd.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixFCmd.c,v
retrieving revision 1.37
diff -u -r1.37 tclUnixFCmd.c
--- tclUnixFCmd.c	26 Apr 2004 15:51:20 -0000	1.37
+++ tclUnixFCmd.c	3 Sep 2004 09:05:25 -0000
@@ -1173,9 +1173,11 @@
     result = TclpObjStat(fileName, &statBuf);
     
     if (result != 0) {
-	Tcl_AppendResult(interp, "could not read \"", 
-		Tcl_GetString(fileName), "\": ",
-		Tcl_PosixError(interp), (char *) NULL);
+	if (interp != NULL) {
+	    Tcl_AppendResult(interp, "could not read \"", 
+		    Tcl_GetString(fileName), "\": ",
+		    Tcl_PosixError(interp), (char *) NULL);
+	}
 	return TCL_ERROR;
     }
 
@@ -1225,9 +1227,11 @@
     result = TclpObjStat(fileName, &statBuf);
     
     if (result != 0) {
-	Tcl_AppendResult(interp, "could not read \"", 
-		Tcl_GetString(fileName), "\": ",
-		Tcl_PosixError(interp), (char *) NULL);
+	if (interp != NULL) {
+	    Tcl_AppendResult(interp, "could not read \"", 
+		    Tcl_GetString(fileName), "\": ",
+		    Tcl_PosixError(interp), (char *) NULL);
+	}
 	return TCL_ERROR;
     }
 
@@ -1277,9 +1281,11 @@
     result = TclpObjStat(fileName, &statBuf);
     
     if (result != 0) {
-	Tcl_AppendResult(interp, "could not read \"", 
-		Tcl_GetString(fileName), "\": ",
-		Tcl_PosixError(interp), (char *) NULL);
+	if (interp != NULL) {
+	    Tcl_AppendResult(interp, "could not read \"", 
+		    Tcl_GetString(fileName), "\": ",
+		    Tcl_PosixError(interp), (char *) NULL);
+	}
 	return TCL_ERROR;
     }
 
@@ -1331,10 +1337,12 @@
 
 	if (groupPtr == NULL) {
 	    endgrent();
-	    Tcl_AppendResult(interp, "could not set group for file \"",
-		    Tcl_GetString(fileName), "\": group \"", 
-		    string, "\" does not exist",
-		    (char *) NULL);
+	    if (interp != NULL) {
+		Tcl_AppendResult(interp, "could not set group for file \"",
+			Tcl_GetString(fileName), "\": group \"", 
+			string, "\" does not exist",
+			(char *) NULL);
+	    }
 	    return TCL_ERROR;
 	}
 	gid = groupPtr->gr_gid;
@@ -1345,9 +1353,11 @@
 
     endgrent();
     if (result != 0) {
-	Tcl_AppendResult(interp, "could not set group for file \"",
-	    Tcl_GetString(fileName), "\": ", Tcl_PosixError(interp), 
-	    (char *) NULL);
+	if (interp != NULL) {
+	    Tcl_AppendResult(interp, "could not set group for file \"",
+		Tcl_GetString(fileName), "\": ", Tcl_PosixError(interp), 
+		(char *) NULL);
+	}
 	return TCL_ERROR;
     }    
     return TCL_OK;
@@ -1393,10 +1403,12 @@
 	Tcl_DStringFree(&ds);
 
 	if (pwPtr == NULL) {
-	    Tcl_AppendResult(interp, "could not set owner for file \"",
-			     Tcl_GetString(fileName), "\": user \"", 
-			     string, "\" does not exist",
-		    (char *) NULL);
+	    if (interp != NULL) {
+		Tcl_AppendResult(interp, "could not set owner for file \"",
+				 Tcl_GetString(fileName), "\": user \"", 
+				 string, "\" does not exist",
+			(char *) NULL);
+	    }
 	    return TCL_ERROR;
 	}
 	uid = pwPtr->pw_uid;
@@ -1406,9 +1418,11 @@
     result = chown(native, (uid_t) uid, (gid_t) -1);   /* INTL: Native. */
 
     if (result != 0) {
-	Tcl_AppendResult(interp, "could not set owner for file \"", 
-			 Tcl_GetString(fileName), "\": ", 
-			 Tcl_PosixError(interp), (char *) NULL);
+	if (interp != NULL) {
+	    Tcl_AppendResult(interp, "could not set owner for file \"", 
+			     Tcl_GetString(fileName), "\": ", 
+			     Tcl_PosixError(interp), (char *) NULL);
+	}
 	return TCL_ERROR;
     }
     return TCL_OK;
@@ -1459,17 +1473,21 @@
 	 */
 	result = TclpObjStat(fileName, &buf);
 	if (result != 0) {
-	    Tcl_AppendResult(interp, "could not read \"", 
-		    Tcl_GetString(fileName), "\": ",
-		    Tcl_PosixError(interp), (char *) NULL);
+	    if (interp != NULL) {
+		Tcl_AppendResult(interp, "could not read \"", 
+				 Tcl_GetString(fileName), "\": ",
+				 Tcl_PosixError(interp), (char *) NULL);
+	    }
 	    return TCL_ERROR;
 	}
 	newMode = (mode_t) (buf.st_mode & 0x00007FFF);
 
 	if (GetModeFromPermString(NULL, modeStringPtr, &newMode) != TCL_OK) {
-	    Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
-		    "unknown permission string format \"",
-		    modeStringPtr, "\"", (char *) NULL);
+	    if (interp != NULL) {
+		Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
+			       "unknown permission string format \"",
+			       modeStringPtr, "\"", (char *) NULL);
+	    }
 	    return TCL_ERROR;
 	}
     }
@@ -1477,10 +1495,12 @@
     native = Tcl_FSGetNativePath(fileName);
     result = chmod(native, newMode);		/* INTL: Native. */
     if (result != 0) {
-	Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
-		"could not set permissions for file \"", 
-		Tcl_GetString(fileName), "\": ",
-		Tcl_PosixError(interp), (char *) NULL);
+	if (interp != NULL) {
+	    Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
+		    "could not set permissions for file \"", 
+		    Tcl_GetString(fileName), "\": ",
+		    Tcl_PosixError(interp), (char *) NULL);
+	}
 	return TCL_ERROR;
     }
     return TCL_OK;
@@ -1889,10 +1909,12 @@
     result = TclpObjStat(fileName, &statBuf);
     
     if (result != 0) {
-	Tcl_AppendResult(interp, "could not read \"", 
-		Tcl_GetString(fileName), "\": ",
-		Tcl_PosixError(interp), (char *) NULL);
-	return TCL_ERROR;
+	if (interp != NULL) {
+	    Tcl_AppendResult(interp, "could not read \"", 
+		    Tcl_GetString(fileName), "\": ",
+		    Tcl_PosixError(interp), (char *) NULL);
+	    return TCL_ERROR;
+	}
     }
 
     *attributePtrPtr = Tcl_NewBooleanObj((statBuf.st_flags & UF_IMMUTABLE) != 0);
@@ -1935,9 +1957,11 @@
     result = TclpObjStat(fileName, &statBuf);
     
     if (result != 0) {
-	Tcl_AppendResult(interp, "could not read \"", 
-		Tcl_GetString(fileName), "\": ",
-		Tcl_PosixError(interp), (char *) NULL);
+	if (interp != NULL) {
+	    Tcl_AppendResult(interp, "could not read \"", 
+		    Tcl_GetString(fileName), "\": ",
+		    Tcl_PosixError(interp), (char *) NULL);
+	}
 	return TCL_ERROR;
     }
 
@@ -1950,10 +1974,12 @@
     native = Tcl_FSGetNativePath(fileName);
     result = chflags(native, statBuf.st_flags);		/* INTL: Native. */
     if (result != 0) {
-	Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
-		"could not set flags for file \"", 
-		Tcl_GetString(fileName), "\": ",
-		Tcl_PosixError(interp), (char *) NULL);
+	if (interp != NULL) {
+	    Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
+		    "could not set flags for file \"", 
+		    Tcl_GetString(fileName), "\": ",
+		    Tcl_PosixError(interp), (char *) NULL);
+	}
 	return TCL_ERROR;
     }
     return TCL_OK;
