mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 17:49:27 +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
|
||||
tscannerstate = record
|
||||
new_scanner: tscannerfile;
|
||||
old_scanner: tscannerfile;
|
||||
old_filepos: tfileposinfo;
|
||||
old_token: ttoken;
|
||||
@ -166,7 +167,8 @@ implementation
|
||||
{ creating a new scanner resets the block type, while we want to continue
|
||||
in the current one }
|
||||
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;
|
||||
{ required for e.g. FpcDeepCopy record method (uses "out" parameter; field
|
||||
names are escaped via &, so should not cause conflicts }
|
||||
@ -178,8 +180,8 @@ implementation
|
||||
begin
|
||||
if sstate.valid then
|
||||
begin
|
||||
current_scanner.free;
|
||||
current_scanner:=sstate.old_scanner;
|
||||
sstate.new_scanner.free;
|
||||
set_current_scanner(sstate.old_scanner,false);
|
||||
current_filepos:=sstate.old_filepos;
|
||||
token:=sstate.old_token;
|
||||
current_settings.modeswitches:=sstate.old_modeswitches;
|
||||
|
Loading…
Reference in New Issue
Block a user