IDE: In all compiler options, allow one char options combined like -Criot.

git-svn-id: trunk@43804 -
This commit is contained in:
juha 2014-01-25 19:05:40 +00:00
parent d469043277
commit 0b9e3dcde4

View File

@ -135,6 +135,7 @@ type
private private
// List of options belonging to this group. // List of options belonging to this group.
fCompilerOpts: TCompilerOptList; fCompilerOpts: TCompilerOptList;
function OneCharOptions(aOptAndValue: string): TCompilerOpt;
protected protected
procedure ParseEditKind; override; procedure ParseEditKind; override;
public public
@ -630,10 +631,28 @@ begin
Result := FindOptionSub(Self); Result := FindOptionSub(Self);
end; end;
function TCompilerOptGroup.OneCharOptions(aOptAndValue: string): TCompilerOpt;
// Split and select option characters like in -Criot.
// Returns reference to the last option object if all characters were valid opts.
var
i: Integer;
OptBase: String;
begin
OptBase := Copy(aOptAndValue, 1, 2);
for i := 3 to Length(aOptAndValue) do
begin
Result := FindOption(OptBase + aOptAndValue[i]);
if Assigned(Result) then
Result.Value := 'True'
else
Exit(Nil);
end;
end;
function TCompilerOptGroup.SelectOption(aOptAndValue: string): Boolean; function TCompilerOptGroup.SelectOption(aOptAndValue: string): Boolean;
var var
Opt: TCompilerOpt; Opt: TCompilerOpt;
OptStr, Param: string; Param: string;
OptLen, ParamLen: integer; OptLen, ParamLen: integer;
begin begin
Opt := FindOption(aOptAndValue); Opt := FindOption(aOptAndValue);
@ -648,20 +667,23 @@ begin
OptLen := 2 OptLen := 2
else else
OptLen := 3; OptLen := 3;
OptStr := Copy(aOptAndValue, 1, OptLen);
ParamLen := Length(aOptAndValue) - OptLen; ParamLen := Length(aOptAndValue) - OptLen;
if (ParamLen > 0) Opt := Nil;
if (ParamLen > 1)
and (aOptAndValue[OptLen+1] in ['''', '"']) and (aOptAndValue[OptLen+1] in ['''', '"'])
and (aOptAndValue[Length(aOptAndValue)] in ['''', '"']) then and (aOptAndValue[Length(aOptAndValue)] in ['''', '"']) then
begin Param := Copy(aOptAndValue, OptLen+2, ParamLen-2) // Strip quotes
Inc(OptLen); // Strip quotes else begin
Dec(ParamLen, 2);
end;
Param := Copy(aOptAndValue, OptLen+1, ParamLen); Param := Copy(aOptAndValue, OptLen+1, ParamLen);
Opt := FindOption(OptStr); if OptLen = 3 then // Can contain one char options like -Criot. Can be combined.
Opt := OneCharOptions(aOptAndValue);
end;
if Opt = Nil then begin
Opt := FindOption(Copy(aOptAndValue, 1, OptLen));
if Assigned(Opt) then if Assigned(Opt) then
Opt.Value := Param; Opt.Value := Param;
end; end;
end;
Result := Assigned(Opt); Result := Assigned(Opt);
end; end;
@ -717,7 +739,7 @@ begin
Opt := TCompilerOpt(fCompilerOpts[i]); Opt := TCompilerOpt(fCompilerOpts[i]);
if Opt.Value <> '' then if Opt.Value <> '' then
case Opt.EditKind of case Opt.EditKind of
oeSetElem: s := s + Opt.Option; oeSetElem : s := s + Opt.Option;
oeSetNumber: s := s + Opt.Value; oeSetNumber: s := s + Opt.Value;
end; end;
end; end;