From 9f0b09e95391306e0af26d9ccee406ecc16cebda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Fri, 29 May 1998 22:40:01 +0200 Subject: [PATCH] Fixed a few warnings in STRTOL(). Rev: src/port.c:1.17 --- src/port.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/port.c b/src/port.c index cc4baa47d8..0bf0818e73 100644 --- a/src/port.c +++ b/src/port.c @@ -17,7 +17,7 @@ #include <float.h> #include <string.h> -RCSID("$Id: port.c,v 1.16 1998/05/17 22:30:38 grubba Exp $"); +RCSID("$Id: port.c,v 1.17 1998/05/29 20:40:01 grubba Exp $"); #ifdef sun time_t time PROT((time_t *)); @@ -115,7 +115,7 @@ unsigned long my_rand(void) return rndbuf[rnd_index] += rndbuf[rnd_index+RNDJUMP-(rnd_index<RNDBUF-RNDJUMP?0:RNDBUF)]; } -#ifndef HAVE_STRTOL +#if !defined(HAVE_STRTOL) || !defined(HAVE_WORKING_STRTOL) #define DIGIT(x) (isdigit(x) ? (x) - '0' : \ islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A') #define MBASE ('z' - 'a' + 1 + 10) @@ -140,20 +140,21 @@ long STRTOL(char *str,char **ptr,int base) c = *++str; } } - if (base == 0) + if (base == 0) { if (c != '0') base = 10; else if (str[1] == 'x' || str[1] == 'X') base = 16; else base = 8; + } /* * for any base > 10, the digits incrementally following * 9 are assumed to be "abc...z" or "ABC...Z" */ if (!isalnum(c) || (xx = DIGIT(c)) >= base) return (0); /* no number formed */ - if (base == 16 && c == '0' && isxdigit(str[2]) && + if (base == 16 && c == '0' && isxdigit(((unsigned char *)str)[2]) && (str[1] == 'x' || str[1] == 'X')) c = *(str += 2); /* skip over leading "0x" or "0X" */ for (val = -DIGIT(c); isalnum(c = *++str) && (xx = DIGIT(c)) < base; ) -- GitLab