From 9dffb7863ba4b0e760ce19215def938abecbcfea Mon Sep 17 00:00:00 2001 From: vincentdarley Date: Wed, 31 Aug 2005 15:12:18 +0000 Subject: allow NULL interp in Tcl_FSMatchInDirectory --- ChangeLog | 9 +++++++++ doc/FileSystem.3 | 14 ++++++++------ generic/tclIOUtil.c | 5 +++-- unix/tclUnixFile.c | 12 +++++++----- win/tclWinFile.c | 12 +++++++----- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc28ed4..84a3067 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-09-31 Vince Darley + + * doc/FileSystem.3: + * unix/tclUnixFile.c: + * windows/tclWinFile.c: clarify that Tcl_FSMatchInDirectory may + be called with a NULL interpreter, and fix the code so this is + allowed. Tcl's core itself (tclEncoding.c:FillEncodingFileMap()) + calls this with a NULL interpreter. + 2005-08-29 Andreas Kupries * library/tm.tcl (::tcl::tm::roots): Accepted Don Porter's patch diff --git a/doc/FileSystem.3 b/doc/FileSystem.3 index cdac36e..3aee462 100644 --- a/doc/FileSystem.3 +++ b/doc/FileSystem.3 @@ -4,7 +4,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: FileSystem.3,v 1.54 2005/05/10 18:33:55 kennykb Exp $ +'\" RCS: @(#) $Id: FileSystem.3,v 1.55 2005/08/31 15:12:18 vincentdarley Exp $ '\" .so man.macros .TH Filesystem 3 8.4 Tcl "Tcl Library Procedures" @@ -376,8 +376,9 @@ directory for all files which match a given pattern. The appropriate function for the filesystem to which \fIpathPtr\fR belongs will be called. .PP The return value is a standard Tcl result indicating whether an error -occurred in globbing. Error messages are placed in interp, but good -results are placed in the resultPtr given. +occurred in globbing. Error messages are placed in interp (unless +interp is NULL, which is allowed), but good results are placed in the +resultPtr given. .PP Note that the \fBglob\fR code implements recursive patterns internally, so this function will only ever be passed simple patterns, which can be @@ -1095,9 +1096,10 @@ not, so code should be flexible to both possibilities. .PP The return value is a standard Tcl result indicating whether an error occurred in the matching process. Error messages are placed in -\fIinterp\fR; on a \fBTCL_OK\fR result, results should be added to the -\fIresultPtr\fR object given (which can be assumed to be a valid -unshared Tcl list). The matches added +\fIinterp\fR, unless \fIinterp\fR in NULL in which case no error +message need be generated; on a \fBTCL_OK\fR result, results should be +added to the \fIresultPtr\fR object given (which can be assumed to be a +valid unshared Tcl list). The matches added to \fIresultPtr\fR should include any path prefix given in \fIpathPtr\fR (this usually means they will be absolute path specifications). Note that if no matches are found, that simply leads to an empty diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 43b8b31..b540f90 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -17,7 +17,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOUtil.c,v 1.121 2005/07/17 22:04:50 dkf Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.122 2005/08/31 15:12:18 vincentdarley Exp $ */ #include "tclInt.h" @@ -1045,7 +1045,8 @@ Tcl_FSUnregister(fsPtr) int Tcl_FSMatchInDirectory(interp, resultPtr, pathPtr, pattern, types) - Tcl_Interp *interp; /* Interpreter to receive error messages. */ + Tcl_Interp *interp; /* Interpreter to receive error + * messages, but may be NULL. */ Tcl_Obj *resultPtr; /* List object to receive results. */ Tcl_Obj *pathPtr; /* Contains path to directory to search. */ CONST char *pattern; /* Pattern to match against. */ diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index b26691d..39ab6bf 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixFile.c,v 1.45 2005/07/20 23:16:00 dkf Exp $ + * RCS: @(#) $Id: tclUnixFile.c,v 1.46 2005/08/31 15:12:18 vincentdarley Exp $ */ #include "tclInt.h" @@ -288,10 +288,12 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types) d = opendir(native); /* INTL: Native. */ if (d == NULL) { Tcl_DStringFree(&ds); - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "couldn't read directory \"", - Tcl_DStringValue(&dsOrig), "\": ", - Tcl_PosixError(interp), (char *) NULL); + if (interp != NULL) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "couldn't read directory \"", + Tcl_DStringValue(&dsOrig), "\": ", + Tcl_PosixError(interp), (char *) NULL); + } Tcl_DStringFree(&dsOrig); Tcl_DecrRefCount(fileNamePtr); return TCL_ERROR; diff --git a/win/tclWinFile.c b/win/tclWinFile.c index dc6d5a0..aeae4bc 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFile.c,v 1.76 2005/07/24 22:56:47 dkf Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.77 2005/08/31 15:12:18 vincentdarley Exp $ */ //#define _WIN32_WINNT 0x0500 @@ -1018,10 +1018,12 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types) } TclWinConvertError(err); - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "couldn't read directory \"", - Tcl_DStringValue(&dsOrig), "\": ", - Tcl_PosixError(interp), (char *) NULL); + if (interp != NULL) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "couldn't read directory \"", + Tcl_DStringValue(&dsOrig), "\": ", + Tcl_PosixError(interp), (char *) NULL); + } Tcl_DStringFree(&dsOrig); return TCL_ERROR; } -- cgit v0.12