summaryrefslogtreecommitdiff
path: root/library/goptions.ml
diff options
context:
space:
mode:
authorGravatar Stephane Glondu <steph@glondu.net>2011-04-19 16:44:20 +0200
committerGravatar Stephane Glondu <steph@glondu.net>2011-04-19 16:44:20 +0200
commit9d27ae09786866b6e3d7b79d1fa7667e5e2aa309 (patch)
treea418d1edb3d53cdb4185b9719b7a70822cf5a24d /library/goptions.ml
parent6b691bbd2101fd39395c0d2135fd7c06a8915e14 (diff)
Imported Upstream version 8.3.pl2upstream/8.3.pl2
Diffstat (limited to 'library/goptions.ml')
-rw-r--r--library/goptions.ml42
1 files changed, 30 insertions, 12 deletions
diff --git a/library/goptions.ml b/library/goptions.ml
index bfd3b272..8cf560d5 100644
--- a/library/goptions.ml
+++ b/library/goptions.ml
@@ -6,7 +6,7 @@
(* * GNU Lesser General Public License Version 2.1 *)
(************************************************************************)
-(* $Id: goptions.ml 13323 2010-07-24 15:57:30Z herbelin $ *)
+(* $Id: goptions.ml 13922 2011-03-21 16:25:18Z letouzey $ *)
(* This module manages customization parameters at the vernacular level *)
@@ -305,19 +305,37 @@ let set_option_value locality check_and_cast key v =
let bad_type_error () = error "Bad type of value for this option."
-let set_int_option_value_gen locality = set_option_value locality
- (fun v -> function
- | (IntValue _) -> IntValue v
- | _ -> bad_type_error ())
+let check_int_value v = function
+ | IntValue _ -> IntValue v
+ | _ -> bad_type_error ()
+
+let check_bool_value v = function
+ | BoolValue _ -> BoolValue v
+ | _ -> bad_type_error ()
+
+let check_string_value v = function
+ | StringValue _ -> StringValue v
+ | _ -> bad_type_error ()
+
+let check_unset_value v = function
+ | BoolValue _ -> BoolValue false
+ | IntValue _ -> IntValue None
+ | _ -> bad_type_error ()
+
+(* Nota: For compatibility reasons, some errors are treated as
+ warning. This allows a script to refer to an option that doesn't
+ exist anymore *)
+
+let set_int_option_value_gen locality =
+ set_option_value locality check_int_value
let set_bool_option_value_gen locality key v =
- try set_option_value locality (fun v -> function
- | (BoolValue _) -> BoolValue v
- | _ -> bad_type_error ()) key v
+ try set_option_value locality check_bool_value key v
+ with UserError (_,s) -> Flags.if_verbose msg_warning s
+let set_string_option_value_gen locality =
+ set_option_value locality check_string_value
+let unset_option_value_gen locality key =
+ try set_option_value locality check_unset_value key ()
with UserError (_,s) -> Flags.if_verbose msg_warning s
-let set_string_option_value_gen locality = set_option_value locality
- (fun v -> function
- | (StringValue _) -> StringValue v
- | _ -> bad_type_error ())
let set_int_option_value = set_int_option_value_gen None
let set_bool_option_value = set_bool_option_value_gen None