Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: For loop bug
- X-seq: zsh-workers 17673
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx (Zsh hackers list)
- Subject: Re: For loop bug
- Date: Sat, 14 Sep 2002 15:39:20 +0100
- In-reply-to: "Peter Stephenson"'s message of "Sat, 14 Sep 2002 00:31:51 BST." <20020913233156.324A31C0E9@xxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Peter Stephenson wrote:
[Hey, Mozilla handles RFC822 downloads from the mailing list archive as
a special type which saves as a regular mailbox! Cool! Don't bother
telling me you've known for years.]
> Philippe Troin wrote:
> > Or did I miss something?
>
> Non, hélas.
I did, however: after fifteen hours, it finally occurred to me that
where there's an or there's an and. This replaces the previous patch
and fixes the equivalent bug, too. (I've subtly changed a couple of
comments owing to pure pedantry.) All tests still pass. I'll still
wait and see if Sven has any comment.
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.45
diff -u -r1.45 exec.c
--- Src/exec.c 5 Aug 2002 12:35:59 -0000 1.45
+++ Src/exec.c 14 Sep 2002 14:35:00 -0000
@@ -851,8 +851,15 @@
* for this sublist. */
donetrap = 1;
goto sublist_done;
- } else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END)
+ } else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END) {
donetrap = 1;
+ /*
+ * Treat this in the same way as if we reached
+ * the end of the sublist normally.
+ */
+ state->pc = next;
+ goto sublist_done;
+ }
}
cmdpush(CS_CMDAND);
break;
@@ -877,8 +884,15 @@
* for this sublist. */
donetrap = 1;
goto sublist_done;
- } else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END)
+ } else if (WC_SUBLIST_TYPE(code) == WC_SUBLIST_END) {
donetrap = 1;
+ /*
+ * Treat this in the same way as if we reached
+ * the end of the sublist normally.
+ */
+ state->pc = next;
+ goto sublist_done;
+ }
}
cmdpush(CS_CMDOR);
break;
Index: Test/A01grammar.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/A01grammar.ztst,v
retrieving revision 1.5
diff -u -r1.5 A01grammar.ztst
--- Test/A01grammar.ztst 22 Aug 2001 15:59:27 -0000 1.5
+++ Test/A01grammar.ztst 14 Sep 2002 14:35:00 -0000
@@ -319,3 +319,21 @@
done < /dev/null | { read name; print done }
0:Bug regression: `while' loop with redirection and pipeline
>done
+
+# This used to be buggy and print X at the end of each iteration.
+ for f in 1 2 3 4; do
+ print $f || break
+ done && print X
+0:Handling of ||'s and &&'s with a for loop in between
+>1
+>2
+>3
+>4
+>X
+
+# Same bug for &&, used to print `no' at the end of each iteration
+ for f in 1 2 3 4; do
+ false && print strange
+ done || print no
+0:Handling of &&'s and ||'s with a for loop in between
+>no
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk
Messages sorted by:
Reverse Date,
Date,
Thread,
Author