| 406 | */ |
| 407 | |
| 408 | unsigned long long int strtoull(const char *ptr, char **endptr, int base) |
| 409 | { |
| 410 | unsigned long long int ret = 0; |
| 411 | |
| 412 | if (endptr != NULL) |
| 413 | *endptr = (char *) ptr; |
| 414 | |
| 415 | /* Purge whitespace */ |
| 416 | |
| 417 | for ( ; *ptr && isspace(*ptr); ptr++); |
| 418 | |
| 419 | if (!*ptr) |
| 420 | return 0; |
| 421 | |
| 422 | /* Determine the base */ |
| 423 | |
| 424 | if (base == 0) { |
| 425 | if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X')) |
| 426 | base = 16; |
| 427 | else if (ptr[0] == '0') { |
| 428 | base = 8; |
| 429 | ptr++; |
| 430 | } else { |
| 431 | base = 10; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | /* Base 16 allows the 0x on front - so skip over it */ |
| 436 | |
| 437 | if (base == 16) { |
| 438 | if (ptr[0] == '0' && (ptr[1] == 'x' || ptr[1] == 'X') && |
| 439 | _valid(ptr[2], base)) |
| 440 | ptr += 2; |
| 441 | } |
| 442 | |
| 443 | for ( ; *ptr && _valid(*ptr, base); ptr++) |
| 444 | ret = (ret * base) + _offset(*ptr, base); |
| 445 | |
| 446 | if (endptr != NULL) |
| 447 | *endptr = (char *) ptr; |
| 448 | |
| 449 | return ret; |
| 450 | } |
| 451 | |
| 452 | unsigned long int strtoul(const char *ptr, char **endptr, int base) |
| 453 | { |
no test coverage detected