codetools: searching compiler: search first in dir of fpc.exe, then in PATH

git-svn-id: trunk@37262 -
This commit is contained in:
mattias 2012-05-13 08:31:43 +00:00
parent 3cc9256141
commit 5a6462019e
3 changed files with 50 additions and 14 deletions

View File

@ -340,6 +340,7 @@ function ReadTilPascalBracketClose(const Source: string;
function GetAtomLength(p: PChar; NestedComments: boolean): integer;
function GetAtomString(p: PChar; NestedComments: boolean): string;
function FindStartOfAtom(const Source: string; Position: integer): integer;
function FindEndOfAtom(const Source: string; Position: integer): integer;
//-----------------------------------------------------------------------------
@ -2233,9 +2234,10 @@ begin
else
inc(p);
c2:=p^;
// test for double char operators :=, +=, -=, /=, *=, <>, <=, >=, **
// test for double char operators :=, +=, -=, /=, *=, <>, <=, >=, **, .., ><
if ((c2='=') and (IsEqualOperatorStartChar[c1]))
or ((c1='<') and (c2='>'))
or ((c1='>') and (c2='<'))
or ((c1='.') and (c2='.'))
or ((c1='*') and (c2='*'))
then
@ -2345,6 +2347,9 @@ begin
'$':
// hex number
dec(Result);
'&':
// &keyword
dec(Result);
end;
break;
end;
@ -2455,7 +2460,7 @@ begin
else
if Result>1 then begin
c2:=Source[Result-1];
// test for double char operators :=, +=, -=, /=, *=, <>, <=, >=, **, ><
// test for double char operators :=, +=, -=, /=, *=, <>, <=, >=, **, ><, ..
if ((c2='=') and (IsEqualOperatorStartChar[c]))
or ((c='<') and (c2='>'))
or ((c='>') and (c2='<'))
@ -2469,6 +2474,23 @@ begin
end;
end;
function FindEndOfAtom(const Source: string; Position: integer): integer;
var
p: PChar;
begin
Result:=FindStartOfAtom(Source,Position);
if (Result>=1) and (Result<=length(Source)) then begin
p:=@Source[Result];
case p^ of
#0..#31,' ': exit;
'{': exit;
'/': if p[1]='/' then exit;
'(': if p[1]='*' then exit;
end;
inc(Result,GetAtomLength(p,false));
end;
end;
function LineEndCount(const Txt: string;
out LengthOfLastLine: integer): integer;
begin

View File

@ -7265,15 +7265,22 @@ function TFPCTargetConfigCache.FindRealCompilerInPath(aTargetCPU: string;
function Search(const ShortFileName: string): string;
begin
if ShortFileName='' then Result:='';
// try in PATH
// fpc.exe first searches in -XP
// Maybe: extact -XP from extra options
// then fpc.exe searches in its own directory
if Compiler<>'' then begin
Result:=ExtractFilePath(Compiler);
if FilenameIsAbsolute(Result) then begin
Result+=ShortFileName;
if FileExistsCached(Result) then
exit;
end;
end;
// finally fpc.exe searches in PATH
Result:=SearchFileInPath(ShortFileName,GetCurrentDirUTF8,
GetEnvironmentVariableUTF8('PATH'),PathSeparator,ctsfcDefault);
if (Result<>'') or (Compiler='') then exit;
// try in directory of compiler
Result:=ExtractFilePath(Compiler)+ShortFileName;
if not FileExistsCached(Result) then
Result:='';
end;
var

View File

@ -41,16 +41,16 @@ type
procedure FreeNodeData;
end;
procedure FreeTVNodeData(TV: TCustomTreeView);
implementation
{ TCodyTreeView }
procedure TCodyTreeView.FreeNodeData;
procedure FreeTVNodeData(TV: TCustomTreeView);
var
Node: TTreeNode;
begin
BeginUpdate;
Node:=Items.GetFirstNode;
TV.BeginUpdate;
Node:=TV.Items.GetFirstNode;
while Node<>nil do begin
if Node.Data<>nil then begin
TObject(Node.Data).Free;
@ -58,7 +58,14 @@ begin
end;
Node:=Node.GetNext;
end;
EndUpdate;
TV.EndUpdate;
end;
{ TCodyTreeView }
procedure TCodyTreeView.FreeNodeData;
begin
FreeTVNodeData(Self);
end;
end.