| 510 | } |
| 511 | |
| 512 | NPY_NO_EXPORT long double |
| 513 | NumPyOS_ascii_strtold(const char *s, char** endptr) |
| 514 | { |
| 515 | const char *p; |
| 516 | long double result; |
| 517 | #ifdef HAVE_STRTOLD_L |
| 518 | locale_t clocale; |
| 519 | #endif |
| 520 | |
| 521 | while (NumPyOS_ascii_isspace(*s)) { |
| 522 | ++s; |
| 523 | } |
| 524 | |
| 525 | /* |
| 526 | * ##1 |
| 527 | * |
| 528 | * Recognize POSIX inf/nan representations on all platforms. |
| 529 | */ |
| 530 | p = s; |
| 531 | result = 1.0; |
| 532 | if (*p == '-') { |
| 533 | result = -1.0; |
| 534 | ++p; |
| 535 | } |
| 536 | else if (*p == '+') { |
| 537 | ++p; |
| 538 | } |
| 539 | if (NumPyOS_ascii_strncasecmp(p, "nan", 3) == 0) { |
| 540 | p += 3; |
| 541 | if (*p == '(') { |
| 542 | ++p; |
| 543 | while (NumPyOS_ascii_isalnum(*p) || *p == '_') { |
| 544 | ++p; |
| 545 | } |
| 546 | if (*p == ')') { |
| 547 | ++p; |
| 548 | } |
| 549 | } |
| 550 | if (endptr != NULL) { |
| 551 | *endptr = (char*)p; |
| 552 | } |
| 553 | return NPY_NAN; |
| 554 | } |
| 555 | else if (NumPyOS_ascii_strncasecmp(p, "inf", 3) == 0) { |
| 556 | p += 3; |
| 557 | if (NumPyOS_ascii_strncasecmp(p, "inity", 5) == 0) { |
| 558 | p += 5; |
| 559 | } |
| 560 | if (endptr != NULL) { |
| 561 | *endptr = (char*)p; |
| 562 | } |
| 563 | return result*NPY_INFINITY; |
| 564 | } |
| 565 | /* End of ##1 */ |
| 566 | |
| 567 | #ifdef HAVE_STRTOLD_L |
| 568 | clocale = newlocale(LC_ALL_MASK, "C", NULL); |
| 569 | if (clocale) { |
no test coverage detected