mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-07 10:10:39 +02:00
* eliminate classes unit from the compiler by copying an array of string based
extractstrings to cclasses. git-svn-id: trunk@27372 -
This commit is contained in:
parent
66d7beb7fe
commit
70088d12a8
@ -76,7 +76,7 @@ type
|
||||
TListSortCompare = function (Item1, Item2: Pointer): Integer;
|
||||
TListCallback = procedure(data,arg:pointer) of object;
|
||||
TListStaticCallback = procedure(data,arg:pointer);
|
||||
|
||||
TDynStringArray = Array Of String;
|
||||
TFPList = class(TObject)
|
||||
private
|
||||
FList: PPointerList;
|
||||
@ -589,12 +589,74 @@ type
|
||||
function FPHash(const s:shortstring):LongWord; inline;
|
||||
function FPHash(const a:ansistring):LongWord; inline;
|
||||
|
||||
function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PChar; var Strings: TDynStringArray; AddEmptyStrings : Boolean = False): Integer;
|
||||
|
||||
implementation
|
||||
|
||||
{*****************************************************************************
|
||||
Memory debug
|
||||
*****************************************************************************}
|
||||
function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PChar; var Strings: TDynStringArray; AddEmptyStrings : Boolean = False): Integer;
|
||||
var
|
||||
b, c : pchar;
|
||||
|
||||
procedure SkipWhitespace;
|
||||
begin
|
||||
while (c^ in Whitespace) do
|
||||
inc (c);
|
||||
end;
|
||||
|
||||
procedure AddString;
|
||||
var
|
||||
l : integer;
|
||||
s : string;
|
||||
begin
|
||||
l := c-b;
|
||||
if (l > 0) or AddEmptyStrings then
|
||||
begin
|
||||
setlength(s, l);
|
||||
if l>0 then
|
||||
move (b^, s[1],l*SizeOf(char));
|
||||
l:=length(Strings);
|
||||
setlength(Strings,l+1);
|
||||
Strings[l]:=S;
|
||||
inc (result);
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
quoted : char;
|
||||
begin
|
||||
result := 0;
|
||||
c := Content;
|
||||
Quoted := #0;
|
||||
Separators := Separators + [#13, #10] - ['''','"'];
|
||||
SkipWhitespace;
|
||||
b := c;
|
||||
while (c^ <> #0) do
|
||||
begin
|
||||
if (c^ = Quoted) then
|
||||
begin
|
||||
if ((c+1)^ = Quoted) then
|
||||
inc (c)
|
||||
else
|
||||
Quoted := #0
|
||||
end
|
||||
else if (Quoted = #0) and (c^ in ['''','"']) then
|
||||
Quoted := c^;
|
||||
if (Quoted = #0) and (c^ in Separators) then
|
||||
begin
|
||||
AddString;
|
||||
inc (c);
|
||||
SkipWhitespace;
|
||||
b := c;
|
||||
end
|
||||
else
|
||||
inc (c);
|
||||
end;
|
||||
if (c <> b) then
|
||||
AddString;
|
||||
end;
|
||||
|
||||
constructor tmemdebug.create(const s:string);
|
||||
begin
|
||||
|
@ -28,7 +28,7 @@ unit optdead;
|
||||
|
||||
uses
|
||||
globtype,
|
||||
classes,cclasses,
|
||||
cclasses,
|
||||
symtype,
|
||||
wpobase;
|
||||
|
||||
@ -71,7 +71,7 @@ unit optdead;
|
||||
fsymnamepos : longint;
|
||||
fsymfile : text;
|
||||
fsymfilename : tcmdstr;
|
||||
aixstrings : tstringlist;
|
||||
aixstrings : TDynStringArray;
|
||||
fuseaixextractstrings : boolean;
|
||||
function parselinenm(const line: ansistring): boolean;
|
||||
function parselineobjdump(const line: ansistring): boolean;
|
||||
@ -229,7 +229,7 @@ const
|
||||
(aixstrings[0][1]='.') then
|
||||
fsymbols.add(copy(aixstrings[0],2,length(aixstrings[0])),pointer(1));
|
||||
end;
|
||||
aixstrings.clear;
|
||||
setlength(aixstrings,0);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -330,7 +330,7 @@ const
|
||||
if not(line[1] in ['0'..'9','a'..'f','A'..'F']) then
|
||||
begin
|
||||
fuseaixextractstrings:=true;
|
||||
aixstrings:=tstringlist.create;
|
||||
setlength(aixstrings,0);
|
||||
result:=true;
|
||||
exit;
|
||||
end;
|
||||
@ -462,7 +462,6 @@ const
|
||||
|
||||
destructor twpodeadcodeinfofromexternallinker.destroy;
|
||||
begin
|
||||
aixstrings.free;
|
||||
inherited destroy;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user