summarylogtreecommitdiffstats
path: root/config.patch
blob: 5a6d741ec23f26510ea256d50368beebbaf807b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
116a117,118
> exception Fail_of_string of [`Int | `Bool | `Threechoices | `Intoption ]
> 
117a120,122
>   let parse: 'a. 'k -> (string -> 'a) -> 'a = fun err f ->
>     try f value with Failure _ -> raise (Fail_of_string err)
>   in
120,128c125,136
<     | "base" -> {t with i_base = int_of_string value}
<     | "type" -> {t with i_type = int_of_string value}
<     | "in" -> {t with i_in = int_of_string value}
<     | "with" -> {t with i_with = int_of_string value}
<     | "match_clause" -> {t with i_match_clause = int_of_string value}
<     | "ppx_stritem_ext" -> {t with i_ppx_stritem_ext = int_of_string value}
<     | "max_indent" -> {t with i_max_indent = intoption_of_string value}
<     | "strict_with" -> {t with i_strict_with = threechoices_of_string value}
<     | "strict_else" -> {t with i_strict_else = threechoices_of_string value}
---
>     | "base" -> {t with i_base = parse `Int int_of_string}
>     | "type" -> {t with i_type = parse `Int int_of_string}
>     | "in" -> {t with i_in = parse `Int int_of_string}
>     | "with" -> {t with i_with = parse `Int int_of_string}
>     | "match_clause" -> {t with i_match_clause = parse `Int int_of_string}
>     | "ppx_stritem_ext" -> {t with i_ppx_stritem_ext = parse `Int int_of_string}
>     | "max_indent" -> {t with i_max_indent =
>                                 parse `Intoption intoption_of_string}
>     | "strict_with" -> {t with i_strict_with =
>                                  parse `Threechoices threechoices_of_string}
>     | "strict_else" -> {t with i_strict_else =
>                                  parse `Threechoices threechoices_of_string}
130,133c138,144
<         {t with i_strict_with = if bool_of_string value then Always else Never}
<     | "strict_comments" -> {t with i_strict_comments = bool_of_string value}
<     | "align_ops" -> {t with i_align_ops = bool_of_string value}
<     | "align_params" -> {t with i_align_params = threechoices_of_string value}
---
>         {t with i_strict_with =
>                   if parse `Bool bool_of_string then Always else Never}
>     | "strict_comments" -> {t with i_strict_comments =
>                                      parse `Bool bool_of_string}
>     | "align_ops" -> {t with i_align_ops = parse `Bool bool_of_string}
>     | "align_params" -> {t with i_align_params =
>                                   parse `Threechoices threechoices_of_string}
141,163c152,160
<   | Failure "int_of_string" ->
<       let e = Printf.sprintf "%s should be an integer, not %S" var_name value in
<       raise (Invalid_argument e)
<   | Failure "bool_of_string" ->
<       let e =
<         Printf.sprintf "%s should be either \"true\" or \"false\", not %S"
<           var_name value
<       in
<       raise (Invalid_argument e)
<   | Failure "threechoices_of_string" ->
<       let e =
<         Printf.sprintf
<           "%s should be either \"always\", \"never\" or \"auto\", not %S"
<           var_name value
<       in
<       raise (Invalid_argument e)
<   | Failure "intoption_of_string" ->
<       let e =
<         Printf.sprintf
<           "%s should be either an integer or \"none\", not %S"
<           var_name value
<       in
<       raise (Invalid_argument e)
---
>   | Fail_of_string kind ->
>       Printf.ksprintf (fun msg -> raise (Invalid_argument msg))
>         (match kind with
>          | `Int -> "%s should be an integer, not %S"
>          | `Bool -> "%s should be either \"true\" or \"false\", not %S"
>          | `Threechoices ->
>              "%s should be either \"always\", \"never\" or \"auto\", not %S"
>          | `Intoption -> "%s should be either an integer or \"none\", not %S")
>         var_name value