+ s += 3;
+ if (c_tolower (*s) == 'i'
+ && c_tolower (s[1]) == 'n'
+ && c_tolower (s[2]) == 'i'
+ && c_tolower (s[3]) == 't'
+ && c_tolower (s[4]) == 'y')
+ s += 5;
+ num = HUGE_VAL;
+ }
+ else if (c_tolower (*s) == 'n'
+ && c_tolower (s[1]) == 'a'
+ && c_tolower (s[2]) == 'n')
+ {
+ s += 3;
+ if (*s == '(')
+ {
+ const char *p = s + 1;
+ while (c_isalnum (*p))
+ p++;
+ if (*p == ')')
+ s = p + 1;
+ }
+
+ /* If the underlying implementation misparsed the NaN, assume
+ its result is incorrect, and return a NaN. Normally it's
+ better to use the underlying implementation's result, since a
+ nice implementation populates the bits of the NaN according
+ to interpreting n-char-sequence as a hexadecimal number. */
+ if (s != end)
+ num = NAN;
+ }
+ else
+ {
+ /* No conversion could be performed. */
+ errno = EINVAL;
+ s = nptr;