diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-07-04 11:01:47 +0100 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-07-04 11:01:47 +0100 |
commit | f2b2271fbe4a7acb1b026545481bf5cd6879d983 (patch) | |
tree | b8bb0211b7cfd2c0ecd43706602ee1c6c77c1e1a /Src | |
parent | a257525afc1578ff4d951e6771b2afab181ac46e (diff) | |
download | zsh-f2b2271fbe4a7acb1b026545481bf5cd6879d983.tar.gz zsh-f2b2271fbe4a7acb1b026545481bf5cd6879d983.tar.xz zsh-f2b2271fbe4a7acb1b026545481bf5cd6879d983.zip |
Turning case parsed as multiple alternatives back into text.
Also add test.
Diffstat (limited to 'Src')
-rw-r--r-- | Src/text.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Src/text.c b/Src/text.c index 3287c54ac..d63141b20 100644 --- a/Src/text.c +++ b/Src/text.c @@ -681,7 +681,7 @@ gettext2(Estate state) case WC_CASE: if (!s) { Wordcode end = state->pc + WC_CASE_SKIP(code); - wordcode nalts; + wordcode nalts, ialts; taddstr("case "); taddstr(ecgetstr(state, EC_NODUP, NULL)); @@ -702,21 +702,22 @@ gettext2(Estate state) taddchr(' '); taddstr("("); code = *state->pc++; - nalts = *state->pc++; - while (nalts--) { + nalts = ialts = *state->pc++; + while (ialts--) { taddstr(ecgetstr(state, EC_NODUP, NULL)); state->pc++; - if (nalts) + if (ialts) taddstr(" | "); } taddstr(") "); tindent++; n = tpush(code, 0); n->u._case.end = end; - n->pop = (state->pc - 2 + WC_CASE_SKIP(code) >= end); + n->pop = (state->pc - 2 - nalts + WC_CASE_SKIP(code) + >= end); } } else if (state->pc < s->u._case.end) { - wordcode nalts; + wordcode nalts, ialts; dec_tindent(); switch (WC_CASE_TYPE(code)) { case WC_CASE_OR: @@ -737,17 +738,17 @@ gettext2(Estate state) taddchr(' '); taddstr("("); code = *state->pc++; - nalts = *state->pc++; - while (nalts--) { + nalts = ialts = *state->pc++; + while (ialts--) { taddstr(ecgetstr(state, EC_NODUP, NULL)); state->pc++; - if (nalts) + if (ialts) taddstr(" | "); } taddstr(") "); tindent++; s->code = code; - s->pop = ((state->pc - 2 + WC_CASE_SKIP(code)) >= + s->pop = ((state->pc - 2 - nalts + WC_CASE_SKIP(code)) >= s->u._case.end); } else { dec_tindent(); |