From 71df73ac43cc3019da9f232d80487b6fe47f3162 Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Tue, 27 Apr 2004 23:16:17 +0000 Subject: [PATCH] =?UTF-8?q?numbers.c=20(XDIGIT2UINT,=20mem2uinteger,=20mem?= =?UTF-8?q?2decimal=5Ffrom=5Fpoint,=20mem2ureal):=20Cast=20char=20to=20int?= =?UTF-8?q?=20for=20ctype.h=20tests,=20to=20avoid=20warnings=20from=20gcc?= =?UTF-8?q?=20on=20HP-UX=20about=20char=20as=20array=20subscript.=20=20Rep?= =?UTF-8?q?orted=20by=20Andreas=20V=C3=B6gele.=20Also=20cast=20through=20u?= =?UTF-8?q?nsigned=20char=20to=20avoid=20passing=20negatives=20to=20those?= =?UTF-8?q?=20macros=20if=20input=20contains=208-bit=20values.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libguile/numbers.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libguile/numbers.c b/libguile/numbers.c index 8b169d3d8..3d7aac307 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -2316,7 +2316,10 @@ enum t_exactness {NO_EXACTNESS, INEXACT, EXACT}; /* R5RS, section 7.1.1, lexical structure of numbers: . */ /* In non ASCII-style encodings the following macro might not work. */ -#define XDIGIT2UINT(d) (isdigit (d) ? (d) - '0' : tolower (d) - 'a' + 10) +#define XDIGIT2UINT(d) \ + (isdigit ((int) (unsigned char) d) \ + ? (d) - '0' \ + : tolower ((int) (unsigned char) d) - 'a' + 10) static SCM mem2uinteger (const char* mem, size_t len, unsigned int *p_idx, @@ -2334,7 +2337,7 @@ mem2uinteger (const char* mem, size_t len, unsigned int *p_idx, return SCM_BOOL_F; c = mem[idx]; - if (!isxdigit (c)) + if (!isxdigit ((int) (unsigned char) c)) return SCM_BOOL_F; digit_value = XDIGIT2UINT (c); if (digit_value >= radix) @@ -2345,7 +2348,7 @@ mem2uinteger (const char* mem, size_t len, unsigned int *p_idx, while (idx != len) { char c = mem[idx]; - if (isxdigit (c)) + if (isxdigit ((int) (unsigned char) c)) { if (hash_seen) break; @@ -2422,7 +2425,7 @@ mem2decimal_from_point (SCM result, const char* mem, size_t len, while (idx != len) { char c = mem[idx]; - if (isdigit (c)) + if (isdigit ((int) (unsigned char) c)) { if (x == INEXACT) return SCM_BOOL_F; @@ -2503,7 +2506,7 @@ mem2decimal_from_point (SCM result, const char* mem, size_t len, else sign = 1; - if (!isdigit (c)) + if (!isdigit ((int) (unsigned char) c)) return SCM_BOOL_F; idx++; @@ -2511,7 +2514,7 @@ mem2decimal_from_point (SCM result, const char* mem, size_t len, while (idx != len) { char c = mem[idx]; - if (isdigit (c)) + if (isdigit ((int) (unsigned char) c)) { idx++; if (exponent <= SCM_MAXEXP) @@ -2589,7 +2592,7 @@ mem2ureal (const char* mem, size_t len, unsigned int *p_idx, return SCM_BOOL_F; else if (idx + 1 == len) return SCM_BOOL_F; - else if (!isdigit (mem[idx + 1])) + else if (!isdigit ((int) (unsigned char) mem[idx + 1])) return SCM_BOOL_F; else result = mem2decimal_from_point (SCM_MAKINUM (0), mem, len,