* ocamlbuild and menhir on MinGW
@ 2007-05-22 16:14 Christoph Bauer
2007-05-23 7:40 ` [Caml-list] " Nicolas Pouillard
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Bauer @ 2007-05-22 16:14 UTC (permalink / raw)
To: caml-list
Hi,
it there a quoting problem with ocamlbuild on OCaml/MinGW? I'm using
the released OCaml 3.10.0.
$ ocamlbuild -use-menhir -I mlutils ....
C:/ocamlmgw/bin/menhir --raw-depend --ocamldep "ocamldep -modules"
mlutils/globParser.mly > mlutils/globParser.mly.depends
C:\ocamlmgw\bin\menhir: unknown option `-modules
mlutils/globParser.mly'.
Usage: C:\ocamlmgw\bin\menhir <options> <filenames>
....
But ocamldep should get the -modules flag, not menhir.
Christoph Bauer
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild and menhir on MinGW
2007-05-22 16:14 ocamlbuild and menhir on MinGW Christoph Bauer
@ 2007-05-23 7:40 ` Nicolas Pouillard
2007-05-23 9:21 ` Christoph Bauer
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Pouillard @ 2007-05-23 7:40 UTC (permalink / raw)
To: Christoph Bauer; +Cc: caml-list
Are you in cygwin or the windows "shell"?
On 5/22/07, Christoph Bauer <Christoph.Bauer@lmsintl.com> wrote:
> Hi,
>
> it there a quoting problem with ocamlbuild on OCaml/MinGW? I'm using
> the released OCaml 3.10.0.
>
> $ ocamlbuild -use-menhir -I mlutils ....
> C:/ocamlmgw/bin/menhir --raw-depend --ocamldep "ocamldep -modules"
> mlutils/globParser.mly > mlutils/globParser.mly.depends
> C:\ocamlmgw\bin\menhir: unknown option `-modules
> mlutils/globParser.mly'.
> Usage: C:\ocamlmgw\bin\menhir <options> <filenames>
> ....
>
> But ocamldep should get the -modules flag, not menhir.
>
> Christoph Bauer
>
--
Nicolas Pouillard
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [Caml-list] ocamlbuild and menhir on MinGW
2007-05-23 7:40 ` [Caml-list] " Nicolas Pouillard
@ 2007-05-23 9:21 ` Christoph Bauer
2007-05-23 14:46 ` Nicolas Pouillard
0 siblings, 1 reply; 5+ messages in thread
From: Christoph Bauer @ 2007-05-23 9:21 UTC (permalink / raw)
To: Nicolas Pouillard; +Cc: caml-list
> 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]...
←[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 []
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] ocamlbuild and menhir on MinGW
2007-05-23 9:21 ` Christoph Bauer
@ 2007-05-23 14:46 ` Nicolas Pouillard
2007-05-24 7:17 ` Christoph Bauer
0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Pouillard @ 2007-05-23 14:46 UTC (permalink / raw)
To: Christoph Bauer; +Cc: caml-list
On 5/23/07, Christoph Bauer <Christoph.Bauer@lmsintl.com> wrote:
> > 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]...
> ←[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 []
>
IMHO quoting of windows is not so simple. Does it solves really your problem?
--
Nicolas Pouillard
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-05-24 7:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-22 16:14 ocamlbuild and menhir on MinGW Christoph Bauer
2007-05-23 7:40 ` [Caml-list] " Nicolas Pouillard
2007-05-23 9:21 ` Christoph Bauer
2007-05-23 14:46 ` Nicolas Pouillard
2007-05-24 7:17 ` Christoph Bauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox