* recursive include depth check

This commit is contained in:
peter 2003-05-25 10:26:43 +00:00
parent c0995a3db1
commit 1b72901b14

View File

@ -34,6 +34,7 @@ interface
widestr,cpuinfo;
const
max_include_nesting=32;
max_macro_nesting=16;
maxmacrolen=16*1024;
preprocbufsize=32*1024;
@ -83,6 +84,7 @@ interface
tscannerfile = class
public
inputfile : tinputfile; { current inputfile list }
inputfilecount : longint;
inputbuffer, { input buffer }
inputpointer : pchar;
@ -759,6 +761,9 @@ implementation
if (not found) then
found:=findincludefile(path,name,target_info.pasext,foundfile);
end;
if current_scanner.inputfilecount<max_include_nesting then
begin
inc(current_scanner.inputfilecount);
{ save old postion and decrease linebreak }
if c=newline then
dec(current_scanner.line_no);
@ -779,6 +784,9 @@ implementation
#10,
#13 : current_scanner.linebreak;
end;
end
else
Message(scan_f_include_deep_ten);
end;
end;
@ -1072,7 +1080,10 @@ implementation
if inputfile.is_macro then
to_dispose:=inputfile
else
begin
to_dispose:=nil;
dec(inputfilecount);
end;
{ we can allways close the file, no ? }
inputfile.close;
inputfile:=inputfile.next;
@ -2803,7 +2814,10 @@ exit_label:
end.
{
$Log$
Revision 1.58 2003-04-26 00:30:27 peter
Revision 1.59 2003-05-25 10:26:43 peter
* recursive include depth check
Revision 1.58 2003/04/26 00:30:27 peter
* don't close inputfile when still closed
Revision 1.57 2003/01/09 21:52:37 peter