diff --git a/ide/compileroptions.pp b/ide/compileroptions.pp index 6ef76f5272..40e2cb608e 100644 --- a/ide/compileroptions.pp +++ b/ide/compileroptions.pp @@ -4275,25 +4275,48 @@ end; procedure TCompilationToolOptions.LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string; DoSwitchPathDelims: boolean); var - ParamList: TStringList; - Cmd, Param: String; - i: Integer; + Params: TStrings; + param, cmd: String; + p, p2, i, j: Integer; begin //debugln(['TCompilationToolOptions.LoadFromXMLConfig ',Command,' Path=',Path,' DoSwitchPathDelims=',DoSwitchPathDelims]); - Cmd:=XMLConfig.GetValue(Path+'Command/Value',''); - ParamList:=TStringList.Create; - try - SplitCmdLineParams(Cmd, ParamList); - for i:=0 to ParamList.Count-1 do - begin // Try to switch path delimiters only for filenames. - Param:=ParamList[i]; // Example: "cmd /C \\server\path\executable.exe" - if (Length(Param)<>2) or (Param[1]<>'/') then - ParamList[i]:=SwitchPathDelims(Param,DoSwitchPathDelims); + Command:=XMLConfig.GetValue(Path+'Command/Value',''); + if DoSwitchPathDelims then begin + if (Command<>'') + and (PathDelim='\') then begin + // specialhandling on windows to not switch path delimiters in options + Params:=TStringList.Create; + try + SplitCmdLineParams(Command,Params); + cmd:=SwitchPathDelims(Params[0],True); + for i:=1 to Params.Count-1 do begin + param:=Params[i]; + p:=-1; + p2:=-1; + for j:=1 to length(param) do + if p>1 then + break + else if param[j]='/' then + p:=j + else if param[j]=':' then + p2:=j; + if p=1 then + // param is option (the only / is at pos 1) + if p2<>-1 then + // potential filename after colon in option + cmd+=' '+copy(param,1,p2)+SwitchPathDelims(Copy(param,p2+1,length(param)-p2),True) + else + cmd+=' '+param + else + cmd+=' '+SwitchPathDelims(param,True); + end; + Command:=cmd; + finally + Params.Free; + end; + end else begin + Command:=SwitchPathDelims(Command,DoSwitchPathDelims); end; - ParamList.Delimiter:=' '; - Command:=ParamList.DelimitedText; - finally - ParamList.Free; end; LoadStringList(XMLConfig,Parsers,Path+'Parsers/'); if Parsers.Count=0 then begin