summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-14 15:05:59 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-14 15:05:59 (GMT)
commit97449587f00016cab8acc385844a1d82f26332c6 (patch)
treef89998d33d66eb6a7f9fe5e3f2d931293830c8a9 /generic/tclUtil.c
parent98a60867761d8d1991cee931a2c8c21423e5dcd1 (diff)
downloadtcl-97449587f00016cab8acc385844a1d82f26332c6.zip
tcl-97449587f00016cab8acc385844a1d82f26332c6.tar.gz
tcl-97449587f00016cab8acc385844a1d82f26332c6.tar.bz2
Speed up [info <thing> <simplePattern>]
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 1a4b841..068a20b 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.47 2004/10/06 15:59:25 dgp Exp $
+ * RCS: @(#) $Id: tclUtil.c,v 1.48 2004/10/14 15:06:03 dkf Exp $
*/
#include "tclInt.h"
@@ -1416,6 +1416,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