* 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:
marco 2014-03-30 12:03:10 +00:00
parent 66d7beb7fe
commit 70088d12a8
2 changed files with 67 additions and 6 deletions

View File

@ -76,7 +76,7 @@ type
TListSortCompare = function (Item1, Item2: Pointer): Integer; TListSortCompare = function (Item1, Item2: Pointer): Integer;
TListCallback = procedure(data,arg:pointer) of object; TListCallback = procedure(data,arg:pointer) of object;
TListStaticCallback = procedure(data,arg:pointer); TListStaticCallback = procedure(data,arg:pointer);
TDynStringArray = Array Of String;
TFPList = class(TObject) TFPList = class(TObject)
private private
FList: PPointerList; FList: PPointerList;
@ -589,12 +589,74 @@ type
function FPHash(const s:shortstring):LongWord; inline; function FPHash(const s:shortstring):LongWord; inline;
function FPHash(const a:ansistring):LongWord; inline; function FPHash(const a:ansistring):LongWord; inline;
function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PChar; var Strings: TDynStringArray; AddEmptyStrings : Boolean = False): Integer;
implementation implementation
{***************************************************************************** {*****************************************************************************
Memory debug 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); constructor tmemdebug.create(const s:string);
begin begin

View File

@ -28,7 +28,7 @@ unit optdead;
uses uses
globtype, globtype,
classes,cclasses, cclasses,
symtype, symtype,
wpobase; wpobase;
@ -71,7 +71,7 @@ unit optdead;
fsymnamepos : longint; fsymnamepos : longint;
fsymfile : text; fsymfile : text;
fsymfilename : tcmdstr; fsymfilename : tcmdstr;
aixstrings : tstringlist; aixstrings : TDynStringArray;
fuseaixextractstrings : boolean; fuseaixextractstrings : boolean;
function parselinenm(const line: ansistring): boolean; function parselinenm(const line: ansistring): boolean;
function parselineobjdump(const line: ansistring): boolean; function parselineobjdump(const line: ansistring): boolean;
@ -229,7 +229,7 @@ const
(aixstrings[0][1]='.') then (aixstrings[0][1]='.') then
fsymbols.add(copy(aixstrings[0],2,length(aixstrings[0])),pointer(1)); fsymbols.add(copy(aixstrings[0],2,length(aixstrings[0])),pointer(1));
end; end;
aixstrings.clear; setlength(aixstrings,0);
end end
else else
begin begin
@ -330,7 +330,7 @@ const
if not(line[1] in ['0'..'9','a'..'f','A'..'F']) then if not(line[1] in ['0'..'9','a'..'f','A'..'F']) then
begin begin
fuseaixextractstrings:=true; fuseaixextractstrings:=true;
aixstrings:=tstringlist.create; setlength(aixstrings,0);
result:=true; result:=true;
exit; exit;
end; end;
@ -462,7 +462,6 @@ const
destructor twpodeadcodeinfofromexternallinker.destroy; destructor twpodeadcodeinfofromexternallinker.destroy;
begin begin
aixstrings.free;
inherited destroy; inherited destroy;
end; end;