This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix bug in GNAT.Directory_Operations


Tested on i686-linux, committed on trunk

GNAT.Directory_Operations.Iteration.Find will only stop the
parsing of the current sub-directory when Quit callback parameter
is set to False. The iterator will continue to parse the parent
directory. This patch make sure that we properly quit the iteration.
The following program:
--
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with GNAT.Directory_Operations.Iteration;
with Ada.Text_IO; use Ada.Text_IO;
procedure Tdir is
   procedure Print_Entry (S     : in     String;
                          Index : in     Positive;
                          Quit  : in out Boolean)
   is
   begin
     Put_Line (Index'Img & ": " & S);
     if Index = 3 then
        Quit := True;
     end if;
   end Print_Entry;
   procedure PF is new Iteration.Find (Print_Entry);
begin
   PF ("dir", "dir");
end Tdir;
--
Called on a directory structure like this:
   dir
    |_ dir
    |    |_ dir
    |         |_ dir
    |              |_ toto
    |         |_ tutu
    |    |_ titi
    |_ dir2
    |_ toto
--
Must output:
 1: dir/dir
 2: dir/dir/dir
 3: dir/dir/dir/dir

2005-12-05  Pascal Obry  <obry@adacore.com>

	* g-diopit.adb (Find): Fix test to exit the iterator and make sure that
	the iterator is quitting iteration on parent directory.

Attachment: difs.11
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]