* String items can also be separated by spaces

This commit is contained in:
pierre 1999-02-16 12:46:38 +00:00
parent 29d778ac51
commit 216d00e8bc

View File

@ -154,7 +154,7 @@ var
CfgFile : text;
{*****************************************************************************
TSwitchItem
TSwitchItem
*****************************************************************************}
constructor TSwitchItem.Init(const n,p:string);
@ -183,7 +183,7 @@ end;
{*****************************************************************************
TSelectItem
TSelectItem
*****************************************************************************}
constructor TSelectItem.Init(const n,p:string);
@ -194,7 +194,7 @@ end;
{*****************************************************************************
TBooleanItem
TBooleanItem
*****************************************************************************}
constructor TBooleanItem.Init(const n,p:string);
@ -218,7 +218,7 @@ end;
{*****************************************************************************
TStringItem
TStringItem
*****************************************************************************}
constructor TStringItem.Init(const n,p:string;mult:boolean);
@ -249,7 +249,7 @@ end;
{*****************************************************************************
TLongintItem
TLongintItem
*****************************************************************************}
constructor TLongintItem.Init(const n,p:string);
@ -282,7 +282,7 @@ end;
{*****************************************************************************
TSwitch
TSwitch
*****************************************************************************}
constructor TSwitches.Init(ch:char);
@ -452,25 +452,28 @@ var
procedure writeitem(P:PSwitchItem);{$ifndef FPC}far;{$endif}
var
s,s1 : string;
i : integer;
i,j : integer;
begin
if P^.NeedParam then
begin
if (P^.Typ=ot_string) and (PStringItem(P)^.Multiple) then
begin
s:=PStringItem(P)^.Str[SwitchesMode];
repeat
i:=pos(';',s);
if i=0 then
i:=256;
s1:=Copy(s,1,i-1);
if s1<>'' then
writeln(CfgFile,' -'+Pref+P^.Param+s1);
Delete(s,1,i);
until s='';
end
begin
s:=PStringItem(P)^.Str[SwitchesMode];
repeat
i:=pos(';',s);
j:=pos(' ',s);
if i=0 then
i:=256;
if (j>0) and (j<i) then
i:=j;
s1:=Copy(s,1,i-1);
if s1<>'' then
writeln(CfgFile,' -'+Pref+P^.Param+s1);
Delete(s,1,i);
until s='';
end
else
Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue);
Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue);
end;
end;
@ -494,9 +497,9 @@ begin
if i=0 then i:=256;
writeln(CfgFile,' '+Copy(s,1,i-1));
if i=256 then
s:=''
s:=''
else
s:=copy(s,i+1,255);
s:=copy(s,i+1,255);
end;
end;
@ -507,7 +510,7 @@ function TSwitches.ReadItemsCfg(const s:string):boolean;
begin
{ empty items are not equivalent to others !! }
CheckItem:=((S='') and (P^.Param='')) or
((Length(S)>0) and (P^.Param=Copy(s,1,length(P^.Param))));
((Length(S)>0) and (P^.Param=Copy(s,1,length(P^.Param))));
end;
var
@ -521,12 +524,12 @@ begin
ot_Select : SelNr[SwitchesMode]:=Items^.IndexOf(FoundP);
ot_Boolean : PBooleanItem(FoundP)^.IsSet[SwitchesMode]:=true;
ot_String : begin
if (PStringItem(FoundP)^.Multiple) and (PStringItem(FoundP)^.Str[SwitchesMode]<>'') then
PStringItem(FoundP)^.Str[SwitchesMode]:=PStringItem(FoundP)^.Str[SwitchesMode]+';'+
Copy(s,length(FoundP^.Param)+1,255)
else
PStringItem(FoundP)^.Str[SwitchesMode]:=Copy(s,length(FoundP^.Param)+1,255);
end;
if (PStringItem(FoundP)^.Multiple) and (PStringItem(FoundP)^.Str[SwitchesMode]<>'') then
PStringItem(FoundP)^.Str[SwitchesMode]:=PStringItem(FoundP)^.Str[SwitchesMode]+';'+
Copy(s,length(FoundP^.Param)+1,255)
else
PStringItem(FoundP)^.Str[SwitchesMode]:=Copy(s,length(FoundP^.Param)+1,255);
end;
ot_Longint : Val(Copy(s,length(FoundP^.Param)+1,255),PLongintItem(FoundP)^.Val[SwitchesMode],code);
end;
ReadItemsCfg:=true;
@ -537,7 +540,7 @@ end;
{*****************************************************************************
Read / Write
Read / Write
*****************************************************************************}
procedure WriteSwitches(const fn:string);
@ -614,17 +617,17 @@ begin
'T' : res:=TargetSwitches^.ReadItemsCfg(s);
'R' : res:=AsmReaderSwitches^.ReadItemsCfg(s);
'C' : begin
res:=CodegenSwitches^.ReadItemsCfg(s);
if not res then
res:=MemorySwitches^.ReadItemsCfg(s);
end;
res:=CodegenSwitches^.ReadItemsCfg(s);
if not res then
res:=MemorySwitches^.ReadItemsCfg(s);
end;
'v' : res:=VerboseSwitches^.ReadItemsCfg(s);
'O' : begin
res:=true;
if not OptimizationSwitches^.ReadItemsCfg(s) then
if not ProcessorSwitches^.ReadItemsCfg(s) then
res:=OptimizingGoalSwitches^.ReadItemsCfg(s)
end;
res:=true;
if not OptimizationSwitches^.ReadItemsCfg(s) then
if not ProcessorSwitches^.ReadItemsCfg(s) then
res:=OptimizingGoalSwitches^.ReadItemsCfg(s)
end;
end;
{ keep all others as a string }
if not res then
@ -633,13 +636,13 @@ begin
else
if (Copy(s,1,7)='#IFDEF ') then
begin
Delete(s,1,7);
for i:=low(TSwitchMode) to high(TSwitchMode) do
if s=SwitchesModeStr[i] then
begin
SwitchesMode:=i;
break;
end;
Delete(s,1,7);
for i:=low(TSwitchMode) to high(TSwitchMode) do
if s=SwitchesModeStr[i] then
begin
SwitchesMode:=i;
break;
end;
end
else;
end;
@ -675,7 +678,7 @@ begin
end;
{*****************************************************************************
Initialize
Initialize
*****************************************************************************}
procedure InitSwitches;
@ -827,7 +830,10 @@ end;
end.
{
$Log$
Revision 1.9 1999-02-10 09:45:55 pierre
Revision 1.10 1999-02-16 12:46:38 pierre
* String items can also be separated by spaces
Revision 1.9 1999/02/10 09:45:55 pierre
* MemorySizeSwitches Removed (was duplicate of MemorySwitches !)
* Added missing disposes at exit