From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13541 invoked from network); 14 Sep 2002 14:39:11 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 14 Sep 2002 14:39:11 -0000 Received: (qmail 11828 invoked by alias); 14 Sep 2002 14:39:01 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17673 Received: (qmail 11813 invoked from network); 14 Sep 2002 14:39:00 -0000 To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: Re: For loop bug In-reply-to: "Peter Stephenson"'s message of "Sat, 14 Sep 2002 00:31:51 BST." <20020913233156.324A31C0E9@pwstephenson.fsnet.co.uk> Date: Sat, 14 Sep 2002 15:39:20 +0100 From: Peter Stephenson Message-Id: <20020914143925.EDDE21C0EB@pwstephenson.fsnet.co.uk> 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 Work: pws@csr.com Web: http://www.pwstephenson.fsnet.co.uk