22 #define strncasecmp _strnicmp 35 pstrtod(
const char *nptr,
char **endptr) {
44 if (*p ==
'+' || *p ==
'-') {
54 if (strncasecmp(p,
"inf", 3) == 0) {
56 if (strncasecmp(p,
"inity", 5) == 0) {
59 value = std::numeric_limits<double>::infinity();
61 }
else if (strncasecmp(p,
"nan", 3) == 0) {
64 if (*p ==
's' || *p ==
'S') {
65 value = std::numeric_limits<double>::signaling_NaN();
68 if (*p ==
'q' || *p ==
'Q') {
71 value = std::numeric_limits<double>::quiet_NaN();
78 if (strncmp(p,
"()", 2) == 0) {
85 return strtod(nptr, endptr);
90 bool found_digits =
false;
92 value = (value * 10.0) + (*p -
'0');
100 double multiplicand = 0.1;
101 while (isdigit(*p)) {
102 value += (*p -
'0') * multiplicand;
111 if (endptr != NULL) {
112 *endptr = (
char *)nptr;
117 if (tolower(*p) ==
'e') {
122 if (*p ==
'+' || *p ==
'-') {
129 while (isdigit(*p)) {
130 evalue = (evalue * 10.0) + (*p -
'0');
135 value /= pow(10.0, evalue);
137 value *= pow(10.0, evalue);
146 if (endptr != NULL) {
163 patof(
const char *str) {
164 return pstrtod(str, (
char **)NULL);