diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2004-10-26 17:20:21 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2004-10-26 17:20:21 +0000 |
commit | c8e70ab5cffaffacf6d0a4e81df4fbd685378bfd (patch) | |
tree | 05c643d439176b1feee4456b07b3a2e6d5f9643a /Src | |
parent | ced347cf3afd9475e07ae3676b6d637243bdabb2 (diff) | |
download | zsh-c8e70ab5cffaffacf6d0a4e81df4fbd685378bfd.tar.gz zsh-c8e70ab5cffaffacf6d0a4e81df4fbd685378bfd.tar.xz zsh-c8e70ab5cffaffacf6d0a4e81df4fbd685378bfd.zip |
20522: must-match optimisation in parameter substitution broken
Diffstat (limited to 'Src')
-rw-r--r-- | Src/glob.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Src/glob.c b/Src/glob.c index 84ee8a751..5519e0e02 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -2206,8 +2206,20 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr) repllist = NULL; /* perform must-match test for complex closures */ - if (p->mustoff && !strstr((char *)s, (char *)p + p->mustoff)) - matched = 0; + if (p->mustoff) + { + /* + * Yuk. Probably we should rewrite this whole function to + * use an unmetafied test string. + * + * Use META_HEAPDUP because we need a terminating NULL. + */ + char *muststr = metafy((char *)p + p->mustoff, + p->patmlen, META_HEAPDUP); + + if (!strstr(s, muststr)) + matched = 0; + } /* in case we used the prog before... */ p->flags &= ~(PAT_NOTSTART|PAT_NOTEND); |