diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-10-18 09:57:00 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-10-18 09:57:00 +0000 |
commit | 910dc80a58cf3bcf91c51a72f117a46a7c9f77cf (patch) | |
tree | 35b972869c1275dc47aa6400a09fac4a60fa9c4c /Src/cond.c | |
parent | 2246999a843ba1e6cf34e41228228609e23e650a (diff) | |
download | zsh-910dc80a58cf3bcf91c51a72f117a46a7c9f77cf.tar.gz zsh-910dc80a58cf3bcf91c51a72f117a46a7c9f77cf.tar.xz zsh-910dc80a58cf3bcf91c51a72f117a46a7c9f77cf.zip |
zsh-workers/8319
Diffstat (limited to 'Src/cond.c')
-rw-r--r-- | Src/cond.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/Src/cond.c b/Src/cond.c index c0a3235be..caa675f2e 100644 --- a/Src/cond.c +++ b/Src/cond.c @@ -107,16 +107,15 @@ evalcond(Cond c) left = dupstring((char *) c->left); singsub(&left); untokenize(left); - if (c->right) { + if (c->right && c->type != COND_STREQ && c->type != COND_STRNEQ) { right = dupstring((char *) c->right); singsub(&right); - if (c->type != COND_STREQ && c->type != COND_STRNEQ) - untokenize(right); + untokenize(right); } if (tracingcond) { if (c->type < COND_MOD) { - char *rt = (char *)right; + char *rt = (char *) right; if (c->type == COND_STREQ || c->type == COND_STRNEQ) { rt = dupstring(rt); untokenize(rt); @@ -168,9 +167,29 @@ evalcond(Cond c) switch (c->type) { case COND_STREQ: - return matchpat(left, right); case COND_STRNEQ: - return !matchpat(left, right); + { + Patprog pprog = c->prog; + int test; + + if (pprog == dummy_patprog1 || pprog == dummy_patprog2) { + char *opat; + int save; + + right = opat = dupstring((char *) c->right); + singsub(&right); + save = (!strcmp(opat, right) && pprog != dummy_patprog2); + + if (!(pprog = patcompile(right, (save ? PAT_ZDUP : PAT_STATIC), + NULL))) + zerr("bad pattern: %s", right, 0); + else if (save) + c->prog = pprog; + } + test = (pprog && pattry(pprog, left)); + + return (c->type == COND_STREQ ? test : !test); + } case COND_STRLT: return strcmp(left, right) < 0; case COND_STRGTR: |