78 long strtol(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;
89 if(base < 0 || base > 36)
95 *endptr = (
char*)(uintptr_t)nptr;
121 if((base == 0 || base == 16) && c ==
'0' && (*s ==
'x' || *s ==
'X'))
127 else if((base == 0 || base == 2) && c ==
'0' && (*s ==
'b' || *s ==
'B'))
136 base = c ==
'0' ? 8 : 10;
157 cutoff = neg ? -(
unsigned long)
LONG_MIN : LONG_MAX;
158 cutlim = (int)(cutoff % (
unsigned long)base);
159 cutoff /= (
unsigned long)base;
160 for(acc = 0, any = 0;; c = *s++)
168 c -=
isupper(c) ?
'A' - 10 :
'a' - 10;
178 if(any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
185 acc *= (
unsigned long)base;
186 acc += (
unsigned long)c;
191 acc = neg ? (
unsigned long)
LONG_MIN : (
unsigned long)LONG_MAX;
200 *endptr = (
char*)(uintptr_t)(any ? s - 1 : nptr);
int isupper(int ch)
Checks if the given character is an uppercase character.
long strtol(char *nptr, char **endptr, int base) const
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.
int isdigit(int ch)
Checks if the given character is a numeric character.