When building wget 1.6 on Solaris 2.5.1 with GCC 2.95.3, I ran
into the following porting problem.
snprintf.c: In function `dopr':
snprintf.c:230: warning: subscript has type `char'
snprintf.c:254: warning: subscript has type `char'
This is warning that isdigit doesn't work on negative characters
(which are possible on hosts where characters are signed).
Here is a patch.
2001-04-07 Paul Eggert <[EMAIL PROTECTED]>
* snprintf.c (is_digit): New macro.
(dopr): Use it instead of isdigit, to avoid problems with negative
characters and pacify GCC.
===================================================================
RCS file: src/snprintf.c,v
retrieving revision 1.6
retrieving revision 1.6.0.1
diff -pu -r1.6 -r1.6.0.1
--- src/snprintf.c 2000/11/04 22:49:46 1.6
+++ src/snprintf.c 2001/04/08 06:33:06 1.6.0.1
@@ -160,6 +160,7 @@ static int dopr_outch (char *buffer, siz
#define DP_C_LLONG 3
#define DP_C_LDOUBLE 4
+#define is_digit(c) ('0' <= (c) && (c) <= '9')
#define char_to_int(p) (p - '0')
#define MAX(p,q) ((p >= q) ? p : q)
#define MIN(p,q) ((p <= q) ? p : q)
@@ -227,7 +228,7 @@ static int dopr (char *buffer, size_t ma
}
break;
case DP_S_MIN:
- if (isdigit(ch))
+ if (is_digit (ch))
{
min = 10*min + char_to_int (ch);
ch = *format++;
@@ -251,7 +252,7 @@ static int dopr (char *buffer, size_t ma
state = DP_S_MOD;
break;
case DP_S_MAX:
- if (isdigit(ch))
+ if (is_digit (ch))
{
if (max < 0)
max = 0;