* source linebuf as dyn array

This commit is contained in:
Michaël Van Canneyt 2025-03-18 14:52:59 +01:00
parent 2f3c0bc8bf
commit 25e955b6e4
5 changed files with 20 additions and 24 deletions

View File

@ -1039,8 +1039,8 @@ Implementation
if not assigned(f) then
exit;
for i:=0 to f.maxlinebuf-1 do
if f.linebuf^[i]<0 then
f.linebuf^[i]:=-f.linebuf^[i]-1;
if f.linebuf[i]<0 then
f.linebuf[i]:=-f.linebuf[i]-1;
end;
begin
@ -1094,13 +1094,13 @@ Implementation
(hp.fileinfo.line<infile.maxlinebuf) then
begin
if (hp.fileinfo.line<>0) and
(infile.linebuf^[hp.fileinfo.line]>=0) then
(infile.linebuf[hp.fileinfo.line]>=0) then
writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp.fileinfo.line)+'] '+
fixline(infile.GetLineStr(hp.fileinfo.line)));
{ set it to a negative value !
to make that is has been read already !! PM }
if (infile.linebuf^[hp.fileinfo.line]>=0) then
infile.linebuf^[hp.fileinfo.line]:=-infile.linebuf^[hp.fileinfo.line]-1;
if (infile.linebuf[hp.fileinfo.line]>=0) then
infile.linebuf[hp.fileinfo.line]:=-infile.linebuf[hp.fileinfo.line]-1;
end;
end;
lastfileinfo:=hp.fileinfo;

View File

@ -33,8 +33,7 @@ interface
linebufincrease=512;
type
tlongintarr = array[0..1000000] of longint;
plongintarr = ^tlongintarr;
tlongintarr = array of longint;
tinputfile = class
path,name : TPathStr; { path and filename }
@ -50,7 +49,7 @@ interface
savelastlinepos,
saveline_no : longint;
linebuf : plongintarr; { line buffer to retrieve lines }
linebuf : tlongintarr; { line buffer to retrieve lines }
maxlinebuf : longint;
ref_index : longint;
@ -248,9 +247,7 @@ uses
begin
if not closed then
close;
{ free memory }
if assigned(linebuf) then
freemem(linebuf,maxlinebuf*sizeof(linebuf^[0]));
linebuf:=Nil;
end;
@ -387,11 +384,10 @@ uses
while (line>=maxlinebuf) do
begin
{ create new linebuf and move old info }
linebuf:=reallocmem(linebuf,(maxlinebuf+linebufincrease)*sizeof(linebuf^[0]));
fillchar(linebuf^[maxlinebuf],linebufincrease*sizeof(linebuf^[0]),0);
SetLength(linebuf,(maxlinebuf+linebufincrease));
inc(maxlinebuf,linebufincrease);
end;
linebuf^[line]:=linepos;
linebuf[line]:=linepos;
end;
@ -405,7 +401,7 @@ uses
getlinestr:='';
if l<maxlinebuf then
begin
fpos:=linebuf^[l];
fpos:=linebuf[l];
{ fpos is set negativ if the line was already written }
{ but we still know the correct value }
if fpos<0 then

View File

@ -346,13 +346,13 @@ implementation
((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
begin
if (hp1.fileinfo.line<>0) and
((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
((infile.linebuf[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
fixline(infile.GetLineStr(hp1.fileinfo.line)));
{ set it to a negative value !
to make that is has been read already !! PM }
if (infile.linebuf^[hp1.fileinfo.line]>=0) then
infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
if (infile.linebuf[hp1.fileinfo.line]>=0) then
infile.linebuf[hp1.fileinfo.line]:=-infile.linebuf[hp1.fileinfo.line]-1;
end;
end;
lastfileinfo:=hp1.fileinfo;

View File

@ -283,13 +283,13 @@ implementation
((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
begin
if (hp1.fileinfo.line<>0) and
((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
((infile.linebuf[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
fixline(infile.GetLineStr(hp1.fileinfo.line)));
{ set it to a negative value !
to make that is has been read already !! PM }
if (infile.linebuf^[hp1.fileinfo.line]>=0) then
infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
if (infile.linebuf[hp1.fileinfo.line]>=0) then
infile.linebuf[hp1.fileinfo.line]:=-infile.linebuf[hp1.fileinfo.line]-1;
end;
end;
lastfileinfo:=hp1.fileinfo;

View File

@ -455,13 +455,13 @@ implementation
((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
begin
if (hp1.fileinfo.line<>0) and
((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
((infile.linebuf[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
writer.AsmWriteLn(asminfo^.comment+'['+tostr(hp1.fileinfo.line)+'] '+
fixline(infile.GetLineStr(hp1.fileinfo.line)));
{ set it to a negative value !
to make that is has been read already !! PM }
if (infile.linebuf^[hp1.fileinfo.line]>=0) then
infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
if (infile.linebuf[hp1.fileinfo.line]>=0) then
infile.linebuf[hp1.fileinfo.line]:=-infile.linebuf[hp1.fileinfo.line]-1;
end;
end;
lastfileinfo:=hp1.fileinfo;