mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 10:58:06 +02:00
* Use dynamic arrays for compiler messages
This commit is contained in:
parent
be1fedb2ec
commit
1547f28a40
@ -35,11 +35,12 @@ type
|
|||||||
ppchar=^pchar;
|
ppchar=^pchar;
|
||||||
TMsgStr = AnsiString;
|
TMsgStr = AnsiString;
|
||||||
|
|
||||||
TArrayOfPChar = array[0..1000] of pchar;
|
TArrayOfPChar = array of pchar;
|
||||||
PArrayOfPChar = ^TArrayOfPChar;
|
TArrayOfState = array of tmsgstate;
|
||||||
|
|
||||||
TArrayOfState = array[0..1000] of tmsgstate;
|
TMsgIdx = array[1..maxmsgidxparts] of TArrayOfPChar;
|
||||||
PArrayOfState = ^TArrayOfState;
|
TMsgIdxMax = array[1..maxmsgidxparts] of longint;
|
||||||
|
TMsgStates = array[1..maxmsgidxparts] of TArrayOfState;
|
||||||
|
|
||||||
PMessage=^TMessage;
|
PMessage=^TMessage;
|
||||||
TMessage=object
|
TMessage=object
|
||||||
@ -50,9 +51,9 @@ type
|
|||||||
msgparts,
|
msgparts,
|
||||||
msgs : longint;
|
msgs : longint;
|
||||||
msgtxt : pchar;
|
msgtxt : pchar;
|
||||||
msgidx : array[1..maxmsgidxparts] of PArrayOfPChar;
|
msgidx : TMsgIdx;
|
||||||
msgidxmax : array[1..maxmsgidxparts] of longint;
|
msgidxmax : TMsgIdxMax;
|
||||||
msgstates : array[1..maxmsgidxparts] of PArrayOfState;
|
msgstates : TMsgStates;
|
||||||
msgcodepage : TSystemCodePage;
|
msgcodepage : TSystemCodePage;
|
||||||
{ set if changes with $WARN need to be cleared at next module change }
|
{ set if changes with $WARN need to be cleared at next module change }
|
||||||
has_local_changes : boolean;
|
has_local_changes : boolean;
|
||||||
@ -121,17 +122,19 @@ begin
|
|||||||
msgcodepage:=CP_ACP;
|
msgcodepage:=CP_ACP;
|
||||||
if n<>high(idxmax)+1 then
|
if n<>high(idxmax)+1 then
|
||||||
fail;
|
fail;
|
||||||
|
FillChar(msgidx,SizeOf(TMsgIdx),0);
|
||||||
|
FillChar(msgidxmax,SizeOf(TMsgIdxMax),0);
|
||||||
|
FillChar(msgstates,SizeOf(TMsgStates),0);
|
||||||
for i:=1 to n do
|
for i:=1 to n do
|
||||||
begin
|
begin
|
||||||
msgidxmax[i]:=idxmax[i-1];
|
msgidxmax[i]:=idxmax[i-1];
|
||||||
{ create array of msgidx }
|
{ create array of msgidx }
|
||||||
getmem(msgidx[i],msgidxmax[i]*sizeof(pointer));
|
SetLength(msgidx[i],msgidxmax[i]);
|
||||||
fillchar(msgidx[i]^,msgidxmax[i]*sizeof(pointer),0);
|
|
||||||
{ create array of states }
|
{ create array of states }
|
||||||
getmem(msgstates[i],msgidxmax[i]*sizeof(tmsgstate));
|
SetLength(msgstates[i],msgidxmax[i]);
|
||||||
{ default value for msgstate is ms_on_global }
|
{ default value for msgstate is ms_on_global }
|
||||||
for j:=0 to msgidxmax[i]-1 do
|
for j:=0 to msgidxmax[i]-1 do
|
||||||
msgstates[i]^[j]:=ms_on_global;
|
msgstates[i][j]:=ms_on_global;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -142,8 +145,8 @@ var
|
|||||||
begin
|
begin
|
||||||
for i:=1 to msgparts do
|
for i:=1 to msgparts do
|
||||||
begin
|
begin
|
||||||
freemem(msgidx[i],msgidxmax[i]*sizeof(pointer));
|
msgidx[i]:=nil;
|
||||||
freemem(msgstates[i],msgidxmax[i]*sizeof(tmsgstate));
|
msgstates[i]:=nil;
|
||||||
end;
|
end;
|
||||||
if msgallocsize>0 then
|
if msgallocsize>0 then
|
||||||
begin
|
begin
|
||||||
@ -335,7 +338,7 @@ var
|
|||||||
begin
|
begin
|
||||||
{ clear }
|
{ clear }
|
||||||
for i:=1 to msgparts do
|
for i:=1 to msgparts do
|
||||||
fillchar(msgidx[i]^,msgidxmax[i]*sizeof(pointer),0);
|
FillChar(msgidx[i][0],msgidxmax[i]*sizeof(pointer),0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -372,11 +375,11 @@ begin
|
|||||||
{ set default verbosity to off is '-' is found just after the '_' }
|
{ set default verbosity to off is '-' is found just after the '_' }
|
||||||
if hp1^='-' then
|
if hp1^='-' then
|
||||||
begin
|
begin
|
||||||
msgstates[numpart]^[numidx]:=ms_off_global;
|
msgstates[numpart][numidx]:=ms_off_global;
|
||||||
inc(hp1);
|
inc(hp1);
|
||||||
end;
|
end;
|
||||||
{ put the address in the idx, the numbers are already checked }
|
{ put the address in the idx, the numbers are already checked }
|
||||||
msgidx[numpart]^[numidx]:=hp1;
|
msgidx[numpart][numidx]:=hp1;
|
||||||
end;
|
end;
|
||||||
{ next string }
|
{ next string }
|
||||||
hp:=pchar(@hp[strlen(hp)+1]);
|
hp:=pchar(@hp[strlen(hp)+1]);
|
||||||
@ -420,12 +423,12 @@ begin
|
|||||||
if (nr mod 1000 < msgidxmax[i]) then
|
if (nr mod 1000 < msgidxmax[i]) then
|
||||||
begin
|
begin
|
||||||
is_global:=(ord(newstate) and ms_global_mask) <> 0;
|
is_global:=(ord(newstate) and ms_global_mask) <> 0;
|
||||||
oldstate:=msgstates[i]^[nr mod 1000];
|
oldstate:=msgstates[i][nr mod 1000];
|
||||||
if not is_global then
|
if not is_global then
|
||||||
newstate:= tmsgstate((ord(newstate) and ms_local_mask) or (ord(oldstate) and ms_global_mask));
|
newstate:= tmsgstate((ord(newstate) and ms_local_mask) or (ord(oldstate) and ms_global_mask));
|
||||||
if newstate<>oldstate then
|
if newstate<>oldstate then
|
||||||
has_local_changes:=true;
|
has_local_changes:=true;
|
||||||
msgstates[i]^[nr mod 1000]:=newstate;
|
msgstates[i][nr mod 1000]:=newstate;
|
||||||
result:=true;
|
result:=true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -444,7 +447,7 @@ var
|
|||||||
begin
|
begin
|
||||||
if (nr div 1000 < msgparts) and
|
if (nr div 1000 < msgparts) and
|
||||||
(nr mod 1000 < msgidxmax[nr div 1000]) then
|
(nr mod 1000 < msgidxmax[nr div 1000]) then
|
||||||
hp:=msgidx[nr div 1000]^[nr mod 1000]
|
hp:=msgidx[nr div 1000][nr mod 1000]
|
||||||
else
|
else
|
||||||
hp:=nil;
|
hp:=nil;
|
||||||
if hp=nil then
|
if hp=nil then
|
||||||
@ -466,7 +469,7 @@ var
|
|||||||
begin
|
begin
|
||||||
i:=nr div 1000;
|
i:=nr div 1000;
|
||||||
j:=nr mod 1000;
|
j:=nr mod 1000;
|
||||||
result:=(i>=low(msgstates)) and (i<msgparts) and (j<msgidxmax[i]) and assigned(msgidx[i]^[j]);
|
result:=(i>=low(msgstates)) and (i<msgparts) and (j<msgidxmax[i]) and assigned(msgidx[i][j]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMessage.ResetStates;
|
procedure TMessage.ResetStates;
|
||||||
@ -479,10 +482,10 @@ begin
|
|||||||
for i:=1 to msgparts do
|
for i:=1 to msgparts do
|
||||||
for j:=0 to msgidxmax[i] - 1 do
|
for j:=0 to msgidxmax[i] - 1 do
|
||||||
begin
|
begin
|
||||||
state:=msgstates[i]^[j];
|
state:=msgstates[i][j];
|
||||||
glob:=(ord(state) and ms_global_mask) shr ms_shift;
|
glob:=(ord(state) and ms_global_mask) shr ms_shift;
|
||||||
state:=tmsgstate((glob shl ms_shift) or glob);
|
state:=tmsgstate((glob shl ms_shift) or glob);
|
||||||
msgstates[i]^[j]:=state;
|
msgstates[i][j]:=state;
|
||||||
end;
|
end;
|
||||||
has_local_changes:=false;
|
has_local_changes:=false;
|
||||||
end;
|
end;
|
||||||
|
@ -629,7 +629,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
i:=m div 1000;
|
i:=m div 1000;
|
||||||
{ get the default state }
|
{ get the default state }
|
||||||
Result:=msg^.msgstates[i]^[m mod 1000];
|
Result:=msg^.msgstates[i][m mod 1000];
|
||||||
|
|
||||||
{ and search at the current unit settings }
|
{ and search at the current unit settings }
|
||||||
{ todo }
|
{ todo }
|
||||||
|
Loading…
Reference in New Issue
Block a user