about summary refs log tree commit diff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/strtod.c9
-rw-r--r--stdlib/tst-strtod.c4
2 files changed, 8 insertions, 5 deletions
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index bcd284c54c..db0938404c 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -573,15 +573,14 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
 #endif
   else if (c < L_('0') || c > L_('9'))
     {
-      int matched = 0;
       /* Check for `INF' or `INFINITY'.  */
-      if (TOLOWER (c) == L_('i')
-	  && ((STRNCASECMP (cp, L_("inf"), 3) == 0 && (matched = 3))
-	      || (STRNCASECMP (cp, L_("infinity"), 8) == 0 && (matched = 8))))
+      if (TOLOWER (c) == L_('i') && STRNCASECMP (cp, L_("inf"), 3) == 0)
 	{
 	  /* Return +/- infinity.  */
 	  if (endptr != NULL)
-	    *endptr = (STRING_TYPE *) (cp + matched);
+	    *endptr = (STRING_TYPE *)
+		      (cp + (STRNCASECMP (cp + 3, L_("inity"), 5) == 0
+			     ? 8 : 3));
 
 	  return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL;
 	}
diff --git a/stdlib/tst-strtod.c b/stdlib/tst-strtod.c
index c466695d2f..adf6255f66 100644
--- a/stdlib/tst-strtod.c
+++ b/stdlib/tst-strtod.c
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
+#include <math.h>
 
 struct ltest
   {
@@ -64,6 +65,9 @@ static const struct ltest tests[] =
     { "0x0.8p-1022",
       1.11253692925360069154511635866620203210960799023116591527666e-308,
       '\0', 0 },
+    { "Inf", HUGE_VAL, '\0', 0 },
+    { "-Inf", -HUGE_VAL, '\0', 0 },
+    { "+InFiNiTy", HUGE_VAL, '\0', 0 },
     { NULL, 0, '\0', 0 }
   };