mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-10 12:29:15 +02:00
* end of an include file works like a new line with regard to single line (//) comments, resolves #39912
This commit is contained in:
parent
9e783cc3ad
commit
af1194de4d
@ -3641,6 +3641,8 @@ type
|
||||
|
||||
|
||||
procedure tscannerfile.reload;
|
||||
var
|
||||
wasmacro: Boolean;
|
||||
begin
|
||||
with inputfile do
|
||||
begin
|
||||
@ -3698,6 +3700,7 @@ type
|
||||
end
|
||||
else
|
||||
begin
|
||||
wasmacro:=inputfile.is_macro;
|
||||
{ load eof position in tokenpos/current_filepos }
|
||||
gettokenpos;
|
||||
{ close file }
|
||||
@ -3713,6 +3716,15 @@ type
|
||||
tempopeninputfile;
|
||||
{ status }
|
||||
Message1(scan_t_back_in,inputfile.name);
|
||||
{ end of include file is like a line break which ends e.g. also // style comments }
|
||||
if not(wasmacro) then
|
||||
begin
|
||||
c:=#10;
|
||||
{ ... but we have to decrease the line number first because it is increased due to this
|
||||
inserted line break later on }
|
||||
dec(line_no);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
{ load next char }
|
||||
c:=inputpointer^;
|
||||
|
2
tests/webtbs/ib39912.inc
Normal file
2
tests/webtbs/ib39912.inc
Normal file
@ -0,0 +1,2 @@
|
||||
inc(i);
|
||||
//
|
17
tests/webtbs/tb39912.pp
Normal file
17
tests/webtbs/tb39912.pp
Normal file
@ -0,0 +1,17 @@
|
||||
{$macro on}
|
||||
var
|
||||
i: int32;
|
||||
|
||||
begin
|
||||
i := 0;
|
||||
{$include ib39912.inc} {$include ib39912.inc} {$include ib39912.inc}
|
||||
|
||||
{$define debugln := writeln}
|
||||
debugln('i = ', i, ' (will be printed; must be 3).');
|
||||
if i<>3 then
|
||||
halt(1);
|
||||
|
||||
{$define debugln := //}
|
||||
debugln('i = ', i, ' (will not be printed).');
|
||||
debugln halt(1);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user