mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-21 23:49:11 +02:00
* replace/restore_scanner use var in state to make sure the correct scanner is freed
This commit is contained in:
parent
8fa3c57c1b
commit
4443e83b75
@ -35,6 +35,7 @@ interface
|
|||||||
|
|
||||||
type
|
type
|
||||||
tscannerstate = record
|
tscannerstate = record
|
||||||
|
new_scanner: tscannerfile;
|
||||||
old_scanner: tscannerfile;
|
old_scanner: tscannerfile;
|
||||||
old_filepos: tfileposinfo;
|
old_filepos: tfileposinfo;
|
||||||
old_token: ttoken;
|
old_token: ttoken;
|
||||||
@ -166,7 +167,8 @@ implementation
|
|||||||
{ creating a new scanner resets the block type, while we want to continue
|
{ creating a new scanner resets the block type, while we want to continue
|
||||||
in the current one }
|
in the current one }
|
||||||
old_block_type:=block_type;
|
old_block_type:=block_type;
|
||||||
current_scanner:=tscannerfile.Create('_Macro_.'+tempname,true);
|
sstate.new_scanner:=tscannerfile.Create('_Macro_.'+tempname,true);
|
||||||
|
set_current_scanner(sstate.new_scanner,False);
|
||||||
block_type:=old_block_type;
|
block_type:=old_block_type;
|
||||||
{ required for e.g. FpcDeepCopy record method (uses "out" parameter; field
|
{ required for e.g. FpcDeepCopy record method (uses "out" parameter; field
|
||||||
names are escaped via &, so should not cause conflicts }
|
names are escaped via &, so should not cause conflicts }
|
||||||
@ -178,8 +180,8 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if sstate.valid then
|
if sstate.valid then
|
||||||
begin
|
begin
|
||||||
current_scanner.free;
|
sstate.new_scanner.free;
|
||||||
current_scanner:=sstate.old_scanner;
|
set_current_scanner(sstate.old_scanner,false);
|
||||||
current_filepos:=sstate.old_filepos;
|
current_filepos:=sstate.old_filepos;
|
||||||
token:=sstate.old_token;
|
token:=sstate.old_token;
|
||||||
current_settings.modeswitches:=sstate.old_modeswitches;
|
current_settings.modeswitches:=sstate.old_modeswitches;
|
||||||
|
Loading…
Reference in New Issue
Block a user