about summary refs log tree commit diff
path: root/Src/lex.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-08-31 19:50:47 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-08-31 19:50:47 +0000
commit2e3363ef7d1492bf8644b7cad89e500c3fc3251b (patch)
tree76c78bab1cefdc22c428105af8a1f30475583505 /Src/lex.c
parent2c52a13aa5d18797b6acdc40b03dfd1bc3a60eeb (diff)
downloadzsh-2e3363ef7d1492bf8644b7cad89e500c3fc3251b.tar.gz
zsh-2e3363ef7d1492bf8644b7cad89e500c3fc3251b.tar.xz
zsh-2e3363ef7d1492bf8644b7cad89e500c3fc3251b.zip
25571: when parsing use line numbers for the start of a token, not the end
add test and move debug trap tests to new file
Diffstat (limited to 'Src/lex.c')
-rw-r--r--Src/lex.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Src/lex.c b/Src/lex.c
index 739a6f391..025387ca1 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -46,6 +46,17 @@ mod_export int tok;
 /**/
 mod_export int tokfd;
 
+/*
+ * Line number at which the first character of a token was found.
+ * We always set this in gettok(), which is always called from
+ * yylex() unless we have reached an error.  So it is always
+ * valid when parsing.  It is not useful during execution
+ * of the parsed structure.
+ */
+
+/**/
+zlong toklineno;
+
 /* lexical analyzer error flag */
  
 /**/
@@ -211,6 +222,7 @@ struct lexstack {
 
     unsigned char *cstack;
     int csp;
+    zlong toklineno;
 };
 
 static struct lexstack *lstack = NULL;
@@ -269,6 +281,7 @@ lexsave(void)
     ls->ecsoffs = ecsoffs;
     ls->ecssub = ecssub;
     ls->ecnfunc = ecnfunc;
+    ls->toklineno = toklineno;
     cmdsp = 0;
     inredir = 0;
     hdocs = NULL;
@@ -333,6 +346,7 @@ lexrestore(void)
     ecssub = lstack->ecssub;
     ecnfunc = lstack->ecnfunc;
     hlinesz = lstack->hlinesz;
+    toklineno = lstack->toklineno;
     errflag = 0;
 
     ln = lstack->next;
@@ -661,6 +675,7 @@ gettok(void)
   beginning:
     tokstr = NULL;
     while (iblank(c = hgetc()) && !lexstop);
+    toklineno = lineno;
     if (lexstop)
 	return (errflag) ? LEXERR : ENDINPUT;
     isfirstln = 0;