about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@zsh.org>2016-06-21 16:12:51 +0100
committerPeter Stephenson <pws@zsh.org>2016-06-21 16:12:51 +0100
commit016929e043abb8ba778293c29081ca8e227c6e58 (patch)
treee79d08294aaf4cdb0a2090d729a5503e4f2ccb4c
parentd309d9addc114d22175f5feb0ab2e5fdf290dc02 (diff)
downloadzsh-016929e043abb8ba778293c29081ca8e227c6e58.tar.gz
zsh-016929e043abb8ba778293c29081ca8e227c6e58.tar.xz
zsh-016929e043abb8ba778293c29081ca8e227c6e58.zip
38734: fix final case clauses terminating with ;&
-rw-r--r--ChangeLog3
-rw-r--r--Src/loop.c2
-rw-r--r--Test/A01grammar.ztst8
3 files changed, 12 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index a65ba2970..fd58e7aa6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2016-06-21  Peter Stephenson  <p.stephenson@samsung.com>
 
+	* 38734: Src/loop.c, Test/A01grammar.ztst: fix final case
+	clauses terminating with ;&.
+
 	* 38692: Doc/Zsh/restricted.yo, Src/params.c: IFS can't be
 	changed in restricted mode.
 
diff --git a/Src/loop.c b/Src/loop.c
index 19d7f733e..fa7602e37 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 7eedfa6e0..394480c19 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