]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
strtof: Work around mingw bug with overflow.
authorBruno Haible <bruno@clisp.org>
Tue, 16 Sep 2025 14:30:38 +0000 (16:30 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 16 Sep 2025 14:30:38 +0000 (16:30 +0200)
* lib/strtod.c (STRTOD): Recognize overflow.
* modules/strtof (Depends-on): Add isinf.
* modules/strtod (Depends-on): Likewise.
* modules/strtold (Depends-on): Likewise.
* doc/posix-functions/strtof.texi: Update mingw version.

ChangeLog
doc/posix-functions/strtof.texi
lib/strtod.c
modules/strtod
modules/strtof
modules/strtold

index 36dff72375b1b0284db005c77238a31535301e0d..bbf3ce8741c262f86b537cc841e3d743795377f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-09-16  Bruno Haible  <bruno@clisp.org>
+
+       strtof: Work around mingw bug with overflow.
+       * lib/strtod.c (STRTOD): Recognize overflow.
+       * modules/strtof (Depends-on): Add isinf.
+       * modules/strtod (Depends-on): Likewise.
+       * modules/strtold (Depends-on): Likewise.
+       * doc/posix-functions/strtof.texi: Update mingw version.
+
 2025-09-16  Bruno Haible  <bruno@clisp.org>
 
        pagealign_alloc tests: Fix link error.
index f1675d8087c539caa88d22c56fdfd1e1662fbfda..9caa74d58d76efa9a3ce6d708542c7353afcbffa 100644 (file)
@@ -28,7 +28,7 @@ macOS 10.6.6.
 
 @item
 This function fails to set @code{errno} upon overflow on some platforms:
-mingw 5.0.
+mingw 9.0.
 
 @item
 @c The term "underflow", as defined by ISO C23 ยง 7.12.1.(6), includes both
index 1258753caf99ad55d0b0ea4f8a2a309dd8a2b884..73fe95ca03e702532c0bb304c1cfdd9f07369a79 100644 (file)
@@ -492,6 +492,10 @@ STRTOD (const char *nptr, char **endptr)
                 }
               end = e;
             }
+          /* If "1e50" was converted to Inf (overflow), errno needs to be
+             set.  */
+          else if (isinf (num))
+            errno = ERANGE;
         }
 
       s = end;
index 23ef6a5213c4102981ff915a7c3b37dbb4c785f9..aaade58f7cbf7537df48e5510709185d4aabc8b7 100644 (file)
@@ -12,6 +12,7 @@ strtod-obsolete
 c-ctype         [test $HAVE_STRTOD = 0 || test $REPLACE_STRTOD = 1]
 math-h          [test $HAVE_STRTOD = 0 || test $REPLACE_STRTOD = 1]
 bool            [test $HAVE_STRTOD = 0 || test $REPLACE_STRTOD = 1]
+isinf           [test $HAVE_STRTOD = 0 || test $REPLACE_STRTOD = 1]
 
 configure.ac:
 gl_FUNC_STRTOD
index df3d79510091cbb1ad2f671a6b5e360c599a5e7e..306e77a040c0c2ce41eb40fa4fefa4f0029640ea 100644 (file)
@@ -12,6 +12,7 @@ stdlib-h
 c-ctype         [test $HAVE_STRTOF = 0 || test $REPLACE_STRTOF = 1]
 math-h          [test $HAVE_STRTOF = 0 || test $REPLACE_STRTOF = 1]
 bool            [test $HAVE_STRTOF = 0 || test $REPLACE_STRTOF = 1]
+isinf           [test $HAVE_STRTOF = 0 || test $REPLACE_STRTOF = 1]
 
 configure.ac:
 gl_FUNC_STRTOF
index 4d8f6628b8c327f29e133a37b70e0f8d1552cbb1..9cafe3f49a25dc811166956006d01c27d801c4cc 100644 (file)
@@ -13,6 +13,7 @@ stdlib-h
 c-ctype         [test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1]
 math-h          [test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1]
 bool            [test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1]
+isinf           [test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1]
 strtod          [{ test $HAVE_STRTOLD = 0 || test $REPLACE_STRTOLD = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1]
 
 configure.ac: