IDE: TrimSearchPath deleting doubles

git-svn-id: trunk@28650 -
This commit is contained in:
mattias 2010-12-08 20:50:27 +00:00
parent e558b5e009
commit 777e1a450c
6 changed files with 24 additions and 16 deletions

View File

@ -948,7 +948,7 @@ var
IgnoreAll: Boolean;
begin
Result:=mrOk;
UnitPath:=TrimSearchPath(TheUnitPath,BaseDir);
UnitPath:=TrimSearchPath(TheUnitPath,BaseDir,true);
SourceUnitTree:=TAVLTree.Create(TListSortCompare(@CompareUnitFiles));
CompiledUnitTree:=TAVLTree.Create(TListSortCompare(@CompareUnitFiles));

View File

@ -1876,7 +1876,7 @@ procedure TfrmCompilerOptions.PathEditBtnExecuted(Sender: TObject);
BaseDir: String;
begin
BaseDir:=CompilerOpts.BaseDirectory;
ExpandedPath:=TrimSearchPath(NewPath,BaseDir);
ExpandedPath:=TrimSearchPath(NewPath,BaseDir,true);
Result:=CheckSearchPath(Context,ExpandedPath,ccomlHints);
end;

View File

@ -1678,9 +1678,12 @@ begin
end;
procedure TEnvironmentOptions.SetDebuggerSearchPath(const AValue: string);
var
NewValue: String;
begin
if FDebuggerSearchPath=AValue then exit;
FDebuggerSearchPath:=TrimSearchPath(AValue,'');
NewValue:=TrimSearchPath(AValue,'');
if FDebuggerSearchPath=NewValue then exit;
FDebuggerSearchPath:=NewValue;
end;
procedure TEnvironmentOptions.SetMakeFilename(const AValue: string);

View File

@ -464,7 +464,7 @@ procedure TCompilerPathOptionsFrame.PathEditBtnExecuted(Sender: TObject);
BaseDir: string;
begin
BaseDir := FCompilerOpts.BaseDirectory;
ExpandedPath := TrimSearchPath(NewPath, BaseDir);
ExpandedPath := TrimSearchPath(NewPath, BaseDir, true);
Result := CheckSearchPath(Context, ExpandedPath, ccomlHints);
end;

View File

@ -135,7 +135,8 @@ function FindFPCTool(const Executable, CompilerFilename: string): string;
procedure ResolveLinksInFileList(List: TStrings; RemoveDanglingLinks: Boolean);
// search paths
function TrimSearchPath(const SearchPath, BaseDirectory: string): string;
function TrimSearchPath(const SearchPath, BaseDirectory: string;
DeleteDoubles: boolean = false): string;
function MergeSearchPaths(const OldSearchPath, AddSearchPath: string): string;
procedure MergeSearchPaths(SearchPath: TStrings; const AddSearchPath: string);
function RemoveSearchPaths(const SearchPath, RemoveSearchPath: string): string;
@ -1345,7 +1346,8 @@ end;
- If BaseDirectory<>'' then every relative Filename will be expanded.
- removes doubles
-------------------------------------------------------------------------------}
function TrimSearchPath(const SearchPath, BaseDirectory: string): string;
function TrimSearchPath(const SearchPath, BaseDirectory: string;
DeleteDoubles: boolean): string;
var
CurPath: String;
EndPos: Integer;
@ -1371,15 +1373,18 @@ begin
if (BaseDir<>'') and (not FilenameIsAbsolute(CurPath)) then
CurPath:=BaseDir+CurPath;
CurPath:=ChompPathDelim(TrimFilename(CurPath));
if CurPath='' then CurPath:='.';
// check if path already exists
// ToDo:
if Result<>'' then
CurPath:=';'+CurPath;
if CurPath<>'' then
Result:=Result+CurPath
else
Result:=Result+'.';
if (not DeleteDoubles)
or (SearchDirectoryInSearchPath(SearchPath,CurPath)<1)
then begin
if Result<>'' then
CurPath:=';'+CurPath;
if CurPath<>'' then
Result:=Result+CurPath
else
Result:=Result+'.';
end;
end;
end;
end;

View File

@ -1401,7 +1401,7 @@ begin
AlreadySearchedPaths:=MergeSearchPaths(AlreadySearchedPaths,FullDir);
// search with include path of directory
if Assigned(OnGetIncludePath) then begin
IncludePath:=TrimSearchPath(OnGetIncludePath(FullDir,false),FullDir);
IncludePath:=TrimSearchPath(OnGetIncludePath(FullDir,false),FullDir,true);
IncludePath:=RemoveSearchPaths(IncludePath,AlreadySearchedIncPaths);
if IncludePath<>'' then begin
Result:=SearchFileInPath(ShortIncFilename,FullDir,IncludePath,';',[]);