summaryrefslogtreecommitdiff
path: root/stdlib/camlinternalFormat.ml
diff options
context:
space:
mode:
authorGabriel Scherer <gabriel.scherer@gmail.com>2014-05-12 15:38:15 +0000
committerGabriel Scherer <gabriel.scherer@gmail.com>2014-05-12 15:38:15 +0000
commit0a7224fd23febc81f00ee37ae589072e5c307a5b (patch)
tree15e8850af39696ac0c4184abe74700191e0e33e9 /stdlib/camlinternalFormat.ml
parent11fdab809df9dd9773d100013dee9e41d9fa8404 (diff)
downloadocaml-0a7224fd23febc81f00ee37ae589072e5c307a5b.tar.gz
some characters were not allowed in charsets
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14831 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib/camlinternalFormat.ml')
-rw-r--r--stdlib/camlinternalFormat.ml14
1 files changed, 13 insertions, 1 deletions
diff --git a/stdlib/camlinternalFormat.ml b/stdlib/camlinternalFormat.ml
index acaf16b767..f6bd86f7c0 100644
--- a/stdlib/camlinternalFormat.ml
+++ b/stdlib/camlinternalFormat.ml
@@ -1882,10 +1882,19 @@ let fmt_ebb_of_string str =
let char_set = freeze_char_set mut_char_set in
next_ind, (if reverse then rev_char_set char_set else char_set)
+ and check_char_set_char str c =
+ if c = '%' && legacy_behavior then
+ failwith_message
+ "non-backward-compatible format %S:\
+ \ character %c was not supported as part of a charset"
+ str c
+
(* Parse the first character of a char set. *)
and parse_char_set_start str_ind end_ind char_set =
if str_ind = end_ind then unexpected_end_of_format end_ind;
- parse_char_set_after_char (str_ind + 1) end_ind char_set str.[str_ind];
+ let c = str.[str_ind] in
+ check_char_set_char str c;
+ parse_char_set_after_char (str_ind + 1) end_ind char_set c;
(* Parse the content of a char set until the first ']'. *)
and parse_char_set_content str_ind end_ind char_set =
@@ -1897,6 +1906,7 @@ let fmt_ebb_of_string str =
add_in_char_set char_set '-';
parse_char_set_content (str_ind + 1) end_ind char_set;
| c ->
+ check_char_set_char str c;
parse_char_set_after_char (str_ind + 1) end_ind char_set c;
(* Test for range in char set. *)
@@ -1909,6 +1919,7 @@ let fmt_ebb_of_string str =
| '-' ->
parse_char_set_after_minus (str_ind + 1) end_ind char_set c
| c' ->
+ check_char_set_char str c';
add_in_char_set char_set c;
parse_char_set_after_char (str_ind + 1) end_ind char_set c'
@@ -1921,6 +1932,7 @@ let fmt_ebb_of_string str =
add_in_char_set char_set '-';
str_ind + 1
| c' ->
+ check_char_set_char str c';
for i = int_of_char c to int_of_char c' do
add_in_char_set char_set (char_of_int i);
done;