Skip to content

Commit

Permalink
49653: fix array indexing issue introduced with 49518 due to using de…
Browse files Browse the repository at this point in the history
…cimal rather than hex 20

Also avoid comparing the current word against all options when the word
doesn't start with - or +.
  • Loading branch information
Oliver Kiddle committed Dec 16, 2021
1 parent 702d773 commit 6b76323
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2021-12-16 Oliver Kiddle <opk@zsh.org>

* 49653: Src/Zle/computil.c: fix array indexing issue introduced
with 49518 due to using decimal rather than hex 20

* 49648 based on github #80 (Vincent Bernat):
Completion/Unix/Command/_find, Completion/Zsh/Type/_globquals:
invert before/since for date glob qualifiers completion
Expand Down
8 changes: 5 additions & 3 deletions Src/Zle/computil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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 ?
Expand Down Expand Up @@ -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? */
Expand Down

0 comments on commit 6b76323

Please sign in to comment.