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

Function NumPyOS_ascii_strtod

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

* NumPyOS_ascii_strtod: * * Work around bugs in PyOS_ascii_strtod */

Source from the content-addressed store, hash-verified

455 * Work around bugs in PyOS_ascii_strtod
456 */
457NPY_NO_EXPORT double
458NumPyOS_ascii_strtod(const char *s, char** endptr)
459{
460 const char *p;
461 double result;
462
463 while (NumPyOS_ascii_isspace(*s)) {
464 ++s;
465 }
466
467 /*
468 * ##1
469 *
470 * Recognize POSIX inf/nan representations on all platforms.
471 */
472 p = s;
473 result = 1.0;
474 if (*p == '-') {
475 result = -1.0;
476 ++p;
477 }
478 else if (*p == '+') {
479 ++p;
480 }
481 if (NumPyOS_ascii_strncasecmp(p, "nan", 3) == 0) {
482 p += 3;
483 if (*p == '(') {
484 ++p;
485 while (NumPyOS_ascii_isalnum(*p) || *p == '_') {
486 ++p;
487 }
488 if (*p == ')') {
489 ++p;
490 }
491 }
492 if (endptr != NULL) {
493 *endptr = (char*)p;
494 }
495 return NPY_NAN;
496 }
497 else if (NumPyOS_ascii_strncasecmp(p, "inf", 3) == 0) {
498 p += 3;
499 if (NumPyOS_ascii_strncasecmp(p, "inity", 5) == 0) {
500 p += 5;
501 }
502 if (endptr != NULL) {
503 *endptr = (char*)p;
504 }
505 return result*NPY_INFINITY;
506 }
507 /* End of ##1 */
508
509 return NumPyOS_ascii_strtod_plain(s, endptr);
510}
511
512NPY_NO_EXPORT long double
513NumPyOS_ascii_strtold(const char *s, char** endptr)

Callers 2

NumPyOS_ascii_strtoldFunction · 0.85
NumPyOS_ascii_ftolfFunction · 0.85

Calls 4

NumPyOS_ascii_isspaceFunction · 0.85
NumPyOS_ascii_isalnumFunction · 0.85

Tested by

no test coverage detected