diff --git a/components/codetools/fileprocs.pas b/components/codetools/fileprocs.pas index eb087eb69a..6c2863fbd4 100644 --- a/components/codetools/fileprocs.pas +++ b/components/codetools/fileprocs.pas @@ -713,6 +713,7 @@ function TrimFilename(const AFilename: string): string; // and special dirs . and .. var SrcPos, DestPos, l, DirStart: integer; c: char; + MacroPos: LongInt; begin Result:=AFilename; if FilenameIsTrimmed(Result) then exit; @@ -766,6 +767,7 @@ begin // 5. \\.. -> skip .., keep \\ // 6. xxx../.. -> copy // 7. xxxdir/.. -> trim dir and skip .. + // 8. xxxdir/.. -> trim dir and skip .. if DestPos=1 then begin // 1. .. -> copy end else if (DestPos=2) and (Result[1]=PathDelim) then begin @@ -797,9 +799,20 @@ begin DirStart:=DestPos-2; while (DirStart>1) and (Result[DirStart-1]<>PathDelim) do dec(DirStart); - DestPos:=DirStart; - inc(SrcPos,2); - continue; + MacroPos:=DirStart; + while MacroPos keep + break; + end; + inc(MacroPos); + end; + if MacroPos=DestPos then begin + DestPos:=DirStart; + inc(SrcPos,2); + continue; + end; end; end; end; diff --git a/ideintf/helpfpdoc.pas b/ideintf/helpfpdoc.pas index 7bd48546dd..f7818ac586 100644 --- a/ideintf/helpfpdoc.pas +++ b/ideintf/helpfpdoc.pas @@ -63,6 +63,7 @@ var FPDocNode: THelpNode; p: LongInt; Dir: String; + NewDirHelp: THelpDBISourceDirectory; begin // create help database Result:=TFPDocHTMLHelpDatabase( @@ -85,8 +86,10 @@ begin Dir:=Trim(copy(AdditionalDirectories,1,p-1)); if Dir<>'' then begin FPDocNode:=THelpNode.CreateURL(Result,DBTitle+' '+Dir,'file://index.html'); - Result.RegisterItem(THelpDBISourceDirectory.Create(FPDocNode, - '$PkgDir('+PackageName+')'+Dir,'*.pp;*.pas',false)); + NewDirHelp:=THelpDBISourceDirectory.Create(FPDocNode, + '$PkgDir('+PackageName+')'+Dir,'*.pp;*.pas',false); + Result.RegisterItem(NewDirHelp); + //DebugLn(['RegisterFPDocHTMLHelpForPackage NewDirHelp.Filename="',NewDirHelp.Filename,'"']); end; System.Delete(AdditionalDirectories,1,p); end; diff --git a/lcl/include/fileutil.inc b/lcl/include/fileutil.inc index 4c92f199d6..4fc18576e6 100644 --- a/lcl/include/fileutil.inc +++ b/lcl/include/fileutil.inc @@ -199,6 +199,7 @@ function TrimFilename(const AFilename: string): string; var SrcPos, DestPos, l, DirStart: integer; c: char; + MacroPos: LongInt; begin Result:=AFilename; if FilenameIsTrimmed(Result) then exit; @@ -245,15 +246,16 @@ begin and (SrcPos+1=l) or (AFilename[SrcPos+2]=PathDelim) then begin // special dir .. - // 1. .. -> copy + // 1. .. -> keep // 2. /.. -> skip .., keep / - // 3. C:.. -> copy + // 3. C:.. -> keep // 4. C:\.. -> skip .., keep C:\ // 5. \\.. -> skip .., keep \\ - // 6. xxx../.. -> copy - // 7. xxxdir/.. -> trim dir and skip .. + // 6. xxx../.. -> keep + // 7. xxxdir$Macro/.. -> keep + // 8. xxxdir/.. -> trim dir and skip .. if DestPos=1 then begin - // 1. .. -> copy + // 1. .. -> keep end else if (DestPos=2) and (Result[1]=PathDelim) then begin // 2. /.. -> skip .., keep / inc(SrcPos,2); @@ -261,7 +263,7 @@ begin {$IFDEF WINDOWS} end else if (DestPos=3) and (Result[2]=':') and (Result[1] in ['a'..'z','A'..'Z']) then begin - // 3. C:.. -> copy + // 3. C:.. -> keep end else if (DestPos=4) and (Result[2]=':') and (Result[3]=PathDelim) and (Result[1] in ['a'..'z','A'..'Z']) then begin // 4. C:\.. -> skip .., keep C:\ @@ -277,15 +279,26 @@ begin if (DestPos>3) and (Result[DestPos-2]='.') and (Result[DestPos-3]='.') and ((DestPos=4) or (Result[DestPos-4]=PathDelim)) then begin - // 6. ../.. -> copy + // 6. ../.. -> keep end else begin // 7. xxxdir/.. -> trim dir and skip .. DirStart:=DestPos-2; while (DirStart>1) and (Result[DirStart-1]<>PathDelim) do dec(DirStart); - DestPos:=DirStart; - inc(SrcPos,2); - continue; + MacroPos:=DirStart; + while MacroPos keep + break; + end; + inc(MacroPos); + end; + if MacroPos=DestPos then begin + DestPos:=DirStart; + inc(SrcPos,2); + continue; + end; end; end; end;