diff options
Diffstat (limited to 'lib/glob/gmisc.c')
-rw-r--r-- | lib/glob/gmisc.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/glob/gmisc.c b/lib/glob/gmisc.c index 4bd37f6..96b1bc0 100644 --- a/lib/glob/gmisc.c +++ b/lib/glob/gmisc.c @@ -42,6 +42,8 @@ #define WLPAREN L'(' #define WRPAREN L')' +extern char *glob_patscan __P((char *, char *, int)); + /* Return 1 of the first character of WSTRING could match the first character of pattern WPAT. Wide character version. */ int @@ -375,3 +377,34 @@ bad_bracket: return matlen; } + +/* Skip characters in PAT and return the final occurrence of DIRSEP. This + is only called when extended_glob is set, so we have to skip over extglob + patterns x(...) */ +char * +glob_dirscan (pat, dirsep) + char *pat; + int dirsep; +{ + char *p, *d, *pe, *se; + + d = pe = se = 0; + for (p = pat; p && *p; p++) + { + if (extglob_pattern_p (p)) + { + if (se == 0) + se = p + strlen (p) - 1; + pe = glob_patscan (p + 2, se, 0); + if (pe == 0) + continue; + else if (*pe == 0) + break; + p = pe - 1; /* will do increment above */ + continue; + } + if (*p == dirsep) + d = p; + } + return d; +} |