diff options
author | Oliver Kiddle <opk@zsh.org> | 2021-12-16 14:27:59 +0100 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2021-12-16 14:27:59 +0100 |
commit | 6b763233b2d7db08ed4c16400356d7deb292fe50 (patch) | |
tree | 7eb0d75d7cd355c4af8580047b6795a57471da67 /Src | |
parent | 702d773e8657d1f8ea161d65d5dfce238a67c204 (diff) | |
download | zsh-6b763233b2d7db08ed4c16400356d7deb292fe50.tar.gz zsh-6b763233b2d7db08ed4c16400356d7deb292fe50.tar.xz zsh-6b763233b2d7db08ed4c16400356d7deb292fe50.zip |
49653: fix array indexing issue introduced with 49518 due to using decimal rather than hex 20
Also avoid comparing the current word against all options when the word doesn't start with - or +.
Diffstat (limited to 'Src')
-rw-r--r-- | Src/Zle/computil.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index c49d688c8..59abb4cc4 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -1088,10 +1088,10 @@ bslashcolon(char *s) static int single_index(char pre, char opt) { - if (opt <= 20 || opt > 0x7e) + if (opt <= 0x20 || opt > 0x7e) return -1; - return opt + (pre == '-' ? -21 : 94 - 21); + return opt + (pre == '-' ? -0x21 : 94 - 0x21); } /* Parse an argument definition. */ @@ -2158,7 +2158,8 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first) /* See if it's an option. */ - if (state.opt == 2 && (state.curopt = ca_get_opt(d, line, 0, &pe)) && + if (state.opt == 2 && (*line == '-' || *line == '+') && + (state.curopt = ca_get_opt(d, line, 0, &pe)) && (state.curopt->type == CAO_OEQUAL ? (compwords[cur] || pe[-1] == '=') : (state.curopt->type == CAO_EQUAL ? @@ -2206,6 +2207,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first) state.curopt = NULL; } } else if (state.opt == 2 && d->single && + (*line == '-' || *line == '+') && ((state.curopt = ca_get_sopt(d, line, &pe, &sopts)) || (cur != compcurrent && sopts && nonempty(sopts)))) { /* Or maybe it's a single-letter option? */ |