78 unsigned long strtoul(nptr, endptr, base)
const char* nptr;
82 register const char* s = nptr;
83 register unsigned long acc;
85 register unsigned long cutoff;
86 register int neg = 0, any, cutlim;
104 if((base == 0 || base == 16) && c ==
'0' && (*s ==
'x' || *s ==
'X'))
110 else if((base == 0 || base == 2) && c ==
'0' && (*s ==
'b' || *s ==
'B'))
119 base = c ==
'0' ? 8 : 10;
122 cutoff = (
unsigned long)
ULONG_MAX / (
unsigned long)base;
123 cutlim = (int)((
unsigned long)
ULONG_MAX % (
unsigned long)base);
124 for(acc = 0, any = 0;; c = *s++)
132 c -=
isupper(c) ?
'A' - 10 :
'a' - 10;
142 if(any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
149 acc *= (
unsigned long)base;
150 acc += (
unsigned long)c;
164 *endptr = (
char*)(uintptr_t)(any ? s - 1 : nptr);
int isupper(int ch)
Checks if the given character is an uppercase character.
int isalpha(int ch)
Checks if the given character is an alphabetic character.
int isspace(int ch)
Checks if the given character is a whitespace character.
unsigned long strtoul(char *nptr, char **endptr, int base) const
int isdigit(int ch)
Checks if the given character is a numeric character.