diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2016-12-04 04:32:03 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2016-12-04 04:32:03 +0100 |
commit | 3e439c3863f14c82f70666804c8570a13b3732e6 (patch) | |
tree | 07036c43e0f3f9242bb6dd42cd2a849ec8ea8aca /Src/parse.c | |
parent | 2aedc4b88fd0e87b89583983951b04b96f48efd3 (diff) | |
parent | 7b7e84f0815ed22a0ee348a217776529035dccf3 (diff) | |
download | zsh-3e439c3863f14c82f70666804c8570a13b3732e6.tar.gz zsh-3e439c3863f14c82f70666804c8570a13b3732e6.zip |
Merge tag 'zsh-5.2-test-1' into debian
Diffstat (limited to 'Src/parse.c')
-rw-r--r-- | Src/parse.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/Src/parse.c b/Src/parse.c index 4829e3a6d..50a0d5f9f 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -63,6 +63,12 @@ int isnewlin; /**/ int infor; +/* != 0 if we are after a repeat keyword; if it's nonzero it's a 1-based index + * of the current token from the last-seen command position */ + +/**/ +int inrepeat_; /* trailing underscore because of name clash with Zle/zle_vi.c */ + /* != 0 if parsing arguments of typeset etc. */ /**/ @@ -271,6 +277,7 @@ parse_context_save(struct parse_stack *ps, int toplevel) ps->incasepat = incasepat; ps->isnewlin = isnewlin; ps->infor = infor; + ps->inrepeat_ = inrepeat_; ps->intypeset = intypeset; ps->hdocs = hdocs; @@ -302,9 +309,9 @@ parse_context_restore(const struct parse_stack *ps, int toplevel) incond = ps->incond; inredir = ps->inredir; incasepat = ps->incasepat; - incasepat = ps->incasepat; isnewlin = ps->isnewlin; infor = ps->infor; + inrepeat_ = ps->inrepeat_; intypeset = ps->intypeset; hdocs = ps->hdocs; @@ -447,6 +454,7 @@ init_parse_status(void) * using the lexical analyser for strings as well as here. */ incasepat = incond = inredir = infor = intypeset = 0; + inrepeat_ = 0; incmdpos = 1; } @@ -586,7 +594,7 @@ par_event(int endtok) if (tok == ENDINPUT) return 0; if (tok == endtok) - return 0; + return 1; p = ecadd(0); @@ -709,7 +717,7 @@ set_sublist_code(int p, int type, int flags, int skip, int cmplx) */ /**/ -static int +static void par_list(int *cmplx) { int p, lp = -1, c; @@ -738,19 +746,15 @@ par_list(int *cmplx) goto rec; } else set_list_code(p, (Z_SYNC | Z_END), c); - return 1; } else { ecused--; - if (lp >= 0) { + if (lp >= 0) ecbuf[lp] |= wc_bdata(Z_END); - return 1; - } - return 0; } } /**/ -static int +static void par_list1(int *cmplx) { int p = ecadd(0), c = 0; @@ -758,11 +762,8 @@ par_list1(int *cmplx) if (par_sublist(&c)) { set_list_code(p, (Z_SYNC | Z_END), c); *cmplx |= c; - return 1; - } else { + } else ecused--; - return 0; - } } /* @@ -1404,7 +1405,7 @@ par_if(int *cmplx) } } cmdpop(); - if (xtok == ELSE) { + if (xtok == ELSE || tok == ELSE) { pp = ecadd(0); cmdpush(CS_ELSE); while (tok == SEPER) @@ -1482,6 +1483,7 @@ par_while(int *cmplx) static void par_repeat(int *cmplx) { + /* ### what to do about inrepeat_ here? */ int oecused = ecused, p; p = ecadd(0); @@ -2383,7 +2385,7 @@ par_cond_2(void) s1 = tokstr; dble = (s1 && *s1 == '-' && (!n_testargs - || strspn(s1+1, "abcdefghknoprstuwxzLONGS") == 1) + || strspn(s1+1, "abcdefghknoprstuvwxzLONGS") == 1) && !s1[2]); if (tok != STRING) { /* Check first argument for [[ STRING ]] re-interpretation */ @@ -2462,7 +2464,7 @@ par_cond_double(char *a, char *b) { if (a[0] != '-' || !a[1]) COND_ERROR("parse error: condition expected: %s", a); - else if (!a[2] && strspn(a+1, "abcdefgknoprstuwxzhLONGS") == 1) { + else if (!a[2] && strspn(a+1, "abcdefgknoprstuvwxzhLONGS") == 1) { ecadd(WCB_COND(a[1], 0)); ecstr(b); } else { @@ -2495,12 +2497,17 @@ par_cond_triple(char *a, char *b, char *c) { int t0; - if ((b[0] == Equals || b[0] == '=') && - (!b[1] || ((b[1] == Equals || b[1] == '=') && !b[2]))) { + if ((b[0] == Equals || b[0] == '=') && !b[1]) { ecadd(WCB_COND(COND_STREQ, 0)); ecstr(a); ecstr(c); ecadd(ecnpats++); + } else if ((b[0] == Equals || b[0] == '=') && + (b[1] == Equals || b[1] == '=') && !b[2]) { + ecadd(WCB_COND(COND_STRDEQ, 0)); + ecstr(a); + ecstr(c); + ecadd(ecnpats++); } else if (b[0] == '!' && (b[1] == Equals || b[1] == '=') && !b[2]) { ecadd(WCB_COND(COND_STRNEQ, 0)); ecstr(a); |