mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 22:59:07 +02:00
TrimFilename no longer reduces $Macro/.. directories
git-svn-id: trunk@9967 -
This commit is contained in:
parent
64efecbebf
commit
75077b39c2
@ -713,6 +713,7 @@ function TrimFilename(const AFilename: string): string;
|
|||||||
// and special dirs . and ..
|
// and special dirs . and ..
|
||||||
var SrcPos, DestPos, l, DirStart: integer;
|
var SrcPos, DestPos, l, DirStart: integer;
|
||||||
c: char;
|
c: char;
|
||||||
|
MacroPos: LongInt;
|
||||||
begin
|
begin
|
||||||
Result:=AFilename;
|
Result:=AFilename;
|
||||||
if FilenameIsTrimmed(Result) then exit;
|
if FilenameIsTrimmed(Result) then exit;
|
||||||
@ -766,6 +767,7 @@ begin
|
|||||||
// 5. \\.. -> skip .., keep \\
|
// 5. \\.. -> skip .., keep \\
|
||||||
// 6. xxx../.. -> copy
|
// 6. xxx../.. -> copy
|
||||||
// 7. xxxdir/.. -> trim dir and skip ..
|
// 7. xxxdir/.. -> trim dir and skip ..
|
||||||
|
// 8. xxxdir/.. -> trim dir and skip ..
|
||||||
if DestPos=1 then begin
|
if DestPos=1 then begin
|
||||||
// 1. .. -> copy
|
// 1. .. -> copy
|
||||||
end else if (DestPos=2) and (Result[1]=PathDelim) then begin
|
end else if (DestPos=2) and (Result[1]=PathDelim) then begin
|
||||||
@ -797,9 +799,20 @@ begin
|
|||||||
DirStart:=DestPos-2;
|
DirStart:=DestPos-2;
|
||||||
while (DirStart>1) and (Result[DirStart-1]<>PathDelim) do
|
while (DirStart>1) and (Result[DirStart-1]<>PathDelim) do
|
||||||
dec(DirStart);
|
dec(DirStart);
|
||||||
DestPos:=DirStart;
|
MacroPos:=DirStart;
|
||||||
inc(SrcPos,2);
|
while MacroPos<DestPos do begin
|
||||||
continue;
|
if (Result[MacroPos]='$')
|
||||||
|
and (Result[MacroPos+1] in ['(','a'..'z','A'..'Z']) then begin
|
||||||
|
// 8. directory contains a macro -> keep
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
inc(MacroPos);
|
||||||
|
end;
|
||||||
|
if MacroPos=DestPos then begin
|
||||||
|
DestPos:=DirStart;
|
||||||
|
inc(SrcPos,2);
|
||||||
|
continue;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -63,6 +63,7 @@ var
|
|||||||
FPDocNode: THelpNode;
|
FPDocNode: THelpNode;
|
||||||
p: LongInt;
|
p: LongInt;
|
||||||
Dir: String;
|
Dir: String;
|
||||||
|
NewDirHelp: THelpDBISourceDirectory;
|
||||||
begin
|
begin
|
||||||
// create help database
|
// create help database
|
||||||
Result:=TFPDocHTMLHelpDatabase(
|
Result:=TFPDocHTMLHelpDatabase(
|
||||||
@ -85,8 +86,10 @@ begin
|
|||||||
Dir:=Trim(copy(AdditionalDirectories,1,p-1));
|
Dir:=Trim(copy(AdditionalDirectories,1,p-1));
|
||||||
if Dir<>'' then begin
|
if Dir<>'' then begin
|
||||||
FPDocNode:=THelpNode.CreateURL(Result,DBTitle+' '+Dir,'file://index.html');
|
FPDocNode:=THelpNode.CreateURL(Result,DBTitle+' '+Dir,'file://index.html');
|
||||||
Result.RegisterItem(THelpDBISourceDirectory.Create(FPDocNode,
|
NewDirHelp:=THelpDBISourceDirectory.Create(FPDocNode,
|
||||||
'$PkgDir('+PackageName+')'+Dir,'*.pp;*.pas',false));
|
'$PkgDir('+PackageName+')'+Dir,'*.pp;*.pas',false);
|
||||||
|
Result.RegisterItem(NewDirHelp);
|
||||||
|
//DebugLn(['RegisterFPDocHTMLHelpForPackage NewDirHelp.Filename="',NewDirHelp.Filename,'"']);
|
||||||
end;
|
end;
|
||||||
System.Delete(AdditionalDirectories,1,p);
|
System.Delete(AdditionalDirectories,1,p);
|
||||||
end;
|
end;
|
||||||
|
@ -199,6 +199,7 @@ function TrimFilename(const AFilename: string): string;
|
|||||||
|
|
||||||
var SrcPos, DestPos, l, DirStart: integer;
|
var SrcPos, DestPos, l, DirStart: integer;
|
||||||
c: char;
|
c: char;
|
||||||
|
MacroPos: LongInt;
|
||||||
begin
|
begin
|
||||||
Result:=AFilename;
|
Result:=AFilename;
|
||||||
if FilenameIsTrimmed(Result) then exit;
|
if FilenameIsTrimmed(Result) then exit;
|
||||||
@ -245,15 +246,16 @@ begin
|
|||||||
and (SrcPos+1=l) or (AFilename[SrcPos+2]=PathDelim) then
|
and (SrcPos+1=l) or (AFilename[SrcPos+2]=PathDelim) then
|
||||||
begin
|
begin
|
||||||
// special dir ..
|
// special dir ..
|
||||||
// 1. .. -> copy
|
// 1. .. -> keep
|
||||||
// 2. /.. -> skip .., keep /
|
// 2. /.. -> skip .., keep /
|
||||||
// 3. C:.. -> copy
|
// 3. C:.. -> keep
|
||||||
// 4. C:\.. -> skip .., keep C:\
|
// 4. C:\.. -> skip .., keep C:\
|
||||||
// 5. \\.. -> skip .., keep \\
|
// 5. \\.. -> skip .., keep \\
|
||||||
// 6. xxx../.. -> copy
|
// 6. xxx../.. -> keep
|
||||||
// 7. xxxdir/.. -> trim dir and skip ..
|
// 7. xxxdir$Macro/.. -> keep
|
||||||
|
// 8. xxxdir/.. -> trim dir and skip ..
|
||||||
if DestPos=1 then begin
|
if DestPos=1 then begin
|
||||||
// 1. .. -> copy
|
// 1. .. -> keep
|
||||||
end else if (DestPos=2) and (Result[1]=PathDelim) then begin
|
end else if (DestPos=2) and (Result[1]=PathDelim) then begin
|
||||||
// 2. /.. -> skip .., keep /
|
// 2. /.. -> skip .., keep /
|
||||||
inc(SrcPos,2);
|
inc(SrcPos,2);
|
||||||
@ -261,7 +263,7 @@ begin
|
|||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
end else if (DestPos=3) and (Result[2]=':')
|
end else if (DestPos=3) and (Result[2]=':')
|
||||||
and (Result[1] in ['a'..'z','A'..'Z']) then begin
|
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)
|
end else if (DestPos=4) and (Result[2]=':') and (Result[3]=PathDelim)
|
||||||
and (Result[1] in ['a'..'z','A'..'Z']) then begin
|
and (Result[1] in ['a'..'z','A'..'Z']) then begin
|
||||||
// 4. C:\.. -> skip .., keep C:\
|
// 4. C:\.. -> skip .., keep C:\
|
||||||
@ -277,15 +279,26 @@ begin
|
|||||||
if (DestPos>3)
|
if (DestPos>3)
|
||||||
and (Result[DestPos-2]='.') and (Result[DestPos-3]='.')
|
and (Result[DestPos-2]='.') and (Result[DestPos-3]='.')
|
||||||
and ((DestPos=4) or (Result[DestPos-4]=PathDelim)) then begin
|
and ((DestPos=4) or (Result[DestPos-4]=PathDelim)) then begin
|
||||||
// 6. ../.. -> copy
|
// 6. ../.. -> keep
|
||||||
end else begin
|
end else begin
|
||||||
// 7. xxxdir/.. -> trim dir and skip ..
|
// 7. xxxdir/.. -> trim dir and skip ..
|
||||||
DirStart:=DestPos-2;
|
DirStart:=DestPos-2;
|
||||||
while (DirStart>1) and (Result[DirStart-1]<>PathDelim) do
|
while (DirStart>1) and (Result[DirStart-1]<>PathDelim) do
|
||||||
dec(DirStart);
|
dec(DirStart);
|
||||||
DestPos:=DirStart;
|
MacroPos:=DirStart;
|
||||||
inc(SrcPos,2);
|
while MacroPos<DestPos do begin
|
||||||
continue;
|
if (Result[MacroPos]='$')
|
||||||
|
and (Result[MacroPos+1] in ['(','a'..'z','A'..'Z']) then begin
|
||||||
|
// 8. directory contains a macro -> keep
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
inc(MacroPos);
|
||||||
|
end;
|
||||||
|
if MacroPos=DestPos then begin
|
||||||
|
DestPos:=DirStart;
|
||||||
|
inc(SrcPos,2);
|
||||||
|
continue;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user