From: Ronan Desplanques Date: Tue, 19 Sep 2023 07:45:16 +0000 (+0200) Subject: ada: Fix filesystem entry filtering X-Git-Tag: basepoints/gcc-15~5608 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34992e156b6a4d737440e675b86cd2f8ac103363;p=thirdparty%2Fgcc.git ada: Fix filesystem entry filtering This patch fixes the behavior of Ada.Directories.Search when being requested to filter out regular files or directories. One of the configurations in which that behavior was incorrect was that when the caller requested only the regular and special files but not the directories, the directories would still be returned. gcc/ada/ * libgnat/a-direct.adb: Fix filesystem entry filtering. --- diff --git a/gcc/ada/libgnat/a-direct.adb b/gcc/ada/libgnat/a-direct.adb index 4b08d41337dd..f7a1d5dfd6d6 100644 --- a/gcc/ada/libgnat/a-direct.adb +++ b/gcc/ada/libgnat/a-direct.adb @@ -1414,24 +1414,26 @@ package body Ada.Directories is elsif Exists = 1 then if Is_Regular_File_Attr (Path_C'Address, Attr'Access) = 1 - and then Filter (Ordinary_File) then - Found := True; - Kind := Ordinary_File; - Size := - File_Size - (File_Length_Attr - (-1, Path_C'Address, Attr'Access)); + if Filter (Ordinary_File) then + Found := True; + Kind := Ordinary_File; + Size := + File_Size + (File_Length_Attr + (-1, Path_C'Address, Attr'Access)); + end if; elsif Is_Directory_Attr (Path_C'Address, Attr'Access) = 1 - and then Filter (File_Kind'First) then - Found := True; - Kind := File_Kind'First; - -- File_Kind'First is used instead of Directory due - -- to a name overload issue with the procedure - -- parameter Directory. - Size := 0; + if Filter (File_Kind'First) then + Found := True; + Kind := File_Kind'First; + -- File_Kind'First is used instead of Directory due + -- to a name overload issue with the procedure + -- parameter Directory. + Size := 0; + end if; elsif Filter (Special_File) then Found := True;