summaryrefslogtreecommitdiff
path: root/glob.c
diff options
context:
space:
mode:
authortjg <tjg>2000-04-19 14:27:44 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:17 +0100
commitf5cf8df384be0b52cbf08015d77580d8f44a77d6 (patch)
tree62ee4c57d6623f1e4b29e9e3d43f50ecb2667116 /glob.c
parent643d8f677a0554e323078b4d75171010dc5a612f (diff)
2000-04-19
Bug: `~ () '*'' dumped core.
Diffstat (limited to 'glob.c')
-rw-r--r--glob.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/glob.c b/glob.c
index cd62d65..ac26203 100644
--- a/glob.c
+++ b/glob.c
@@ -34,23 +34,13 @@ static List *sort(List *);
extern bool lmatch(List *s, List *p) {
List *q;
- int i;
- bool okay;
if (s == NULL) {
if (p == NULL) /* null matches null */
return TRUE;
- for (; p != NULL; p = p->n) { /* one or more stars match null */
- if (*p->w != '\0') { /* the null string is a special case; it does *not* match () */
- okay = TRUE;
- for (i = 0; p->w[i] != '\0'; i++)
- if (p->w[i] != '*' || p->m[i] != 1) {
- okay = FALSE;
- break;
- }
- if (okay)
- return TRUE;
- }
- }
+ for (; p != NULL; p = p->n) /* one or more stars match null */
+ if (strspn(p->w, "*") == strlen(p->w) &&
+ p->m != NULL && strlen(p->m) == strlen(p->w))
+ return TRUE;
return FALSE;
}
for (; s != NULL; s = s->n)