diff options
author | Peter Stephenson <pws@zsh.org> | 2015-05-18 09:56:00 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2015-05-18 09:56:00 +0100 |
commit | 52aeb9aaeb4799b760138a7c34b18ede4b47242a (patch) | |
tree | 0da193cbc61ac0000ae0bad210619276f63dccd5 /Src/text.c | |
parent | 34a1489f436d95bc2404f8e371130a469cbccebe (diff) | |
download | zsh-52aeb9aaeb4799b760138a7c34b18ede4b47242a.tar.gz zsh-52aeb9aaeb4799b760138a7c34b18ede4b47242a.tar.xz zsh-52aeb9aaeb4799b760138a7c34b18ede4b47242a.zip |
35168: Improve parsing of case patterns.
"|" is now found properly by looking for words that come from the lexical analyser, rather than hacking a pattern returned in one dollop. Update some completion functions that need extra quoting as a result. Add test for new parsing. Update version number to 5.0.8-dev-3 because of wordcode incompatibility.
Diffstat (limited to 'Src/text.c')
-rw-r--r-- | Src/text.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/Src/text.c b/Src/text.c index b58c2516d..958303c68 100644 --- a/Src/text.c +++ b/Src/text.c @@ -602,6 +602,7 @@ gettext2(Estate state) case WC_CASE: if (!s) { Wordcode end = state->pc + WC_CASE_SKIP(code); + wordcode nalts; taddstr("case "); taddstr(ecgetstr(state, EC_NODUP, NULL)); @@ -622,8 +623,13 @@ gettext2(Estate state) taddchr(' '); taddstr("("); code = *state->pc++; - taddstr(ecgetstr(state, EC_NODUP, NULL)); - state->pc++; + nalts = *state->pc++; + while (nalts--) { + taddstr(ecgetstr(state, EC_NODUP, NULL)); + state->pc++; + if (nalts) + taddstr(" | "); + } taddstr(") "); tindent++; n = tpush(code, 0); @@ -631,6 +637,7 @@ gettext2(Estate state) n->pop = (state->pc - 2 + WC_CASE_SKIP(code) >= end); } } else if (state->pc < s->u._case.end) { + wordcode nalts; dec_tindent(); switch (WC_CASE_TYPE(code)) { case WC_CASE_OR: @@ -638,11 +645,11 @@ gettext2(Estate state) break; case WC_CASE_AND: - taddstr(";&"); + taddstr(" ;&"); break; default: - taddstr(";|"); + taddstr(" ;|"); break; } if (tnewlins) @@ -651,8 +658,13 @@ gettext2(Estate state) taddchr(' '); taddstr("("); code = *state->pc++; - taddstr(ecgetstr(state, EC_NODUP, NULL)); - state->pc++; + nalts = *state->pc++; + while (nalts--) { + taddstr(ecgetstr(state, EC_NODUP, NULL)); + state->pc++; + if (nalts) + taddstr(" | "); + } taddstr(") "); tindent++; s->code = code; @@ -666,11 +678,11 @@ gettext2(Estate state) break; case WC_CASE_AND: - taddstr(";&"); + taddstr(" ;&"); break; default: - taddstr(";|"); + taddstr(" ;|"); break; } dec_tindent(); |