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 Wildcard_Iterator


Tested on i686-linux, committed on mainline.

Fix the case when Path passed to Wildcard_Iterator
is starting with a "/". Indeed the following program was always outputing
nothing:

with Ada.Text_IO;
with GNAT.Directory_Operations.Iteration;

procedure Wildcardexpansion is
   procedure Action
     (Item  : in     String;
      Index : in     Positive;
      Quit  : in out Boolean)
   is
   begin
      Ada.Text_IO.Put_Line(Item);
   end Action;

   procedure Expander is new
     GNAT.Directory_Operations.Iteration.Wildcard_Iterator(Action);
begin
   Expander("/*");
end Wildcardexpansion;

This checkin fix the case when the argument of Wildcard_Iterator is a null
string. Indeed the following program was raising a Constraint_Error:

procedure Wildcardexpansion is
   procedure Action
     (Item  : in     String;
      Index : in     Positive;
      Quit  : in out Boolean)
   is
   begin
      Ada.Text_IO.Put_Line(Item);
   end Action;

   procedure Expander is new
     GNAT.Directory_Operations.Iteration.Wildcard_Iterator(Action);
begin
   Expander("");
end Wildcardexpansion;

The expected behavior is that the procedure does nothing in this case. The
issue has been fixed by testing at the beginning of Wildcard_Iterator if
Path equals "". In this case the procedure returns directly.

2005-06-14  Nicolas Roche  <roche@adacore.com>

	* g-diopit.adb (Wildcard_Iterator): Return directly if Path is equal
	to ""
	(Next_Level): Fix minor bug in handling of ../dir case
	(Read): Add dir separator to Directory name so that "" is understood as
	 "/"

Attachment: difs.29
Description: Text document


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