diff options
author | Pierre Weis <Pierre.Weis@inria.fr> | 2013-06-01 09:01:59 +0000 |
---|---|---|
committer | Pierre Weis <Pierre.Weis@inria.fr> | 2013-06-01 09:01:59 +0000 |
commit | e833f3c9d5003f10235409bc505f0e47f77db37a (patch) | |
tree | 49ecbdff14e095714f7befcf13c08c1a78a614fe | |
parent | abb832f430c37a51d8041da3f1eea7c04d15a63d (diff) |
Better error messages for binary/octal/hexa integer scanning.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13725 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | stdlib/scanf.ml | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/stdlib/scanf.ml b/stdlib/scanf.ml index 945eee9a4..44199a98c 100644 --- a/stdlib/scanf.ml +++ b/stdlib/scanf.ml @@ -612,7 +612,7 @@ let scan_decimal_digits_plus width ib = bad_input (Printf.sprintf "character %C is not a decimal digit" c) ;; -let scan_digits_plus digitp width ib = +let scan_digits_plus basis digitp width ib = (* To scan numbers from other bases, we use a predicate argument to scan_digits. *) let rec scan_digits width = @@ -637,7 +637,7 @@ let scan_digits_plus digitp width ib = let width = Scanning.store_char width ib c in scan_digits width else - bad_input (Printf.sprintf "character %C is not a digit" c) + bad_input (Printf.sprintf "character %C is not a valid %s digit" basis) ;; let is_binary_digit = function @@ -645,21 +645,21 @@ let is_binary_digit = function | _ -> false ;; -let scan_binary_int = scan_digits_plus is_binary_digit;; +let scan_binary_int = scan_digits_plus "binary" is_binary_digit;; let is_octal_digit = function | '0' .. '7' -> true | _ -> false ;; -let scan_octal_int = scan_digits_plus is_octal_digit;; +let scan_octal_int = scan_digits_plus "octal" is_octal_digit;; let is_hexa_digit = function | '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' -> true | _ -> false ;; -let scan_hexadecimal_int = scan_digits_plus is_hexa_digit;; +let scan_hexadecimal_int = scan_digits_plus "hexadecimal" is_hexa_digit;; (* Scan a decimal integer. *) let scan_unsigned_decimal_int = scan_decimal_digits_plus;; |