Added -args

This commit is contained in:
John Whitington 2013-10-09 14:31:55 +01:00
parent e3c00a52fb
commit 1f4a1a7cd5
1 changed files with 19 additions and 7 deletions

View File

@ -3359,6 +3359,19 @@ let parse_argv () =
let align_specs s = let align_specs s =
Arg.align s Arg.align s
(* The old -control mechanism clashed with AND, but must be retained for
backwards compatibility. There is a new mechanism -args file which performs
direct textual substitution of the file, before any expansion of ANDs *)
let rec expand_args_inner prev = function
[] -> rev prev
| "-args"::filename::r ->
expand_args_inner (rev (parse_control_file filename) @ prev) r
| h::t -> expand_args_inner (h::prev) t
let expand_args argv =
let l = Array.to_list argv in
Array.of_list (expand_args_inner [] l)
(* Main function. *) (* Main function. *)
let go_withargv argv = let go_withargv argv =
if demo then if demo then
@ -3370,6 +3383,8 @@ let go_withargv argv =
flush stderr flush stderr
end; end;
try try
(* Pre-expand -args *)
let argv = expand_args argv in
(* Split the arguments into sets either side of ANDs *) (* Split the arguments into sets either side of ANDs *)
let sets = let sets =
let args = let args =
@ -3394,13 +3409,10 @@ let go_withargv argv =
flush stdout (*r for Windows *) flush stdout (*r for Windows *)
with with
| Arg.Bad s -> | Arg.Bad s ->
let s' = prerr_string
let chars = explode s in (implode (takewhile (neq '\n') (explode s)) ^ " Use -help for help.\n\n");
implode (takewhile (neq '\n') chars) ^ " Use -help for help.\n\n" flush stderr;
in exit 2
prerr_string s';
flush stderr;
exit 2
| Arg.Help _ -> | Arg.Help _ ->
Arg.usage (align_specs specs) usage_msg; Arg.usage (align_specs specs) usage_msg;
flush stderr (*r for Windows *) flush stderr (*r for Windows *)