X-Git-Url: http://drtracing.org/?a=blobdiff_plain;ds=sidebyside;f=libiberty%2Fstrtoul.c;h=ba80063531e508b7488d59bb72aaccd2d48be3f6;hb=13aa5ceb01cc94a0e617f397c0c5434fc22bb1e5;hp=87fa3ffdf93679f48d72e7f4a349a6ac2ce58725;hpb=62df20656565cd422330ae2b2aebf61c67cbaf22;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/strtoul.c b/libiberty/strtoul.c index 87fa3ffdf9..ba80063531 100644 --- a/libiberty/strtoul.c +++ b/libiberty/strtoul.c @@ -37,7 +37,6 @@ #ifdef HAVE_SYS_PARAM_H #include #endif -#include #include #ifdef NEED_DECLARATION_ERRNO extern int errno; @@ -46,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 */ @@ -58,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; @@ -74,7 +71,7 @@ strtoul(nptr, endptr, base) */ do { c = *s++; - } while (isspace(c)); + } while (ISSPACE(c)); if (c == '-') { neg = 1; c = *s++; @@ -91,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)