From 650488feaa2ab25432876da40e7df0516e18a611 Mon Sep 17 00:00:00 2001 From: Sean Eric Fagan Date: Wed, 14 Sep 1994 17:41:32 +0000 Subject: [PATCH] With '!' being made into a keyword (yech!), case cases didn't work properly. This should fix it (passed my test cases). Originally discovered with perl's Configure (well, in FreeBSD, I don't know how the NetBSD folks discovered it). Reviewed by: sef Submitted by: jtc@cygnus.com Obtained from: NetBSD --- bin/sh/parser.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 898349f38441..30cc92d330ef 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -392,7 +392,8 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); if (lasttoken != TWORD || ! equal(wordtext, "in")) synerror("expecting \"in\""); cpp = &n1->ncase.cases; - while (checkkwd = 2, readtoken() == TWORD) { + checkkwd = 2, readtoken(); + do { *cpp = cp = (union node *)stalloc(sizeof (struct nclist)); cp->type = NCLIST; app = &cp->nclist.pattern; @@ -401,25 +402,26 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); ap->type = NARG; ap->narg.text = wordtext; ap->narg.backquote = backquotelist; - if (readtoken() != TPIPE) + if (checkkwd = 2, readtoken() != TPIPE) break; app = &ap->narg.next; - if (readtoken() != TWORD) - synexpect(TWORD); + readtoken(); } ap->narg.next = NULL; if (lasttoken != TRP) synexpect(TRP); cp->nclist.body = list(0); - if ((t = readtoken()) == TESAC) - tokpushback++; - else if (t != TENDCASE) - synexpect(TENDCASE); + + checkkwd = 2; + if ((t = readtoken()) != TESAC) { + if (t != TENDCASE) + synexpect(TENDCASE); + else + checkkwd = 2, readtoken(); + } cpp = &cp->nclist.next; - } + } while(lasttoken != TESAC); *cpp = NULL; - if (lasttoken != TESAC) - synexpect(TESAC); checkkwd = 1; break; case TLP: