[SOLVED] Code cleanup at function ExtractFileExt lazarus / 64-FPC development ---------------------------------------------------------------------- lagprogramming · 2024-01-06 14:46 rtl/objpas/sysutils/fina.inc has Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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:=AllowDirectoryS eparators+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. The following patch removes the "else" part making the function become: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i 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:=AllowDirectoryS eparators+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;end; ---------------------------------------------------------------------- AlexTP · 2024-01-06 18:08 Posted: https://gitlab.com/freepascal.org/fpc/source/-/issues/40587