aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGuillaume Melquiond2015-12-14 10:44:22 +0100
committerGuillaume Melquiond2015-12-14 10:44:22 +0100
commitd58957f63d36e2da41f6f839a2d94cb0db4c8125 (patch)
tree884b79ab00b0b914a4fa2c3335491927eaf86a17 /tools
parent7ae0748586fe8291f0666cce7bd39d7109471d08 (diff)
Remove some occurrences of Unix.opendir.
Diffstat (limited to 'tools')
-rw-r--r--tools/coqdep_common.ml5
-rw-r--r--tools/ocamllibdep.mll25
2 files changed, 9 insertions, 21 deletions
diff --git a/tools/coqdep_common.ml b/tools/coqdep_common.ml
index 221f3406b9..b66529bb38 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 4e5edcf6c2..1bcbe7c0e8 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;