Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: case pattern parsing



On Tue, 21 Jun 2016 13:22:09 +0200
Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
> I noticed a bug with case statements which git bisect tracks to this
> change (workers/35168 or 52aeb9aa). It occurs with a fall-through at the
> end of the case statement:
> 
>   case whatever in
>     *) ;&
>   esac

diff --git a/Src/loop.c b/Src/loop.c
index 19d7f73..fa7602e 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -660,7 +660,7 @@ execcase(Estate state, int do_exec)
 	    execlist(state, 1, ((WC_CASE_TYPE(code) == WC_CASE_OR) &&
 				do_exec));
 	    while (!retflag && wc_code(code) == WC_CASE &&
-		   WC_CASE_TYPE(code) == WC_CASE_AND) {
+		   WC_CASE_TYPE(code) == WC_CASE_AND && state->pc < end) {
 		state->pc = next;
 		code = *state->pc++;
 		next = state->pc + WC_CASE_SKIP(code);
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 7eedfa6..394480c 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -283,6 +283,14 @@
 >2
 >3
 
+  case whatever in
+  (*) print yeah, right ;&
+  esac
+  print but well
+0:'case', redundant final ";&"
+>yeah, right
+>but well
+
 ## Select now reads from stdin if the shell is not interactive.
 ## Its own output goes to stderr.
   (COLUMNS=80 LINES=3



Messages sorted by: Reverse Date, Date, Thread, Author