[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Christoph Bauer <Christoph.Bauer@l...> |
| Subject: | RE: [Caml-list] ocamlbuild and menhir on MinGW |
> Are you in cygwin or the windows "shell"?
cygwin shell. With windows "shell" Cmd.exe the output differs but it fails
as well:
[KC:\ocamlmgw\bin\menhir: unknown option `-modules mlutils/globParser.mly'.
Usage: C:\ocamlmgw\bin\menhir <options> <filenames>
...[CUT]...
$B"+(J[KExit code 2 while executing this command:
C:/ocamlmgw/bin/menhir --raw-depend --ocamldep "ocamldep -modules" mlutils/glo
bParser.mly > mlutils/globParser.mly.depends
In ocamlbuild/my_std.ml there is a comment about the problem:
let sys_command =
match Sys.os_type with
| "Win32" -> fun cmd ->
let cmd = "bash -c "^Filename.quote cmd in
(* FIXME fix Filename.quote for windows *)
let cmd = String.subst "\"&\"\"&\"" "&&" cmd in
Sys.command cmd
| _ -> Sys.command
We could use Unix.create_process. I attached a function
to split cmd in a list.
Regards,
Christoph Bauer
let split_quoted_string_list ?(quote = '"') s =
let len = String.length s in
let word_buffer = Buffer.create 128 in
let rec outer i acc =
if i >= len then List.rev acc
else
let c = String.unsafe_get s i in
match c with
' ' | '\t' | '\r' | '\n' -> outer (i+1) acc
| c when c = quote -> inner (i+1) acc
| _ -> plain i acc
and end_of_word i acc =
let word = Buffer.contents word_buffer in
Buffer.clear word_buffer;
outer i (word::acc)
and inner i acc =
if i >= len then failwith ("parser error (split_quoted_string_list): " ^ s);
let c = String.unsafe_get s i in
if c = quote then end_of_word (i+1) acc
else
(Buffer.add_char word_buffer c;
inner (i+1) acc);
and plain i acc =
if i >= len then end_of_word i acc
else
match String.unsafe_get s i with
' ' | '\t' | '\r' | '\n' -> end_of_word (i+1) acc
| c when c = quote -> end_of_word i acc
| c -> Buffer.add_char word_buffer c;
plain (i+1) acc
in outer 0 []