From 2e3363ef7d1492bf8644b7cad89e500c3fc3251b Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 31 Aug 2008 19:50:47 +0000 Subject: 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 --- Src/lex.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Src/lex.c') 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; -- cgit 1.4.1