From a6f1211ee610ae95359848fc441241ed200c0114 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 31 Aug 2018 20:42:58 -0500 Subject: [PATCH] Properly treat #line directive as giving the next line number, not the current one. --- Scanner.pas | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Scanner.pas b/Scanner.pas index 3e8355c..7505be5 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -1837,6 +1837,7 @@ var lReportEOL: boolean; {local copy of reportEOL} tSkipping: boolean; {temp copy of the skipping variable} val: integer; {expression value} + nextLineNumber: integer; {number for next line} function Defined: boolean; @@ -2546,6 +2547,7 @@ lReportEOL := reportEOL; {we need to see eol's} reportEOL := true; tSkipping := skipping; {don't skip the directive name!} skipping := false; +nextLineNumber := -1; NextCh; {skip the '#' char} while charKinds[ord(ch)] = ch_white do {skip white space} NextCh; @@ -2626,13 +2628,11 @@ if ch in ['a','d','e','i','l','p','u','w'] then begin FlagPragmas(p_line); NextToken; if token.kind = intconst then begin - lineNumber := token.ival; + nextLineNumber := token.ival; NextToken; end {if} else Error(18); - if lineNumber < 0 then - lineNumber := 0; if token.kind = stringconst then begin LongToPString( pointer(ord4(@sourceFileGS.theString)+1), @@ -2857,6 +2857,8 @@ charKinds[ord('#')] := illegal; {don't allow # as a token} reportEOL := lReportEOL; {restore flags} printMacroExpansions := lPrintMacroExpansions; skipping := tskipping; +if nextLineNumber >= 0 then + lineNumber := nextLineNumber; end; {PreProcess} {-- Externally available routines ------------------------------}