lcl: extended ReadLFMHeader for unitnames

This commit is contained in:
mattias 2023-04-11 17:55:20 +02:00
parent c3f0c4009a
commit 9e78f5abe0

View File

@ -2029,26 +2029,33 @@ var
begin begin
{ examples: { examples:
object Form1: TForm1 object Form1: TForm1
inherited AboutBox2: TAboutBox2 inherited AboutBox2: ns.unit2/TAboutBox2
} }
LFMComponentName:=''; LFMComponentName:='';
LFMClassName := ''; LFMClassName := '';
LFMType := ''; LFMType := '';
Token := ''; Token := '';
while (LFMStream.Read(c,1)=1) and (LFMStream.Position<1000) do begin while (LFMStream.Read(c,1)=1) and (LFMStream.Position<1000) do begin
if c in ['a'..'z','A'..'Z','0'..'9','_'] then case c of
Token := Token + c ' ',#9,':':
else begin begin
if Token<>'' then begin if Token<>'' then begin
if LFMType = '' then if LFMType = '' then
LFMType := Token LFMType := Token
else if LFMComponentName='' then else if LFMComponentName='' then
LFMComponentName:=Token LFMComponentName:=Token
else if LFMClassName = '' then else if LFMClassName = '' then
begin
LFMClassName := Token; LFMClassName := Token;
exit;
end;
Token := ''; Token := '';
end; end;
if c in [#10,#13] then break; end;
'a'..'z','A'..'Z','0'..'9','_','.','/':
Token:=Token+c;
else
break;
end; end;
end; end;
LFMStream.Position:=0; LFMStream.Position:=0;
@ -2070,21 +2077,21 @@ var
begin begin
{ examples: { examples:
object Form1: TForm1 object Form1: TForm1
inherited AboutBox2: TAboutBox2 inherited AboutBox2: ns.unit1/TAboutBox2
- LFMType is the first word on the line - LFMType is the first word on the line, e.g. object or inherited
- LFMComponentName is the second word - LFMComponentName is the second word
- LFMClassName is the fourth token - LFMClassName is the third
} }
// read first word => LFMType // read LFMType
p:=1; p:=1;
while (p<=length(LFMSource)) while (p<=length(LFMSource))
and (LFMSource[p] in ['a'..'z','A'..'Z','0'..'9','_']) do and (LFMSource[p] in ['a'..'z','A'..'Z','0'..'9','_']) do
inc(p); inc(p);
LFMType:=copy(LFMSource,1,p-1); LFMType:=copy(LFMSource,1,p-1);
// read second word => LFMComponentName // read LFMComponentName
while (p<=length(LFMSource)) and (LFMSource[p] in [' ',#9]) do inc(p); while (p<=length(LFMSource)) and (LFMSource[p] in [' ',#9]) do inc(p);
StartPos:=p; StartPos:=p;
while (p<=length(LFMSource)) while (p<=length(LFMSource))
@ -2092,11 +2099,11 @@ begin
inc(p); inc(p);
LFMComponentName:=copy(LFMSource,StartPos,p-StartPos); LFMComponentName:=copy(LFMSource,StartPos,p-StartPos);
// read third word => LFMClassName // read LFMClassName
while (p<=length(LFMSource)) and (LFMSource[p] in [' ',#9,':']) do inc(p); while (p<=length(LFMSource)) and (LFMSource[p] in [' ',#9,':']) do inc(p);
StartPos:=p; StartPos:=p;
while (p<=length(LFMSource)) while (p<=length(LFMSource))
and (LFMSource[p] in ['a'..'z','A'..'Z','0'..'9','_']) do and (LFMSource[p] in ['a'..'z','A'..'Z','0'..'9','_','.','/']) do
inc(p); inc(p);
LFMClassName:=copy(LFMSource,StartPos,p-StartPos); LFMClassName:=copy(LFMSource,StartPos,p-StartPos);
end; end;