X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=libiberty%2Fstrtoul.c;h=ba80063531e508b7488d59bb72aaccd2d48be3f6;hb=228c8f4be0c428369ec6b68e25696863d1e62ed7;hp=59d428cd49e0d38afc63c902cb9480dd29efd2c4;hpb=7d3ffcaf8540b6a29edc9d24ea1fe3bddbd96004;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/strtoul.c b/libiberty/strtoul.c index 59d428cd49..ba80063531 100644 --- a/libiberty/strtoul.c +++ b/libiberty/strtoul.c @@ -28,8 +28,15 @@ * SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#ifdef HAVE_LIMITS_H #include -#include +#endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif #include #ifdef NEED_DECLARATION_ERRNO extern int errno; @@ -38,6 +45,7 @@ extern int errno; #include #endif #include "ansidecl.h" +#include "safe-ctype.h" #ifndef ULONG_MAX #define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ @@ -50,10 +58,7 @@ extern int errno; * alphabets and digits are each contiguous. */ unsigned long -strtoul(nptr, endptr, base) - const char *nptr; - char **endptr; - register int base; +strtoul(const char *nptr, char **endptr, register int base) { register const char *s = nptr; register unsigned long acc; @@ -66,7 +71,7 @@ strtoul(nptr, endptr, base) */ do { c = *s++; - } while (isspace(c)); + } while (ISSPACE(c)); if (c == '-') { neg = 1; c = *s++; @@ -83,10 +88,10 @@ strtoul(nptr, endptr, base) cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { - if (isdigit(c)) + if (ISDIGIT(c)) c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else if (ISALPHA(c)) + c -= ISUPPER(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= base)