From bac0e2326323206f396609ffbef092d11abb6474 Mon Sep 17 00:00:00 2001 From: Dirk Herrmann Date: Mon, 25 Feb 2002 22:48:21 +0000 Subject: [PATCH] * num2integral.i.c (NUM2INTEGRAL): Fixed signedness problem. --- libguile/ChangeLog | 4 ++++ libguile/num2integral.i.c | 30 +++++++++++++++++------------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/libguile/ChangeLog b/libguile/ChangeLog index bc17890a4..fc6852e93 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,7 @@ +2002-01-10 Dirk Herrmann + + * num2integral.i.c (NUM2INTEGRAL): Fixed signedness problem. + 2002-02-25 Gary Houston * convert.c: include for convert_i.c. diff --git a/libguile/num2integral.i.c b/libguile/num2integral.i.c index b6e8a9b5f..a9bd5c718 100644 --- a/libguile/num2integral.i.c +++ b/libguile/num2integral.i.c @@ -27,17 +27,21 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) scm_out_of_range (s_caller, num); #endif - if (sizeof (ITYPE) >= sizeof (scm_t_signed_bits)) - /* can't fit anything too big for this type in an inum - anyway */ - return (ITYPE) n; - else - { /* an inum can be out of range, so check */ - if (((ITYPE)n) != n) - scm_out_of_range (s_caller, num); - else - return (ITYPE) n; - } +#if SIZEOF_ITYPE >= SIZEOF_SCM_T_BITS + /* the target type is large enough to hold any possible inum */ + return (ITYPE) n; +#else + /* an inum can be out of range, so check */ +#ifdef UNSIGNED + /* n is known to be >= 0 */ + if ((scm_t_bits) n > UNSIGNED_ITYPE_MAX) + scm_out_of_range (s_caller, num); +#else + if (((ITYPE)n) != n) + scm_out_of_range (s_caller, num); +#endif + return (ITYPE) n; +#endif /* SIZEOF_ITYPE >= SIZEOF_SCM_T_BITS */ } else if (SCM_BIGP (num)) { /* bignum */ @@ -78,9 +82,9 @@ NUM2INTEGRAL (SCM num, unsigned long int pos, const char *s_caller) scm_out_of_range (s_caller, num); } #endif - + #else /* SIZEOF_ITYPE >= SIZEOF_SCM_T_BITS */ - scm_out_of_range (s_caller, num); + scm_out_of_range (s_caller, num); #endif }