| 354 | */ |
| 355 | |
| 356 | long long int strtoll(const char *orig_ptr, char **endptr, int base) |
| 357 | { |
| 358 | const char *ptr = orig_ptr; |
| 359 | int is_negative = 0; |
| 360 | |
| 361 | /* Purge whitespace */ |
| 362 | |
| 363 | for ( ; *ptr && isspace(*ptr); ptr++); |
| 364 | |
| 365 | if (ptr[0] == '-') { |
| 366 | is_negative = 1; |
| 367 | ptr++; |
| 368 | } |
| 369 | |
| 370 | unsigned long long uval = strtoull(ptr, endptr, base); |
| 371 | |
| 372 | /* If the whole string is unparseable, endptr should point to start. */ |
| 373 | if (endptr && *endptr == ptr) |
| 374 | *endptr = (char *)orig_ptr; |
| 375 | |
| 376 | if (uval > (unsigned long long)LLONG_MAX + !!is_negative) |
| 377 | uval = (unsigned long long)LLONG_MAX + !!is_negative; |
| 378 | |
| 379 | if (is_negative) |
| 380 | return -uval; |
| 381 | else |
| 382 | return uval; |
| 383 | } |
| 384 | |
| 385 | long int strtol(const char *ptr, char **endptr, int base) |
| 386 | { |
no test coverage detected