diff options
author | Peter Stephenson <pws@zsh.org> | 2015-06-18 14:54:41 +0100 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2015-06-19 09:50:29 +0100 |
commit | a29746ee48c84b40add764f3cbd62d995179f72a (patch) | |
tree | 9630693c7add01f6fbb6dd893c0bc233e824d169 /Src/text.c | |
parent | 98687fa1dec803f041cbb5417c146d8aa5129b53 (diff) | |
download | zsh-a29746ee48c84b40add764f3cbd62d995179f72a.tar.gz zsh-a29746ee48c84b40add764f3cbd62d995179f72a.tar.xz zsh-a29746ee48c84b40add764f3cbd62d995179f72a.zip |
First compiling attempt at typeset array handling.
Completely untested and undebugged.
Diffstat (limited to 'Src/text.c')
-rw-r--r-- | Src/text.c | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/Src/text.c b/Src/text.c index 850879699..a72ab33e6 100644 --- a/Src/text.c +++ b/Src/text.c @@ -155,6 +155,46 @@ taddlist(Estate state, int num) } } +/* add an assignment */ + +static void +taddassign(wordcode code, Estate state, int typeset) +{ + /* name */ + taddstr(ecgetstr(state, EC_NODUP, NULL)); + /* value... maybe */ + if (WC_ASSIGN_TYPE2(code) == WC_ASSIGN_INC) { + if (typeset) { + /* dummy assignment --- just var name */ + (void)ecgetstr(state, EC_NODUP, NULL); + taddchr(' '); + return; + } + taddchr('+'); + } + taddchr('='); + if (WC_ASSIGN_TYPE(code) == WC_ASSIGN_ARRAY) { + taddchr('('); + taddlist(state, WC_ASSIGN_NUM(code)); + taddstr(") "); + } else { + taddstr(ecgetstr(state, EC_NODUP, NULL)); + taddchr(' '); + } +} + +/* add a number of assignments from typeset */ + +/**/ +static void +taddassignlist(Estate state, wordcode count) +{ + while (count--) { + wordcode code = *state->pc++; + taddassign(code, state, 1); + } +} + /* add a newline, or something equivalent, to the text buffer */ /**/ @@ -439,22 +479,17 @@ gettext2(Estate state) } break; case WC_ASSIGN: - taddstr(ecgetstr(state, EC_NODUP, NULL)); - if (WC_ASSIGN_TYPE2(code) == WC_ASSIGN_INC) taddchr('+'); - taddchr('='); - if (WC_ASSIGN_TYPE(code) == WC_ASSIGN_ARRAY) { - taddchr('('); - taddlist(state, WC_ASSIGN_NUM(code)); - taddstr(") "); - } else { - taddstr(ecgetstr(state, EC_NODUP, NULL)); - taddchr(' '); - } + taddassign(code, state, 0); break; case WC_SIMPLE: taddlist(state, WC_SIMPLE_ARGC(code)); stack = 1; break; + case WC_TYPESET: + taddlist(state, WC_TYPESET_ARGC(code)); + taddassignlist(state, *state->pc++); + stack = 1; + break; case WC_SUBSH: if (!s) { taddstr("("); |