summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabrice Le Fessant <fabrice.le_fessant@ocamlpro.com>2017-05-10 14:59:08 +0200
committerDamien Doligez <damien.doligez@gmail.com>2017-09-29 13:38:59 +0200
commitf20a0a042e8c5fe7c9ee981eec24dcdd769f293f (patch)
treed79790a2d3b498b060aad75a6c37ad9ddcc64e7f
parentb9709db3ff7cc9d6c30310899162a2c5a20fae2e (diff)
downloadocaml-f20a0a042e8c5fe7c9ee981eec24dcdd769f293f.tar.gz
Allow first character of OCAMLPARAM to specify an alternative separator
The alternative separator must be in ":|; ,".
-rw-r--r--Changes4
-rw-r--r--driver/compenv.ml23
-rw-r--r--manual/manual/cmds/comp.etex9
-rw-r--r--manual/manual/cmds/native.etex9
4 files changed, 36 insertions, 9 deletions
diff --git a/Changes b/Changes
index 6f349eed2d..afb82c5f78 100644
--- a/Changes
+++ b/Changes
@@ -14,6 +14,10 @@ be mentioned in the 4.06 section below instead of here.)
### Compiler user-interface and warnings:
+- GPR#1166: In OCAMLPARAM, an alternative separator can be specified as
+ first character (instead of comma) in the set ":|; ,"
+ (Fabrice Le Fessant)
+
### Runtime system:
### Other libraries:
diff --git a/driver/compenv.ml b/driver/compenv.ml
index 194fa617c8..2909d67e7d 100644
--- a/driver/compenv.ml
+++ b/driver/compenv.ml
@@ -101,19 +101,30 @@ type filename = string
type readenv_position =
Before_args | Before_compile of filename | Before_link
-(* Syntax of OCAMLPARAM: (name=VALUE,)* _ (,name=VALUE)*
- where VALUE should not contain ',' *)
+(* Syntax of OCAMLPARAM: SEP?(name=VALUE SEP)* _ (SEP name=VALUE)*
+ where VALUE should not contain SEP, and SEP is ',' if unspecified,
+ or ':', '|', ';', ' ' or ',' *)
exception SyntaxError of string
let parse_args s =
- let args = String.split_on_char ',' s in
+ let args =
+ let len = String.length s in
+ if len = 0 then []
+ else
+ (* allow first char to specify an alternative separator in ":|; ," *)
+ match s.[0] with
+ | ( ':' | '|' | ';' | ' ' | ',' ) as c ->
+ List.tl (String.split_on_char c s)
+ | _ -> String.split_on_char ',' s
+ in
let rec iter is_after args before after =
match args with
[] ->
if not is_after then
raise (SyntaxError "no '_' separator found")
else
- (List.rev before, List.rev after)
+ (List.rev before, List.rev after)
+ | "" :: tail -> iter is_after tail before after
| "_" :: _ when is_after -> raise (SyntaxError "too many '_' separators")
| "_" :: tail -> iter true tail before after
| arg :: tail ->
@@ -358,7 +369,9 @@ let read_one_param ppf position name v =
ccobjs := Misc.rev_split_words v @ !ccobjs
end
- | "ccopts" ->
+ | "ccopt"
+ | "ccopts"
+ ->
begin
match position with
| Before_link | Before_compile _ ->
diff --git a/manual/manual/cmds/comp.etex b/manual/manual/cmds/comp.etex
index fc1ef28f17..3e60101408 100644
--- a/manual/manual/cmds/comp.etex
+++ b/manual/manual/cmds/comp.etex
@@ -122,8 +122,13 @@ development work, not in released packages.
\begin{options}
\item["OCAMLPARAM" \rm(environment variable)]
-Arguments that will be inserted before or after the arguments from the
-command line.
+A set of arguments that will be inserted before or after the arguments from
+the command line. Arguments are specified in a comma-separated list
+of "name=value" pairs. A "_" is used to specify the position of
+the command line arguments, i.e. "a=x,_,b=y" means that "a=x" should be
+executed before parsing the arguments, and "b=y" after. Finally,
+an alternative separator can be specified as the
+first character of the string, within the set ":|; ,".
\item["ocaml_compiler_internal_params" \rm(file in the stdlib directory)]
A mapping of file names to lists of arguments that
will be added to the command line (and "OCAMLPARAM") arguments.
diff --git a/manual/manual/cmds/native.etex b/manual/manual/cmds/native.etex
index 1e846849ca..2351b55723 100644
--- a/manual/manual/cmds/native.etex
+++ b/manual/manual/cmds/native.etex
@@ -135,8 +135,13 @@ development work, not in released packages.
\begin{options}
\item["OCAMLPARAM" \rm(environment variable)]
-Arguments that will be inserted before or after the arguments from the
-command line.
+A set of arguments that will be inserted before or after the arguments from
+the command line. Arguments are specified in a comma-separated list
+of "name=value" pairs. A "_" is used to specify the position of
+the command line arguments, i.e. "a=x,_,b=y" means that "a=x" should be
+executed before parsing the arguments, and "b=y" after. Finally,
+an alternative separator can be specified as the
+first character of the string, within the set ":|; ,".
\item["ocaml_compiler_internal_params" \rm(file in the stdlib directory)]
A mapping of file names to lists of arguments that
will be added to the command line (and "OCAMLPARAM") arguments.