From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12871 invoked from network); 13 Apr 1999 12:36:34 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Apr 1999 12:36:34 -0000 Received: (qmail 15122 invoked by alias); 13 Apr 1999 12:36:24 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6018 Received: (qmail 15115 invoked from network); 13 Apr 1999 12:36:22 -0000 Message-Id: <9904131212.AA32642@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: (#?) glob with empty path segment Date: Tue, 13 Apr 1999 14:12:05 +0200 From: Peter Stephenson This should fix the problem that things like /lib/(#l)l*/ didn't work. It was trying to match the empty path segment at the end by a pattern match. --- Src/glob.c.cstr Wed Mar 24 10:20:10 1999 +++ Src/glob.c Tue Apr 13 14:06:14 1999 @@ -397,6 +397,7 @@ int pbcwdsav = pathbufcwd; int errssofar = errsfound; struct dirsav ds; + char *str; ds.ino = ds.dev = 0; ds.dirname = NULL; @@ -412,17 +413,18 @@ scanner(q->next); } c = q->comp; + str = c->str; /* Now the actual matching for the current path section. */ - if (!(c->next || c->left) && !haswilds(c->str) + if (!(c->next || c->left) && !haswilds(str) && (!((c->stat & (C_LCMATCHUC|C_IGNCASE)) || c->errsmax) - || !strcmp(".", c->str) || !strcmp("..", c->str))) { + || !*str || !strcmp(".", str) || !strcmp("..", str))) { /* * We always need to match . and .. explicitly, even if we're * checking other strings for case-insensitive matches. * * It's a straight string to the end of the path section. */ - int l = strlen(c->str); + int l = strlen(str); if (l + !l + pathpos - pathbufcwd >= PATH_MAX) { int err; @@ -442,14 +444,14 @@ /* Not the last path section. Just add it to the path. */ int oppos = pathpos; - if (!errflag && !(q->closure && !strcmp(c->str, "."))) { - addpath(c->str); + if (!errflag && !(q->closure && !strcmp(str, "."))) { + addpath(str); if (!closure || statfullpath("", NULL, 1)) scanner((q->closure) ? q : q->next); pathbuf[pathpos = oppos] = '\0'; } } else - insert(c->str, 0); + insert(str, 0); } else { /* Do pattern matching on current path section. */ char *fn = pathbuf[pathbufcwd] ? unmeta(pathbuf + pathbufcwd) : "."; -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy