summaryrefslogtreecommitdiff
path: root/Src/pattern.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-10-22 15:36:35 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-10-22 15:36:35 +0000
commitfeca88ede6dec816878832f2129fe85b211770e4 (patch)
tree7679a3c1425af4829b539f58b99daadbdd6f5207 /Src/pattern.c
parent658f46a8094663e4a1d3dfbf37a951cbd9e1a345 (diff)
downloadzsh-feca88ede6dec816878832f2129fe85b211770e4.tar.gz
zsh-feca88ede6dec816878832f2129fe85b211770e4.zip
20513: fix tests of zero-length patterns
trivial optimisation in jobs.c (unposted)
Diffstat (limited to 'Src/pattern.c')
-rw-r--r--Src/pattern.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/Src/pattern.c b/Src/pattern.c
index 04452187d..528c48d5e 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -399,7 +399,7 @@ patcompile(char *exp, int inflags, char **endexp)
patendstr++;
patendseglen--;
patendstrlen--;
- remnulargs(exp);
+ remnulargs(patparse);
patglobflags = 0;
}
/*
@@ -419,10 +419,20 @@ patcompile(char *exp, int inflags, char **endexp)
|| (!(patglobflags & ~GF_IGNCASE) && (patflags & PAT_FILE))
#endif
)
+ {
+ /*
+ * Waah! I wish I understood this.
+ * Empty metafied strings have an initial Nularg.
+ * This never corresponds to a real character in
+ * a glob pattern or string, so skip it.
+ */
+ if (*exp == Nularg)
+ exp++;
for (strp = exp; *strp &&
(!(patflags & PAT_FILE) || *strp != '/') && !itok(*strp);
strp++)
;
+ }
if (!strp || (*strp && *strp != '/')) {
/* No, do normal compilation. */
strp = NULL;
@@ -1010,6 +1020,9 @@ patcomppiece(int *flagp)
/* Get length of string without metafication. */
nmeta = 0;
+ /* inherited from domatch, but why, exactly? */
+ if (*str0 == Nularg)
+ str0++;
for (ptr = str0; ptr < patparse; ptr++) {
if (*ptr == Meta) {
nmeta++;