From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3281 invoked from network); 29 Jul 2004 14:59:26 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 29 Jul 2004 14:59:26 -0000 Received: (qmail 88229 invoked from network); 29 Jul 2004 14:59:20 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 Jul 2004 14:59:20 -0000 Received: (qmail 10317 invoked by alias); 29 Jul 2004 14:59:08 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20221 Received: (qmail 10308 invoked from network); 29 Jul 2004 14:59:07 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 29 Jul 2004 14:59:07 -0000 Received: (qmail 87239 invoked from network); 29 Jul 2004 14:57:09 -0000 Received: from lhuumrelay3.lnd.ops.eu.uu.net (62.189.58.19) by a.mx.sunsite.dk with SMTP; 29 Jul 2004 14:57:07 -0000 Received: from MAILSWEEPER01.csr.com (mailhost1.csr.com [62.189.183.235]) by lhuumrelay3.lnd.ops.eu.uu.net (8.11.0/8.11.0) with ESMTP id i6TEv5v02194 for ; Thu, 29 Jul 2004 14:57:05 GMT Received: from EXCHANGE02.csr.com (unverified [192.168.137.45]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id ; Thu, 29 Jul 2004 15:56:19 +0100 Received: from news01.csr.com ([192.168.143.38]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 29 Jul 2004 15:59:00 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.12.11/8.12.11) with ESMTP id i6TEv2d6023433; Thu, 29 Jul 2004 15:57:02 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.12.11/8.12.11/Submit) with ESMTP id i6TEv0Yl023430; Thu, 29 Jul 2004 15:57:00 +0100 Message-Id: <200407291457.i6TEv0Yl023430@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk cc: "Dieter Lambrecht" Subject: Re: Bug in zsh versions 4.1.1 and 4.2.0 In-reply-to: ""Dieter Lambrecht""'s message of "Thu, 29 Jul 2004 16:14:51 +0200." Date: Thu, 29 Jul 2004 15:56:59 +0100 From: Peter Stephenson X-OriginalArrivalTime: 29 Jul 2004 14:59:00.0288 (UTC) FILETIME=[949C4400:01C4757C] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-4.9 required=6.0 tests=BAYES_00 autolearn=no version=2.63 X-Spam-Hits: -4.9 "Dieter Lambrecht" wrote: > Hi, > > the following zsh-script running on Linux (Suse-Linux-Desktop) > > #! /home/bzq090/aps4_main/aps4/test/package/zsh/zsh-4.2.0/Src/zsh > emulate -L zsh > > trap 'print $LINENO' DEBUG > > echo $LINENO > echo $LINENO > > > > gives the following output: > > 1 > 6 > 1 > 7 > 1 > > > Contrary to the information in "Z SHELL Manual" p. 85, LINENO is not > updated correctly if used with the trap-builtin. Yes, that's a real bug, the documentation is correct. This must have got broken when the wordcode execution stuff came in, since I remember sweating blood over this some years ago. It's been masked by the fact that the buggy behaviour is encoded into the test suite; that's fixed below as well. I'm surprised nobody noticed it before since it makes detailed debugging a good deal harder. Maybe people now rely on PS4, which gets the correct line number. (I think the explanation for the test suite is that the first test, TRAPDEBUG, is correct, also as per documentation. The example got copied for trap '...' debug, and since it worked without alteration, no one noticed this was wrong. The behaviour for TRAPDEBUG probably isn't all that useful, actually; I think I decided somewhat arbitrarily that it would respect the normal function convention. There's no prior art in that case.) Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.68 diff -u -r1.68 exec.c --- Src/exec.c 26 Jul 2004 13:18:14 -0000 1.68 +++ Src/exec.c 29 Jul 2004 14:48:59 -0000 @@ -787,7 +787,8 @@ if (errflag) return (lastval = 1); - if (code) + /* In evaluated traps, don't modify the line number. */ + if ((!intrap || trapisfunc) && code) lineno = code - 1; code = wc_code(*state->pc++); @@ -1258,7 +1259,8 @@ if (breaks || retflag) return; - if (WC_PIPE_LINENO(pcode)) + /* In evaluated traps, don't modify the line number. */ + if ((!intrap || trapisfunc) && WC_PIPE_LINENO(pcode)) lineno = WC_PIPE_LINENO(pcode) - 1; if (pline_level == 1) { Index: Src/signals.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/signals.c,v retrieving revision 1.29 diff -u -r1.29 signals.c --- Src/signals.c 26 Jul 2004 13:18:14 -0000 1.29 +++ Src/signals.c 29 Jul 2004 14:49:01 -0000 @@ -943,6 +943,11 @@ /**/ int intrap; +/* Is the current trap a function? */ + +/**/ +int trapisfunc; + /**/ void dotrapargs(int sig, int *sigtr, void *sigfn) @@ -1001,19 +1006,19 @@ zaddlinknode(args, num); trapreturn = -1; /* incremented by doshfunc */ + trapisfunc = isfunc = 1; + sfcontext = SFC_SIGNAL; doshfunc(name, sigfn, args, 0, 1); sfcontext = osc; freelinklist(args, (FreeFunc) NULL); zsfree(name); - isfunc = 1; } else { trapreturn = -2; /* not incremented, used at current level */ + trapisfunc = isfunc = 0; execode(sigfn, 1, 0); - - isfunc = 0; } runhookdef(AFTERTRAPHOOK, NULL); Index: Test/A05execution.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/A05execution.ztst,v retrieving revision 1.3 diff -u -r1.3 A05execution.ztst --- Test/A05execution.ztst 22 Aug 2001 15:59:27 -0000 1.3 +++ Test/A05execution.ztst 29 Jul 2004 14:49:01 -0000 @@ -136,7 +136,7 @@ rm fn 0:trap DEBUG >Line 1 ->Line 1 +>Line 2 TRAPZERR() { print Command failed; } true -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************