Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: line number reporting weirdnesses



On Sat, 30 Aug 2008 10:49:03 -0400
"Rocky Bernstein" <rocky.bernstein@xxxxxxxxx> 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 <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author