From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1488 invoked from network); 31 Aug 2008 15:55:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 Aug 2008 15:55:51 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 2560 invoked from network); 31 Aug 2008 15:55:37 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Aug 2008 15:55:37 -0000 Received: (qmail 8578 invoked by alias); 31 Aug 2008 15:55:31 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25570 Received: (qmail 8559 invoked from network); 31 Aug 2008 15:55:30 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 31 Aug 2008 15:55:30 -0000 Received: from mtaout02-winn.ispmail.ntl.com (mtaout02-winn.ispmail.ntl.com [81.103.221.48]) by bifrost.dotsrc.org (Postfix) with ESMTP id A7784801E2B4 for ; Sun, 31 Aug 2008 17:55:27 +0200 (CEST) Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com with ESMTP id <20080831155526.NOOP21103.mtaout02-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com> for ; Sun, 31 Aug 2008 16:55:26 +0100 Received: from pws-pc ([81.107.43.40]) by aamtaout01-winn.ispmail.ntl.com with ESMTP id <20080831155526.PLGI5827.aamtaout01-winn.ispmail.ntl.com@pws-pc> for ; Sun, 31 Aug 2008 16:55:26 +0100 Date: Sun, 31 Aug 2008 16:55:18 +0100 From: Peter Stephenson To: "Zsh hackers list" Subject: Re: line number reporting weirdnesses Message-ID: <20080831165518.5714d07a@pws-pc> In-Reply-To: <6cd6de210808300749yf3cc8d4gadc62d8f7f96ec15@mail.gmail.com> References: <6cd6de210808300749yf3cc8d4gadc62d8f7f96ec15@mail.gmail.com> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.11; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.92.1/8122/Sun Aug 31 03:04:56 2008 on bifrost X-Virus-Status: Clean On Sat, 30 Aug 2008 10:49:03 -0400 "Rocky Bernstein" wrote: > First, the lines numbers of with [[ ]] inside if [[ ]] are weird - > there is no line 3920. This happened with anything followed by "||" or "&&"; yet another special case in the code. Not sure where this came in, but the fix seems to be obvious. > Second the line number in an assignment statement is basically the > line of the string token which spans several lines. Possibly it might > be more helpful to give the line number of the LHS token. I agree, but that means we need to remember the line number at the start of the last parsed token instead of after. I'll have to think about how to do this some more; this could be another hard one to get completely consistent. The problem is we actually record the line number down in the input code, below the level of the lexical analyser. It should be possible to get this right with an extra variable; the question is where this variable needs to be set and updated. Index: Src/exec.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/exec.c,v retrieving revision 1.142 diff -u -r1.142 exec.c --- Src/exec.c 25 Aug 2008 17:28:16 -0000 1.142 +++ Src/exec.c 31 Aug 2008 15:46:27 -0000 @@ -1060,7 +1060,7 @@ lnp1 = code2; } else if (wc_code(code2) == WC_SUBLIST) { if (WC_SUBLIST_FLAGS(code2) == WC_SUBLIST_SIMPLE) - lnp1 = state->pc[2]; + lnp1 = state->pc[1]; else lnp1 = WC_PIPE_LINENO(state->pc[1]); } Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.143 diff -u -r1.143 zsh.h --- Src/zsh.h 19 Aug 2008 12:02:11 -0000 1.143 +++ Src/zsh.h 31 Aug 2008 15:46:29 -0000 @@ -1063,7 +1063,7 @@ struct shfunc { struct hashnode node; char *filename; /* Name of file located in */ - int lineno; /* line number in above file */ + zlong lineno; /* line number in above file */ Eprog funcdef; /* function definition */ }; Index: Test/C03traps.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/C03traps.ztst,v retrieving revision 1.15 diff -u -r1.15 C03traps.ztst --- Test/C03traps.ztst 25 Aug 2008 17:28:16 -0000 1.15 +++ Test/C03traps.ztst 31 Aug 2008 15:46:29 -0000 @@ -429,6 +429,16 @@ 1:Skip assignment from DEBUG trap >5 three + fn() { + setopt localtraps localoptions debugbeforecmd + trap 'print $LINENO' DEBUG + [[ a = a ]] && print a is ok + } + fn +0:line numbers of complex sublists +>3 +>a is ok + %clean rm -f TRAPEXIT -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/