---
 mingw-w64-crt/Makefile.am       |  1 +
 mingw-w64-crt/stdio/_strtof_l.c | 28 ++++++++++++++++++++++++++++
 mingw-w64-headers/crt/stdlib.h  |  1 +
 mingw-w64-headers/crt/tchar.h   |  2 ++
 4 files changed, 32 insertions(+)
 create mode 100644 mingw-w64-crt/stdio/_strtof_l.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 4bc09516..dd5a9eb1 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -181,6 +181,7 @@ src_msvcrt_common=\
   stdio/_getwc_nolock.c \
   stdio/_putc_nolock.c \
   stdio/_putwc_nolock.c \
+  stdio/_strtof_l.c \
   stdio/acrt_iob_func.c \
   stdio/strtof.c \
   stdio/snprintf_alias.c \
diff --git a/mingw-w64-crt/stdio/_strtof_l.c b/mingw-w64-crt/stdio/_strtof_l.c
new file mode 100644
index 00000000..0d83acec
--- /dev/null
+++ b/mingw-w64-crt/stdio/_strtof_l.c
@@ -0,0 +1,28 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * 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>
+#include <locale.h>
+
+float _strtof_l( const char *nptr, char **endptr, _locale_t _Locale)
+{
+  const double ret = _strtod_l(nptr, endptr, _Locale);
+  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;
+}
diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h
index e3b5499e..59b51e80 100644
--- a/mingw-w64-headers/crt/stdlib.h
+++ b/mingw-w64-headers/crt/stdlib.h
@@ -515,6 +515,7 @@ float __cdecl __MINGW_NOTHROW strtof(const char * 
__restrict__ _Str,char ** __re
   double __cdecl __mingw_strtod (const char * __restrict__, char ** 
__restrict__);
   long double __cdecl __mingw_strtold(const char * __restrict__, char ** 
__restrict__);
 #endif /* __NO_ISOCEXT */
+  _CRTIMP float __cdecl _strtof_l(const char * __restrict__ _Str,char ** 
__restrict__ _EndPtr,_locale_t _Locale);
   _CRTIMP double __cdecl _strtod_l(const char * __restrict__ _Str,char ** 
__restrict__ _EndPtr,_locale_t _Locale);
   long __cdecl strtol(const char * __restrict__ _Str,char ** __restrict__ 
_EndPtr,int _Radix);
   _CRTIMP long __cdecl _strtol_l(const char * __restrict__ _Str,char ** 
__restrict__ _EndPtr,int _Radix,_locale_t _Locale);
diff --git a/mingw-w64-headers/crt/tchar.h b/mingw-w64-headers/crt/tchar.h
index 9fa2a030..2a41b1bb 100644
--- a/mingw-w64-headers/crt/tchar.h
+++ b/mingw-w64-headers/crt/tchar.h
@@ -573,6 +573,7 @@ extern "C" {
 #define _ungettc ungetc
 #define _ungettch _ungetch
 
+#define _tcstof strtof
 #define _tcstod strtod
 #define _tcstol strtol
 #define _tcstoul strtoul
@@ -580,6 +581,7 @@ extern "C" {
 #define _tstol atol
 #define _tstoi atoi
 #define _tstoi64 _atoi64
+#define _tcstof_l _strtof_l
 #define _tcstod_l _strtod_l
 #define _tcstol_l _strtol_l
 #define _tcstoul_l _strtoul_l
-- 
2.38.1



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to