Commit 7d8f58e4 authored by François Bobot's avatar François Bobot

autodetection: version_ok, version_bad, version_old can be a regexp. regexp must start with ^

parent 48685ba9
...@@ -44,6 +44,8 @@ the version is old (version_old). ...@@ -44,6 +44,8 @@ the version is old (version_old).
The field command can be missing in a block, in that case the block The field command can be missing in a block, in that case the block
defines a version known to be buggy: no prover config is generated. defines a version known to be buggy: no prover config is generated.
The regexp must start with ^.
*) *)
open Format open Format
...@@ -66,9 +68,9 @@ type prover_autodetection_data = ...@@ -66,9 +68,9 @@ type prover_autodetection_data =
execs : string list; execs : string list;
version_switch : string; version_switch : string;
version_regexp : string; version_regexp : string;
versions_ok : string list; versions_ok : Str.regexp list;
versions_old : string list; versions_old : Str.regexp list;
versions_bad : string list; versions_bad : Str.regexp list;
(** If none it's a fake prover (very bad version) *) (** If none it's a fake prover (very bad version) *)
prover_command : string option; prover_command : string option;
prover_driver : string; prover_driver : string;
...@@ -86,6 +88,8 @@ let prover_keys = ...@@ -86,6 +88,8 @@ let prover_keys =
let load_prover kind (id,section) = let load_prover kind (id,section) =
check_exhaustive section prover_keys; check_exhaustive section prover_keys;
let reg_map = List.rev_map
(fun s -> if s.[0] = '^' then Str.regexp s else Str.regexp_string s) in
{ kind = kind; { kind = kind;
prover_id = id; prover_id = id;
prover_name = get_string section "name"; prover_name = get_string section "name";
...@@ -93,9 +97,9 @@ let load_prover kind (id,section) = ...@@ -93,9 +97,9 @@ let load_prover kind (id,section) =
execs = get_stringl section "exec"; execs = get_stringl section "exec";
version_switch = get_string section ~default:"" "version_switch"; version_switch = get_string section ~default:"" "version_switch";
version_regexp = get_string section ~default:"" "version_regexp"; version_regexp = get_string section ~default:"" "version_regexp";
versions_ok = get_stringl section ~default:[] "version_ok"; versions_ok = reg_map $ get_stringl section ~default:[] "version_ok";
versions_old = get_stringl section ~default:[] "version_old"; versions_old = reg_map $ get_stringl section ~default:[] "version_old";
versions_bad = get_stringl section ~default:[] "version_bad"; versions_bad = reg_map $ get_stringl section ~default:[] "version_bad";
prover_command = get_stringo section "command"; prover_command = get_stringo section "command";
prover_driver = get_string section "driver"; prover_driver = get_string section "driver";
prover_editor = get_string section ~default:"" "editor"; prover_editor = get_string section ~default:"" "editor";
...@@ -151,13 +155,14 @@ let read_editors main = ...@@ -151,13 +155,14 @@ let read_editors main =
| Not_found -> | Not_found ->
Loc.errorm "provers-detection-data.conf not found at %s@." filename Loc.errorm "provers-detection-data.conf not found at %s@." filename
let make_command exec com = let make_command =
let cmd_regexp = Str.regexp "%\\(.\\)" in let cmd_regexp = Str.regexp "%\\(.\\)" in
let replace s = match Str.matched_group 1 s with fun exec com ->
| "e" -> exec let replace s = match Str.matched_group 1 s with
| c -> "%"^c | "e" -> exec
in | c -> "%"^c
Str.global_substitute cmd_regexp replace com in
Str.global_substitute cmd_regexp replace com
let sanitize_exec = let sanitize_exec =
let first c = match c with let first c = match c with
...@@ -213,7 +218,9 @@ let ask_prover_version env exec_name version_switch = ...@@ -213,7 +218,9 @@ let ask_prover_version env exec_name version_switch =
Hashtbl.replace env.prover_output (exec_name,version_switch) res; Hashtbl.replace env.prover_output (exec_name,version_switch) res;
res res
let check_version (version : string) schema = schema = version let check_version version schema =
Str.string_match schema version 0
&& Str.match_end () = String.length version
let known_version env exec_name = let known_version env exec_name =
Hashtbl.replace env.prover_unknown_version exec_name None Hashtbl.replace env.prover_unknown_version exec_name None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment