mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 20:50:18 +02:00
lazutils: TrimFilename: optimized
git-svn-id: trunk@43403 -
This commit is contained in:
parent
73a2ef1ce7
commit
b4a999be14
@ -559,15 +559,17 @@ var
|
||||
begin
|
||||
Result := AFileName;
|
||||
Len := Length(AFileName);
|
||||
if (Len > 0) and not FilenameIsTrimmed(Result) then
|
||||
if (Len = 0) or FilenameIsTrimmed(Result) then exit;
|
||||
if AFilename[1] = #32 then
|
||||
begin
|
||||
Start := 1;
|
||||
while (Len > 0) and (AFileName[Len] = #32) do Dec(Len);
|
||||
while (Start <= Len) and (AFilename[Start] = #32) do Inc(Start);
|
||||
if Start > 1 then System.Delete(Result,1,Start-1);
|
||||
SetLength(Result, Len - (Start - 1));
|
||||
Result := ResolveDots(Result);
|
||||
System.Delete(Result,1,Start-1);
|
||||
Len := Length(AFileName);
|
||||
end;
|
||||
while (Len > 0) and (AFileName[Len] = #32) do Dec(Len);
|
||||
SetLength(Result, Len);
|
||||
Result := ResolveDots(Result);
|
||||
end;
|
||||
|
||||
procedure ForcePathDelims(var FileName: string);
|
||||
|
Loading…
Reference in New Issue
Block a user