diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-04-15 18:20:19 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-04-15 18:20:19 +0000 |
commit | 04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8 (patch) | |
tree | 2215f99f95d55660fc939a029bf965c454d080b5 /Src/glob.c | |
parent | 7a0415cfd70a02b2280d27556c6c54cef1c86e1a (diff) | |
download | zsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.tar.gz zsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.tar.xz zsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.zip |
zsh-3.1.5-pws-12 zsh-3.1.5-pws-12
Diffstat (limited to 'Src/glob.c')
-rw-r--r-- | Src/glob.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/Src/glob.c b/Src/glob.c index 738753377..56e0ac133 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -2304,26 +2304,25 @@ getmatch(char **sp, char *pat, int fl, int n, char *replstr) case SUB_LONG: /* * Largest/smallest possible match at head of string. - * First get the longest match. + * First get the longest match... */ if (dolongestmatch(s, c, 0)) { char *mpos = pptr; - while (!(fl & SUB_LONG) && pptr > s) { - /* - * If we want the shortest, keep backing up to the - * previous character and find the longest up to there. - * That way we can usually reach the shortest in only - * a few attempts. - */ - t = (pptr > s + 1 && pptr[-2] == Meta) ? pptr - 2 : pptr -1; + if (!(fl & SUB_LONG)) { + /* + * ... now we know whether it's worth looking for the + * shortest, which we do by brute force. + */ + for (t = s; t < mpos; METAINC(t)) { sav = *t; *t = '\0'; - if (!dolongestmatch(s, c, 0)) { - *t = sav; - break; + if (dolongestmatch(s, c, 0)) { + mpos = pptr; + *t = sav; + break; } - mpos = pptr; *t = sav; + } } *sp = get_match_ret(*sp, 0, mpos-s, fl, replstr); return 1; |