diff options
Diffstat (limited to 'Src/Modules/zutil.c')
-rw-r--r-- | Src/Modules/zutil.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index 376cd8402..d95c0c254 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -472,7 +472,7 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) Patprog prog; char *pat; - if (arrlen(args) < 2) { + if (arrlen_lt(args, 2)) { zwarnnam(nam, "not enough arguments"); return 1; } @@ -491,7 +491,7 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) Style s; char *context, *stylename; - switch (arrlen(args)) { + switch (arrlen_ge(args, 3) ? 3 : arrlen(args)) { case 2: context = args[0]; stylename = args[1]; @@ -1745,13 +1745,15 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) for (p = o; *p; p++) { if (*p == '\\' && p[1]) p++; - else if (*p == '+') { - f |= ZOF_MULT; - *p = '\0'; - p++; - break; - } else if (*p == ':' || *p == '=') - break; + else if (p > o) { /* At least one character of option name */ + if (*p == '+') { + f |= ZOF_MULT; + *p = '\0'; + p++; + break; + } else if (*p == ':' || *p == '=') + break; + } } if (*p == ':') { f |= ZOF_ARG; @@ -1789,6 +1791,7 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) p++; *n++ = *p; } + *n = '\0'; if (get_opt_desc(o)) { zwarnnam(nam, "option defined more than once: %s", o); return 1; @@ -1833,7 +1836,8 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) if (o[1]) { add_opt_val(d, o + 1); break; - } else if (!(d->flags & ZOF_OPT)) { + } else if (!(d->flags & ZOF_OPT) || + (pp[1] && pp[1][0] != '-')) { if (!pp[1]) { zwarnnam(nam, "missing argument for option: %s", d->name); @@ -1859,7 +1863,8 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) if (*e) add_opt_val(d, e); - else if (!(d->flags & ZOF_OPT)) { + else if (!(d->flags & ZOF_OPT) || + (pp[1] && pp[1][0] != '-')) { if (!pp[1]) { zwarnnam(nam, "missing argument for option: %s", d->name); @@ -1990,7 +1995,7 @@ enables_(Module m, int **enables) /**/ int -boot_(Module m) +boot_(UNUSED(Module m)) { return 0; } |