MCPcopy Create free account
hub / github.com/numpy/numpy / NumPyOS_ascii_strtold

Function NumPyOS_ascii_strtold

numpy/core/src/common/numpyos.c:512–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510}
511
512NPY_NO_EXPORT long double
513NumPyOS_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) {

Callers 2

NumPyOS_ascii_ftoLfFunction · 0.85

Calls 4

NumPyOS_ascii_isspaceFunction · 0.85
NumPyOS_ascii_isalnumFunction · 0.85
NumPyOS_ascii_strtodFunction · 0.85

Tested by

no test coverage detected