summaryrefslogtreecommitdiffstats
path: root/bin/sh/parser.c
diff options
context:
space:
mode:
authorsef <sef@FreeBSD.org>1994-09-14 17:41:32 +0000
committersef <sef@FreeBSD.org>1994-09-14 17:41:32 +0000
commit600b25e2d39956cedfa65d55f69f43e84bb0b645 (patch)
tree2f0e587e2ea02d7e37e3929c9d1b5a97026c4ba1 /bin/sh/parser.c
parent9089c1585a625445fdd282ecc542aa6b5099d0fd (diff)
downloadFreeBSD-src-600b25e2d39956cedfa65d55f69f43e84bb0b645.zip
FreeBSD-src-600b25e2d39956cedfa65d55f69f43e84bb0b645.tar.gz
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
Diffstat (limited to 'bin/sh/parser.c')
-rw-r--r--bin/sh/parser.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index 898349f..30cc92d 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:
OpenPOWER on IntegriCloud