summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Protzenko <Jonathan.Protzenko@ens-lyon.org>2011-12-22 14:04:18 +0000
committerJonathan Protzenko <Jonathan.Protzenko@ens-lyon.org>2011-12-22 14:04:18 +0000
commitb47d5b20f27642acfcc92b18084710a130493b32 (patch)
treeba6378b09df24b829994265d239015ada5bf50a9
parentbc025935709d95ea30ea7a0b19e583a118be99c7 (diff)
Fix #5437: when registering an option with Arg, if the option has an empty doc string, do not include it when printing the usage.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11939 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--Changes2
-rw-r--r--stdlib/arg.ml9
-rw-r--r--stdlib/arg.mli2
3 files changed, 9 insertions, 4 deletions
diff --git a/Changes b/Changes
index f1f2ec9b1..174d9104b 100644
--- a/Changes
+++ b/Changes
@@ -35,6 +35,8 @@ Standard library:
. Added optional "seed" parameter to Hashtbl.create for diversification
. Added new functorial interface "MakeSeeded" to support diversification
with user-provided hash functions.
+- Arg: options with empty doc strings are no longer included in the usage string
+ (PR#5437)
Bug Fixes:
- PR#4869: rare collisions between assembly labels for code and data
diff --git a/stdlib/arg.ml b/stdlib/arg.ml
index d5d1bdf74..d19f89056 100644
--- a/stdlib/arg.ml
+++ b/stdlib/arg.ml
@@ -64,10 +64,11 @@ let make_symlist prefix sep suffix l =
;;
let print_spec buf (key, spec, doc) =
- match spec with
- | Symbol (l, _) -> bprintf buf " %s %s%s\n" key (make_symlist "{" "|" "}" l)
- doc
- | _ -> bprintf buf " %s %s\n" key doc
+ if String.length doc > 0 then
+ match spec with
+ | Symbol (l, _) -> bprintf buf " %s %s%s\n" key (make_symlist "{" "|" "}" l)
+ doc
+ | _ -> bprintf buf " %s %s\n" key doc
;;
let help_action () = raise (Stop (Unknown "-help"));;
diff --git a/stdlib/arg.mli b/stdlib/arg.mli
index 1fff78f19..d6e0210aa 100644
--- a/stdlib/arg.mli
+++ b/stdlib/arg.mli
@@ -83,6 +83,8 @@ val parse :
- The reason for the error: unknown option, invalid or missing argument, etc.
- [usage_msg]
- The list of options, each followed by the corresponding [doc] string.
+ Beware: options that have an empty [doc] string will not be included in the
+ list.
For the user to be able to specify anonymous arguments starting with a
[-], include for example [("-", String anon_fun, doc)] in [speclist].