diff options
author | jilles <jilles@FreeBSD.org> | 2011-06-17 13:03:49 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-06-17 13:03:49 +0000 |
commit | c7a72567a8474dcecd93215073976b04171d1144 (patch) | |
tree | d74a77976194c0d5d68bbf18c002a166b97300a5 /bin/sh/parser.c | |
parent | f405f6d6f8e62f9714eb668d35001c794646022b (diff) | |
download | FreeBSD-src-c7a72567a8474dcecd93215073976b04171d1144.zip FreeBSD-src-c7a72567a8474dcecd93215073976b04171d1144.tar.gz |
sh: Add case statement fallthrough (with ';&' instead of ';;').
Replacing ;; with the new control operator ;& will cause the next list to be
executed as well without checking its pattern, continuing until a list ends
with ;; or until the end of the case statement. This is like omitting
"break" in a C "switch" statement.
The sequence ;& was formerly invalid.
This feature is proposed for the next POSIX issue in Austin Group issue
#449.
Diffstat (limited to 'bin/sh/parser.c')
-rw-r--r-- | bin/sh/parser.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 2fea1ec..61be512 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -542,10 +542,13 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); checkkwd = CHKNL | CHKKWD | CHKALIAS; if ((t = readtoken()) != TESAC) { - if (t != TENDCASE) - synexpect(TENDCASE); + if (t == TENDCASE) + ; + else if (t == TFALLTHRU) + cp->type = NCLISTFALLTHRU; else - checkkwd = CHKNL | CHKKWD, readtoken(); + synexpect(TENDCASE); + checkkwd = CHKNL | CHKKWD, readtoken(); } cpp = &cp->nclist.next; } @@ -931,8 +934,11 @@ xxreadtoken(void) pungetc(); RETURN(TPIPE); case ';': - if (pgetc() == ';') + c = pgetc(); + if (c == ';') RETURN(TENDCASE); + else if (c == '&') + RETURN(TFALLTHRU); pungetc(); RETURN(TSEMI); case '(': |