crt: Fix setting errno in the strtod based strtof implementation

In this case, strtod will have set errno for cases that were out of
range for doubles. For doubles that were in range, but that are out
of ranges for float, set errno before returning.

Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/stdio/strtof.c b/mingw-w64-crt/stdio/strtof.c
index 5697eb4..c4e4eb9 100644
--- a/mingw-w64-crt/stdio/strtof.c
+++ b/mingw-w64-crt/stdio/strtof.c
@@ -4,8 +4,24 @@
  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  */
 #include <stdlib.h>
+#include <float.h>
+#include <errno.h>
+#include <math.h>
 
 float strtof( const char *nptr, char **endptr)
 {
-  return (strtod(nptr, endptr));
+  double ret = strtod(nptr, endptr);
+  if (isfinite(ret)) {
+    /* Check for cases that aren't out of range for doubles, but that are
+     * for floats. */
+    if (ret > FLT_MAX)
+      errno = ERANGE;
+    else if (ret < -FLT_MAX)
+      errno = ERANGE;
+    else if (ret > 0 && ret < FLT_MIN)
+      errno = ERANGE;
+    else if (ret < 0 && ret > -FLT_MIN)
+      errno = ERANGE;
+  }
+  return ret;
 }