mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
numbers.c (XDIGIT2UINT,
mem2uinteger, mem2decimal_from_point, mem2ureal): Cast char to int for ctype.h tests, to avoid warnings from gcc on HP-UX about char as array subscript. Reported by Andreas Vögele. Also cast through unsigned char to avoid passing negatives to those macros if input contains 8-bit values.
This commit is contained in:
parent
70d31de900
commit
71df73ac43
1 changed files with 10 additions and 7 deletions
|
@ -2316,7 +2316,10 @@ enum t_exactness {NO_EXACTNESS, INEXACT, EXACT};
|
||||||
/* R5RS, section 7.1.1, lexical structure of numbers: <uinteger R>. */
|
/* R5RS, section 7.1.1, lexical structure of numbers: <uinteger R>. */
|
||||||
|
|
||||||
/* In non ASCII-style encodings the following macro might not work. */
|
/* 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
|
static SCM
|
||||||
mem2uinteger (const char* mem, size_t len, unsigned int *p_idx,
|
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;
|
return SCM_BOOL_F;
|
||||||
|
|
||||||
c = mem[idx];
|
c = mem[idx];
|
||||||
if (!isxdigit (c))
|
if (!isxdigit ((int) (unsigned char) c))
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
digit_value = XDIGIT2UINT (c);
|
digit_value = XDIGIT2UINT (c);
|
||||||
if (digit_value >= radix)
|
if (digit_value >= radix)
|
||||||
|
@ -2345,7 +2348,7 @@ mem2uinteger (const char* mem, size_t len, unsigned int *p_idx,
|
||||||
while (idx != len)
|
while (idx != len)
|
||||||
{
|
{
|
||||||
char c = mem[idx];
|
char c = mem[idx];
|
||||||
if (isxdigit (c))
|
if (isxdigit ((int) (unsigned char) c))
|
||||||
{
|
{
|
||||||
if (hash_seen)
|
if (hash_seen)
|
||||||
break;
|
break;
|
||||||
|
@ -2422,7 +2425,7 @@ mem2decimal_from_point (SCM result, const char* mem, size_t len,
|
||||||
while (idx != len)
|
while (idx != len)
|
||||||
{
|
{
|
||||||
char c = mem[idx];
|
char c = mem[idx];
|
||||||
if (isdigit (c))
|
if (isdigit ((int) (unsigned char) c))
|
||||||
{
|
{
|
||||||
if (x == INEXACT)
|
if (x == INEXACT)
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
|
@ -2503,7 +2506,7 @@ mem2decimal_from_point (SCM result, const char* mem, size_t len,
|
||||||
else
|
else
|
||||||
sign = 1;
|
sign = 1;
|
||||||
|
|
||||||
if (!isdigit (c))
|
if (!isdigit ((int) (unsigned char) c))
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
|
@ -2511,7 +2514,7 @@ mem2decimal_from_point (SCM result, const char* mem, size_t len,
|
||||||
while (idx != len)
|
while (idx != len)
|
||||||
{
|
{
|
||||||
char c = mem[idx];
|
char c = mem[idx];
|
||||||
if (isdigit (c))
|
if (isdigit ((int) (unsigned char) c))
|
||||||
{
|
{
|
||||||
idx++;
|
idx++;
|
||||||
if (exponent <= SCM_MAXEXP)
|
if (exponent <= SCM_MAXEXP)
|
||||||
|
@ -2589,7 +2592,7 @@ mem2ureal (const char* mem, size_t len, unsigned int *p_idx,
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
else if (idx + 1 == len)
|
else if (idx + 1 == len)
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
else if (!isdigit (mem[idx + 1]))
|
else if (!isdigit ((int) (unsigned char) mem[idx + 1]))
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
else
|
else
|
||||||
result = mem2decimal_from_point (SCM_MAKINUM (0), mem, len,
|
result = mem2decimal_from_point (SCM_MAKINUM (0), mem, len,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue