zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: Re: For loop bug
Date: Sat, 14 Sep 2002 15:39:20 +0100	[thread overview]
Message-ID: <20020914143925.EDDE21C0EB@pwstephenson.fsnet.co.uk> (raw)
In-Reply-To: "Peter Stephenson"'s message of "Sat, 14 Sep 2002 00:31:51 BST." <20020913233156.324A31C0E9@pwstephenson.fsnet.co.uk>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2743 bytes --]

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@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk


  parent reply	other threads:[~2002-09-14 14:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-13 18:25 Philippe Troin
2002-09-13 23:31 ` Peter Stephenson
2002-09-14  0:34   ` Bart Schaefer
2002-09-14  0:58   ` Philippe Troin
2002-09-14  4:56     ` Bart Schaefer
2002-09-16  4:58       ` Philippe Troin
2002-09-16  6:25         ` Bart Schaefer
2002-09-16 18:26           ` Philippe Troin
2002-09-16 20:46             ` Hans Dieter Pearcey
2002-09-17  0:08               ` Philippe Troin
2002-09-14 14:39   ` Peter Stephenson [this message]
2002-09-17 10:47     ` Peter Stephenson
2002-09-29 13:20     ` Sven Wischnowsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020914143925.EDDE21C0EB@pwstephenson.fsnet.co.uk \
    --to=pws@pwstephenson.fsnet.co.uk \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).