[Ada] Fix possible infinite recursion in directory iterator
gcc/ada/ * libgnat/g-diopit.adb (Find): Fix possible infinite recursion in Find iterator. * libgnat/g-diopit.ads (Find): Update comments accordingly.
This commit is contained in:
parent
afed612dc5
commit
3a6021dc1d
2 changed files with 5 additions and 2 deletions
|
@ -32,6 +32,7 @@
|
|||
with Ada.Characters.Handling;
|
||||
with Ada.Strings.Fixed;
|
||||
with Ada.Strings.Maps;
|
||||
|
||||
with GNAT.OS_Lib;
|
||||
with GNAT.Regexp;
|
||||
|
||||
|
@ -49,7 +50,7 @@ package body GNAT.Directory_Operations.Iteration is
|
|||
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
|
||||
|
@ -113,6 +114,7 @@ package body GNAT.Directory_Operations.Iteration is
|
|||
|
||||
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;
|
||||
|
@ -124,7 +126,6 @@ package body GNAT.Directory_Operations.Iteration is
|
|||
end Read_Directory;
|
||||
|
||||
begin
|
||||
Quit := False;
|
||||
Read_Directory (Root_Directory);
|
||||
end Find;
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ package GNAT.Directory_Operations.Iteration is
|
|||
-- 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
|
||||
|
|
Loading…
Add table
Reference in a new issue