Skip to content

Code cleanup at function ExtractFileExt

from 'lagprogramming'.

rtl/objpas/sysutils/fina.inc has

    function ExtractFileExt(const FileName: PathStr): PathStr;
    var
      i : longint;
      EndSep : Set of AnsiChar;
      SOF : Boolean; // Dot at Start of filename ?
     
    begin
      Result:='';
      I := Length(FileName);
      EndSep:=AllowDirectorySeparators+AllowDriveSeparators+[ExtensionSeparator];
      while (I > 0) and not CharInSet(FileName[I],EndSep) do
        Dec(I);
      if (I > 0) and (FileName[I] = ExtensionSeparator) then
        begin
              SOF:=(I=1) or (FileName[i-1] in AllowDirectorySeparators);
              if (Not SOF) or FirstDotAtFileNameStartIsExtension then
                Result := Copy(FileName, I, MaxInt);
              end
      else
        Result := '';
    end;

In addition to the initial Result:=''; line, the function has a redundant empty string assignment at the "else" part.

patch.diff

Edited by Alexey Torgashin
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information