aboutsummaryrefslogtreecommitdiff
path: root/lib/system.ml
diff options
context:
space:
mode:
authorEnrico Tassi2014-09-08 11:36:44 +0200
committerEnrico Tassi2014-09-09 13:11:38 +0200
commit4d601a87b775529b7d516fa213c688b6ecf5246d (patch)
tree0f6f2c716f3bbb8cf25032b30e4af42a223ded69 /lib/system.ml
parent938dd9ba81d0bba5a9358627405d3110fc4ee335 (diff)
toploop plugins taken into account when printing --help (close: 3535)
E.g. Coq options are: -I dir look for ML files in dir -include dir (idem) [...] -h, --help print this list of options With the flag '-toploop coqidetop' these extra option are also available: --help-XML-protocol print the documentation of the XML protocol used by CoqIDE
Diffstat (limited to 'lib/system.ml')
-rw-r--r--lib/system.ml26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/system.ml b/lib/system.ml
index 511b84ab4b..a2f339b1d3 100644
--- a/lib/system.ml
+++ b/lib/system.ml
@@ -53,14 +53,12 @@ let all_subdirs ~unix_path:root =
if exists_dir root then traverse root [];
List.rev !l
+let rec search paths test =
+ match paths with
+ | [] -> []
+ | lpe :: rem -> test lpe @ search rem test
+
let where_in_path ?(warn=true) path filename =
- let rec search = function
- | lpe :: rem ->
- let f = Filename.concat lpe filename in
- if Sys.file_exists f
- then (lpe,f) :: search rem
- else search rem
- | [] -> [] in
let check_and_warn l = match l with
| [] -> raise Not_found
| (lpe, f) :: l' ->
@@ -77,7 +75,19 @@ let where_in_path ?(warn=true) path filename =
in
(lpe, f)
in
- check_and_warn (search path)
+ check_and_warn (search path (fun lpe ->
+ let f = Filename.concat lpe filename in
+ if Sys.file_exists f then [lpe,f] else []))
+
+let where_in_path_rex path rex =
+ search path (fun lpe ->
+ let files = Sys.readdir lpe in
+ CList.map_filter (fun name ->
+ try
+ ignore(Str.search_forward rex name 0);
+ Some (lpe,Filename.concat lpe name)
+ with Not_found -> None)
+ (Array.to_list files))
let find_file_in_path ?(warn=true) paths filename =
if not (Filename.is_implicit filename) then