From 1713d319b714502df37078ed2a0bf5a3496b9ac4 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 19 Oct 2004 15:59:56 +0000 Subject: [PATCH] * numbers.c (scm_i_range_error): New. * conv-integer.i.c, conv-uinteger.i.c: Use it instead of scm_out_of_range. --- libguile/conv-integer.i.c | 8 +++++--- libguile/conv-uinteger.i.c | 4 +++- libguile/numbers.c | 10 ++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/libguile/conv-integer.i.c b/libguile/conv-integer.i.c index 82b81012d..4cf887cb6 100644 --- a/libguile/conv-integer.i.c +++ b/libguile/conv-integer.i.c @@ -1,10 +1,10 @@ -/* This code in included by number.s.c to generate integer conversion +/* This code in included by numbers.c to generate integer conversion functions like scm_to_int and scm_from_int. It is only for signed types, see conv-uinteger.i.c for the unsigned variant. */ /* You need to define the following macros before including this - template. They are undefined at the end of this file to giove a + template. They are undefined at the end of this file to give a clean slate for the next inclusion. TYPE - the integral type to be converted @@ -91,7 +91,9 @@ SCM_TO_TYPE_PROTO (SCM val) else { out_of_range: - scm_out_of_range (NULL, val); + scm_i_range_error (val, + scm_from_signed_integer (TYPE_MIN), + scm_from_signed_integer (TYPE_MAX)); return 0; } } diff --git a/libguile/conv-uinteger.i.c b/libguile/conv-uinteger.i.c index 0917b9bee..ff0d28012 100644 --- a/libguile/conv-uinteger.i.c +++ b/libguile/conv-uinteger.i.c @@ -35,7 +35,9 @@ SCM_TO_TYPE_PROTO (SCM val) else { out_of_range: - scm_out_of_range (NULL, val); + scm_i_range_error (val, + scm_from_unsigned_integer (TYPE_MIN), + scm_from_unsigned_integer (TYPE_MAX)); return 0; } } diff --git a/libguile/numbers.c b/libguile/numbers.c index 2c9a7ea6f..8b83f786a 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -5595,6 +5595,16 @@ scm_is_unsigned_integer (SCM val, scm_t_uintmax min, scm_t_uintmax max) return 0; } +static void +scm_i_range_error (SCM bad_val, SCM min, SCM max) +{ + scm_error (scm_out_of_range_key, + NULL, + "Value out of range ~S to ~S: ~S", + scm_list_3 (min, max, bad_val), + scm_list_1 (bad_val)); +} + #define TYPE scm_t_intmax #define TYPE_MIN min #define TYPE_MAX max