diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-04-15 18:10:10 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-04-15 18:10:10 +0000 |
commit | 2a5a899a55fd2bce10efd01c75a4bec5285aa46c (patch) | |
tree | 4744bc2f1a6b86fc1b12870be94edf96fdab4879 /Src/cond.c | |
parent | 9003d99d16c46b5679da7fcf1f2a41adef495ff9 (diff) | |
download | zsh-2a5a899a55fd2bce10efd01c75a4bec5285aa46c.tar.gz zsh-2a5a899a55fd2bce10efd01c75a4bec5285aa46c.tar.xz zsh-2a5a899a55fd2bce10efd01c75a4bec5285aa46c.zip |
zsh-3.1.5-pws-4 zsh-3.1.5-pws-4
Diffstat (limited to 'Src/cond.c')
-rw-r--r-- | Src/cond.c | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/Src/cond.c b/Src/cond.c index ed91f72f3..906e81938 100644 --- a/Src/cond.c +++ b/Src/cond.c @@ -48,7 +48,8 @@ evalcond(Cond c) { Conddef cd; - if ((cd = getconddef((c->type == COND_MODI), (char *) c->left, 1))) { + if ((cd = getconddef((c->type == COND_MODI), + ((char *) c->left) + 1, 1))) { if (c->type == COND_MOD) { int l = arrlen((char **) c->right); @@ -57,10 +58,24 @@ evalcond(Cond c) return 0; } } - return cd->handler(cd, (char **) c->right); + return cd->handler((char **) c->right, cd->condid); + } + else { + char **a = (char **) c->right, *s = a[0]; + + if (s && s[0] == '-' && + (cd = getconddef(0, s + 1, 1))) { + int l = arrlen(a); + + if (l < cd->min || (cd->max >= 0 && l > cd->max)) { + zerr("unrecognized condition: `-%s'", (char *) c->left, 0); + return 0; + } + a[0] = (char *) c->left; + return cd->handler(a, cd->condid); + } else + zerr("unrecognized condition: `-%s'", (char *) c->left, 0); } - else - zerr("unrecognized condition: `-%s'", (char *) c->left, 0); return 0; } } @@ -244,3 +259,38 @@ optison(char *s) else return isset(i); } + +/**/ +char * +cond_str(char **args, int num) +{ + char *s = args[num]; + + singsub(&s); + untokenize(s); + + return s; +} + +/**/ +long +cond_val(char **args, int num) +{ + char *s = args[num]; + + singsub(&s); + untokenize(s); + + return matheval(s); +} + +/**/ +int +cond_match(char **args, int num, char *str) +{ + char *s = args[num]; + + singsub(&s); + + return matchpat(str, s); +} |