gcc/ada/
* libgnat/g-diopit.adb (Find): Fix possible infinite recursion
in Find iterator.
* libgnat/g-diopit.ads (Find): Update comments accordingly.
with Ada.Characters.Handling;
with Ada.Strings.Fixed;
with Ada.Strings.Maps;
+
with GNAT.OS_Lib;
with GNAT.Regexp;
is
File_Regexp : constant Regexp.Regexp := Regexp.Compile (File_Pattern);
Index : Natural := 0;
- Quit : Boolean;
+ Quit : Boolean := False;
procedure Read_Directory (Directory : Dir_Name_Str);
-- Open Directory and read all entries. This routine is called
if not (Dir_Entry = "." or else Dir_Entry = "..")
and then OS_Lib.Is_Directory (Pathname)
+ and then not OS_Lib.Is_Symbolic_Link (Pathname)
then
Read_Directory (Pathname);
exit when Quit;
end Read_Directory;
begin
- Quit := False;
Read_Directory (Root_Directory);
end Find;
-- will pass in the value False on each call to Action. The iterator will
-- terminate after passing the last matched path to Action or after
-- returning from a call to Action which sets Quit to True.
+ -- The iterator does not follow symbolic links avoiding possible
+ -- circularities or exploring unrelated directories.
-- Raises GNAT.Regexp.Error_In_Regexp if File_Pattern is ill formed.
generic