summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
authordkf <dkf@noemail.net>2004-10-14 15:28:35 (GMT)
committerdkf <dkf@noemail.net>2004-10-14 15:28:35 (GMT)
commitc9fbda2768fbfb12bc734ff0582b25b8876d5a9b (patch)
treeb5dba038b42ffc58fba56239e5f85fd048c2c11a /generic/tclUtil.c
parentd092aeabf3ed14423f8c1ab12829125cc179054e (diff)
downloadtcl-c9fbda2768fbfb12bc734ff0582b25b8876d5a9b.zip
tcl-c9fbda2768fbfb12bc734ff0582b25b8876d5a9b.tar.gz
tcl-c9fbda2768fbfb12bc734ff0582b25b8876d5a9b.tar.bz2
Speed up [info <thing> <simplePattern>]
FossilOrigin-Name: c82a4cd09d2b170d844d001f100c7687048d18a0
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r--generic/tclUtil.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 8dfe0d9..59872ce 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.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: tclUtil.c,v 1.36.2.4 2003/08/27 21:31:53 dgp Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.36.2.5 2004/10/14 15:28:39 dkf Exp $
*/
#include "tclInt.h"
@@ -1395,6 +1395,43 @@ Tcl_StringCaseMatch(string, pattern, nocase)
/*
*----------------------------------------------------------------------
*
+ * TclMatchIsTrivial --
+ *
+ * Test whether a particular glob pattern is a trivial pattern.
+ * (i.e. where matching is the same as equality testing).
+ *
+ * Results:
+ * A boolean indicating whether the pattern is free of all of the
+ * glob special chars.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TclMatchIsTrivial(pattern)
+ CONST char *pattern;
+{
+ CONST char *p = pattern;
+
+ while (1) {
+ switch (*p++) {
+ case '\0':
+ return 1;
+ case '*':
+ case '?':
+ case '[':
+ case '\\':
+ return 0;
+ }
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_DStringInit --
*
* Initializes a dynamic string, discarding any previous contents