* PATCH: (#?) glob with empty path segment
@ 1999-04-13 12:12 Peter Stephenson
0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 1999-04-13 12:12 UTC (permalink / raw)
To: Zsh hackers list
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 <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1999-04-13 12:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-13 12:12 PATCH: (#?) glob with empty path segment Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).