Skip to content

Commit

Permalink
Move push_args closer to use
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb committed Sep 14, 2018
1 parent 4a0534b commit 15f870c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions tools/ocamlmklib.ml
Expand Up @@ -63,26 +63,25 @@ let print_version_num () =
exit 0;
;;

let push_args first arr stk =
for i = Array.length arr - 1 downto first do
Stack.push arr.(i) stk
done
;;

let parse_arguments argv =
let args = Stack.create () in
push_args 1 argv args;
let push_args ~first arr =
for i = Array.length arr - 1 downto first do
Stack.push arr.(i) args
done
in
let next_arg s =
if Stack.is_empty args
then raise (Bad_argument("Option " ^ s ^ " expects one argument"));
Stack.pop args
in
push_args ~first:1 argv;
while not (Stack.is_empty args) do
let s = Stack.pop args in
if s = "-args" then
push_args 0 (Arg.read_arg (next_arg s)) args
push_args ~first:0 (Arg.read_arg (next_arg s))
else if s = "-args0" then
push_args 0 (Arg.read_arg0 (next_arg s)) args
push_args ~first:0 (Arg.read_arg0 (next_arg s))
else if ends_with s ".cmo" || ends_with s ".cma" then
bytecode_objs := s :: !bytecode_objs
else if ends_with s ".cmx" || ends_with s ".cmxa" then
Expand Down

0 comments on commit 15f870c

Please sign in to comment.