aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/system.ml4
-rw-r--r--tools/coqdep_common.ml5
-rw-r--r--tools/ocamllibdep.mll25
3 files changed, 10 insertions, 24 deletions
diff --git a/lib/system.ml b/lib/system.ml
index b57c02a14..b641aad91 100644
--- a/lib/system.ml
+++ b/lib/system.ml
@@ -64,9 +64,7 @@ let apply_subdir f path name =
| _ -> ()
let process_directory f path =
- let dirh = Unix.opendir path in
- try while true do apply_subdir f path (Unix.readdir dirh) done
- with End_of_file -> Unix.closedir dirh
+ Array.iter (apply_subdir f path) (Sys.readdir path)
let process_subdirectories f path =
let f = function FileDir (path,base) -> f path base | FileRegular _ -> () in
diff --git a/tools/coqdep_common.ml b/tools/coqdep_common.ml
index 221f3406b..b66529bb3 100644
--- a/tools/coqdep_common.ml
+++ b/tools/coqdep_common.ml
@@ -574,15 +574,12 @@ let rec treat_file old_dirname old_name =
match try (stat complete_name).st_kind with _ -> S_BLK with
| S_DIR ->
(if name.[0] <> '.' then
- let dir=opendir complete_name in
let newdirname =
match dirname with
| None -> name
| Some d -> d//name
in
- try
- while true do treat_file (Some newdirname) (readdir dir) done
- with End_of_file -> closedir dir)
+ Array.iter (treat_file (Some newdirname)) (Sys.readdir complete_name))
| S_REG ->
(match get_extension name [".v";".ml";".mli";".ml4";".mllib";".mlpack"] with
| (base,".v") ->
diff --git a/tools/ocamllibdep.mll b/tools/ocamllibdep.mll
index 4e5edcf6c..1bcbe7c0e 100644
--- a/tools/ocamllibdep.mll
+++ b/tools/ocamllibdep.mll
@@ -98,23 +98,14 @@ let file_name s = function
type dir = string option
-(* Visits all the directories under [dir], including [dir],
- or just [dir] if [recur=false] *)
-
-let rec add_directory add_file phys_dir =
- let dirh = opendir phys_dir in
- try
- while true do
- let f = readdir dirh in
- (* we avoid all files and subdirs starting by '.' (e.g. .svn),
- plus CVS and _darcs and any subdirs given via -exclude-dirs *)
- if f.[0] <> '.' then
- let phys_f = if phys_dir = "." then f else phys_dir//f in
- match try (stat phys_f).st_kind with _ -> S_BLK with
- | S_REG -> add_file phys_dir f
- | _ -> ()
- done
- with End_of_file -> closedir dirh
+let add_directory add_file phys_dir =
+ Array.iter (fun f ->
+ (* we avoid all files starting by '.' *)
+ if f.[0] <> '.' then
+ let phys_f = if phys_dir = "." then f else phys_dir//f in
+ match try (stat phys_f).st_kind with _ -> S_BLK with
+ | S_REG -> add_file phys_dir f
+ | _ -> ()) (Sys.readdir phys_dir)
let error_cannot_parse s (i,j) =
Printf.eprintf "File \"%s\", characters %i-%i: Syntax error\n" s i j;