From 28874513024e2087054c3fcbdb08a7fead506bc8 Mon Sep 17 00:00:00 2001 From: hobbs Date: Tue, 11 Feb 2003 09:42:02 +0000 Subject: * unix/tclUnixFile.c (TclpMatchInDirectory): simplify the hidden file match check. --- unix/tclUnixFile.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index 62f9a3a..4e89ee1 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.30 2003/02/10 10:26:26 vincentdarley Exp $ + * RCS: @(#) $Id: tclUnixFile.c,v 1.31 2003/02/11 09:42:02 hobbs Exp $ */ #include "tclInt.h" @@ -283,34 +283,24 @@ TclpMatchInDirectory(interp, resultPtr, pathPtr, pattern, types) nativeDirLen = Tcl_DStringLength(&ds); /* - * Check to see if the pattern needs to compare with hidden files. + * Check to see if -type or the pattern requests hidden files. */ - - if ((pattern[0] == '.') - || ((pattern[0] == '\\') && (pattern[1] == '.'))) { - matchHidden = 1; - } else { - matchHidden = 0; - } + matchHidden = ((types && (types->perm & TCL_GLOB_PERM_HIDDEN)) || + ((pattern[0] == '.') + || ((pattern[0] == '\\') && (pattern[1] == '.')))); while ((entryPtr = TclOSreaddir(d)) != NULL) { /* INTL: Native. */ Tcl_DString utfDs; CONST char *utfname; - - if (types != NULL && (types->perm & TCL_GLOB_PERM_HIDDEN)) { - /* - * We explicitly asked for hidden files, so turn around - * and ignore any file which isn't hidden. - */ - if (*entryPtr->d_name != '.') { - continue; - } - } else if (!matchHidden && (*entryPtr->d_name == '.')) { - /* - * Don't match names starting with "." unless the "." is - * present in the pattern. - */ - continue; + + /* + * Skip this file if it doesn't agree with the hidden + * parameters requested by the user (via -type or pattern). + */ + if (*entryPtr->d_name == '.') { + if (!matchHidden) continue; + } else { + if (matchHidden) continue; } /* -- cgit v0.12