From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12311 invoked from network); 25 Feb 2002 09:19:45 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 25 Feb 2002 09:19:45 -0000 Received: (qmail 5298 invoked by alias); 25 Feb 2002 09:19:39 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16711 Received: (qmail 5287 invoked from network); 25 Feb 2002 09:19:39 -0000 From: Sven Wischnowsky MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15482.373.362707.374283@wischnow.berkom.de> Date: Mon, 25 Feb 2002 10:18:45 +0100 To: zsh-workers@sunsite.dk Subject: Re: [falk@debian.org: Bug#107528: "while do done" gets into uninterruptable loop] In-Reply-To: <20020221040542.GA6331@dman.com> References: <20010803105421.A14927@dman.com> <200108071355.PAA04130@beta.informatik.hu-berlin.de> <20020221040542.GA6331@dman.com> X-Mailer: VM 6.95 under 21.5 (patch 3) "asparagus" XEmacs Lucid Clint Adams wrote: > > The patch below looks stupid (and it may well be), but it's the easiest > > I can think of. I think I better not commit this until I get replies. > > (Most of it is re-indentation of that loop, there's just a tiny bit of > > added code at the top.) > > This seems to work; I don't have any objection to its committal. Nor have I. And since noone else complained I'm just going to commit it. Bye Sven Index: Src/loop.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/loop.c,v retrieving revision 1.7 diff -u -r1.7 loop.c --- Src/loop.c 23 Oct 2001 16:17:05 -0000 1.7 +++ Src/loop.c 25 Feb 2002 09:18:48 -0000 @@ -380,37 +380,53 @@ cmdpush(isuntil ? CS_UNTIL : CS_WHILE); loops++; loop = state->pc; - for (;;) { - state->pc = loop; - noerrexit = 1; - execlist(state, 1, 0); - noerrexit = olderrexit; - if (!((lastval == 0) ^ isuntil)) { - if (breaks) - breaks--; - lastval = oldval; - break; - } - if (retflag) { - lastval = oldval; - break; - } - execlist(state, 1, 0); - if (breaks) { - breaks--; - if (breaks || !contflag) - break; - contflag = 0; - } - if (errflag) { - lastval = 1; - break; - } - if (retflag) - break; - freeheap(); - oldval = lastval; - } + + if (loop[0] == WC_END && loop[1] == WC_END) { + + /* This is an empty loop. Make sure the signal handler sets the + * flags and then just wait for someone hitting ^C. */ + + int old_simple_pline = simple_pline; + + simple_pline = 1; + + while (!breaks) + ; + breaks--; + + simple_pline = old_simple_pline; + } else + for (;;) { + state->pc = loop; + noerrexit = 1; + execlist(state, 1, 0); + noerrexit = olderrexit; + if (!((lastval == 0) ^ isuntil)) { + if (breaks) + breaks--; + lastval = oldval; + break; + } + if (retflag) { + lastval = oldval; + break; + } + execlist(state, 1, 0); + if (breaks) { + breaks--; + if (breaks || !contflag) + break; + contflag = 0; + } + if (errflag) { + lastval = 1; + break; + } + if (retflag) + break; + freeheap(); + oldval = lastval; + } cmdpop(); popheap(); loops--; -- Sven Wischnowsky wischnow@berkom.de