Implement 0b/0B binary prefix support in strtol, strtoul, wcstol, wcstoul
and related functions for C23 compliance.

* Add %b prefix parsing to strtoimax/wcstoimax/strtoumax/wcstoumax
* Add implementations of strtol, strtoul, wcstol, wcstoul with %b prefix
  parsing in misc/
* Expose new implementations of strtox family in stdlib.h and wchar.h when
  __USE_MINGW_STRTOX is defined

Signed-off-by: Peter Damianov <[email protected]>
---
 mingw-w64-crt/Makefile.am      |   1 +
 mingw-w64-crt/misc/strtoimax.c |   6 +-
 mingw-w64-crt/misc/strtol.c    | 109 ++++++++++++++++++++++++++++++
 mingw-w64-crt/misc/strtoul.c   | 110 +++++++++++++++++++++++++++++++
 mingw-w64-crt/misc/strtoumax.c |   6 +-
 mingw-w64-crt/misc/wcstoimax.c |   8 ++-
 mingw-w64-crt/misc/wcstol.c    | 117 +++++++++++++++++++++++++++++++++
 mingw-w64-crt/misc/wcstoul.c   | 114 ++++++++++++++++++++++++++++++++
 mingw-w64-crt/misc/wcstoumax.c |   8 ++-
 mingw-w64-headers/crt/stdlib.h |  34 +++++++++-
 mingw-w64-headers/crt/wchar.h  |  15 ++++-
 11 files changed, 520 insertions(+), 8 deletions(-)
 create mode 100644 mingw-w64-crt/misc/strtol.c
 create mode 100644 mingw-w64-crt/misc/strtoul.c
 create mode 100644 mingw-w64-crt/misc/wcstol.c
 create mode 100644 mingw-w64-crt/misc/wcstoul.c

diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index d159d181c..d48e1b736 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -1160,6 +1160,7 @@ src_libmingwex=\
   misc/tsearch.c         misc/twalk.c           \
   misc/wcstof.c \
   misc/wcstold.c \
+  misc/strtol.c          misc/strtoul.c             misc/wcstol.c           
misc/wcstoul.c \
   misc/wdirent.c         misc/winbs_uint64.c        misc/winbs_ulong.c      
misc/winbs_ushort.c    \
   misc/btowc.c           misc/wctob.c \
   misc/wmemchr.c         misc/wmemcmp.c             misc/wmemcpy.c          
misc/wmemmove.c              misc/wmempcpy.c        \
diff --git a/mingw-w64-crt/misc/strtoimax.c b/mingw-w64-crt/misc/strtoimax.c
index a6a20c3e6..8578d2b07 100644
--- a/mingw-w64-crt/misc/strtoimax.c
+++ b/mingw-w64-crt/misc/strtoimax.c
@@ -63,16 +63,20 @@ strtoimax(const char * __restrict__ nptr, char ** 
__restrict__ endptr, int base)
                if ( *nptr == '0' ) {
                        if ( nptr[1] == 'X' || nptr[1] == 'x' )
                                base = 16;
+                       else if ( nptr[1] == 'b' || nptr[1] == 'B' )
+                               base = 2;
                        else
                                base = 8;
                }
                else
                                base = 10;
        }
-       /* optional "0x" or "0X" for base 16 */
+       /* optional "0x" or "0X" for base 16, "0b" or "0B" for base 2 */
 
        if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') )
                nptr += 2;              /* skip past this prefix */
+       else if ( base == 2 && *nptr == '0' && (nptr[1] == 'b' || nptr[1] == 
'B') )
+               nptr += 2;              /* skip past this prefix */
 
        /* check whether there is at least one valid digit */
 
diff --git a/mingw-w64-crt/misc/strtol.c b/mingw-w64-crt/misc/strtol.c
new file mode 100644
index 000000000..242a21b6b
--- /dev/null
+++ b/mingw-w64-crt/misc/strtol.c
@@ -0,0 +1,109 @@
+/**
+ * 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 <errno.h>
+#include <ctype.h>
+#include <limits.h>
+
+/* Helper macros */
+
+/* convert digit character to number, in any base */
+#define ToNumber(c)    (isdigit(c) ? (c) - '0' : \
+                        isupper(c) ? (c) - 'A' + 10 : \
+                        islower(c) ? (c) - 'a' + 10 : \
+                        -1             /* "invalid" flag */ \
+                       )
+/* validate converted digit character for specific base */
+#define valid(n, b)    ((n) >= 0 && (n) < (b))
+
+long
+__cdecl
+__strtol(const char * __restrict__ nptr, char ** __restrict__ endptr, int base)
+       {
+       register unsigned long  accum;  /* accumulates converted value */
+       register int            n;      /* numeral from digit character */
+       int                     minus;  /* set iff minus sign seen */
+       int                     toobig; /* set iff value overflows */
+
+       if ( endptr != NULL )
+               *endptr = (char *)nptr; /* in case no conversion's performed */
+
+       if ( base < 0 || base == 1 || base > 36 )
+               {
+               errno = EDOM;
+               return 0;               /* unspecified behavior */
+               }
+
+       /* skip initial, possibly empty sequence of white-space characters */
+
+       while ( isspace(*nptr) )
+               ++nptr;
+
+       /* process subject sequence: */
+
+       /* optional sign */
+       if ( (minus = *nptr == '-') || *nptr == '+' )
+               ++nptr;
+
+       if ( base == 0 ) {
+               if ( *nptr == '0' ) {
+                       if ( nptr[1] == 'X' || nptr[1] == 'x' )
+                               base = 16;
+                       else if ( nptr[1] == 'b' || nptr[1] == 'B' )
+                               base = 2;
+                       else
+                               base = 8;
+               }
+               else
+                               base = 10;
+       }
+       /* optional "0x" or "0X" for base 16, "0b" or "0B" for base 2 */
+
+       if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') )
+               nptr += 2;              /* skip past this prefix */
+       else if ( base == 2 && *nptr == '0' && (nptr[1] == 'b' || nptr[1] == 
'B') )
+               nptr += 2;              /* skip past this prefix */
+
+       /* check whether there is at least one valid digit */
+
+       n = ToNumber(*nptr);
+       ++nptr;
+
+       if ( !valid(n, base) )
+               return 0;               /* subject seq. not of expected form */
+
+       accum = n;
+
+       for ( toobig = 0; n = ToNumber(*nptr), valid(n, base); ++nptr )
+               if ( accum > (unsigned long)(LONG_MAX / base + 2) ) /* major 
wrap-around */
+                       toobig = 1;     /* but keep scanning */
+               else
+                       accum = base * accum + n;
+
+       if ( endptr != NULL )
+               *endptr = (char *)nptr; /* points to first not-valid-digit */
+
+       if ( minus )
+               {
+               if ( accum > (unsigned long)LONG_MAX + 1 )
+                       toobig = 1;
+               }
+       else
+       if ( accum > (unsigned long)LONG_MAX )
+               toobig = 1;
+
+       if ( toobig )
+               {
+               errno = ERANGE;
+               return minus ? LONG_MIN : LONG_MAX;
+               }
+       else
+               return (long)(minus ? -accum : accum);
+       }
+
+long __cdecl __mingw_strtol(const char * __restrict__ nptr, char ** 
__restrict__ endptr, int base)
+    __attribute__((alias("__strtol")));
\ No newline at end of file
diff --git a/mingw-w64-crt/misc/strtoul.c b/mingw-w64-crt/misc/strtoul.c
new file mode 100644
index 000000000..cdb28fd0e
--- /dev/null
+++ b/mingw-w64-crt/misc/strtoul.c
@@ -0,0 +1,110 @@
+/**
+ * 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 <errno.h>
+#include <ctype.h>
+#include <limits.h>
+
+/* Helper macros */
+
+/* convert digit character to number, in any base */
+#define ToNumber(c)    (isdigit(c) ? (c) - '0' : \
+                        isupper(c) ? (c) - 'A' + 10 : \
+                        islower(c) ? (c) - 'a' + 10 : \
+                        -1             /* "invalid" flag */ \
+                       )
+/* validate converted digit character for specific base */
+#define valid(n, b)    ((n) >= 0 && (n) < (b))
+
+unsigned long
+__cdecl
+__strtoul(const char * __restrict__ nptr, char ** __restrict__ endptr, int 
base)
+       {
+       register unsigned long  accum;  /* accumulates converted value */
+       register int            n;      /* numeral from digit character */
+       int                     minus;  /* set iff minus sign seen (yes!) */
+       int                     toobig; /* set iff value overflows */
+
+       if ( endptr != NULL )
+               *endptr = (char *)nptr; /* in case no conversion's performed */
+
+       if ( base < 0 || base == 1 || base > 36 )
+               {
+               errno = EDOM;
+               return 0;               /* unspecified behavior */
+               }
+
+       /* skip initial, possibly empty sequence of white-space characters */
+
+       while ( isspace(*nptr) )
+               ++nptr;
+
+       /* process subject sequence: */
+
+       /* optional sign (yes!) */
+
+       if ( (minus = *nptr == '-') || *nptr == '+' )
+               ++nptr;
+
+       if ( base == 0 )
+        {
+               if ( *nptr == '0' )
+            {
+                       if ( nptr[1] == 'X' || nptr[1] == 'x' )
+                               base = 16;
+                       else if ( nptr[1] == 'b' || nptr[1] == 'B' )
+                               base = 2;
+                       else
+                               base = 8;
+                   }
+               else
+                               base = 10;
+               }
+
+    /* optional "0x" or "0X" for base 16, "0b" or "0B" for base 2 */
+    
+       if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') )
+               nptr += 2;              /* skip past this prefix */
+       else if ( base == 2 && *nptr == '0' && (nptr[1] == 'b' || nptr[1] == 
'B') )
+               nptr += 2;              /* skip past this prefix */
+
+       /* check whether there is at least one valid digit */
+
+       n = ToNumber(*nptr);
+       ++nptr;
+
+       if ( !valid(n, base) )
+               return 0;               /* subject seq. not of expected form */
+
+       accum = n;
+
+       for ( toobig = 0; n = ToNumber(*nptr), valid(n, base); ++nptr )
+               if ( accum > ULONG_MAX / base ) 
+                       toobig = 1;     /* but keep scanning */
+               else
+                       {
+                       accum *= base;
+                       if ( accum > ULONG_MAX - n )
+                               toobig = 1; /* but keep scanning */
+                       else
+                               accum += n;
+                       }
+
+       if ( endptr != NULL )
+               *endptr = (char *)nptr; /* points to first not-valid-digit */
+
+       if ( toobig )
+               {
+               errno = ERANGE;
+               return ULONG_MAX;
+               }
+       else
+               return minus ? -accum : accum;
+       }
+
+unsigned long __cdecl __mingw_strtoul(const char * __restrict__ nptr, char ** 
__restrict__ endptr, int base)
+    __attribute__((alias("__strtoul")));
\ No newline at end of file
diff --git a/mingw-w64-crt/misc/strtoumax.c b/mingw-w64-crt/misc/strtoumax.c
index f368f5eee..6d431b49f 100644
--- a/mingw-w64-crt/misc/strtoumax.c
+++ b/mingw-w64-crt/misc/strtoumax.c
@@ -67,6 +67,8 @@ strtoumax(const char * __restrict__ nptr, char ** 
__restrict__ endptr, int base)
             {
                        if ( nptr[1] == 'X' || nptr[1] == 'x' )
                                base = 16;
+                       else if ( nptr[1] == 'b' || nptr[1] == 'B' )
+                               base = 2;
                        else
                                base = 8;
                    }
@@ -74,10 +76,12 @@ strtoumax(const char * __restrict__ nptr, char ** 
__restrict__ endptr, int base)
                                base = 10;
                }
 
-    /* optional "0x" or "0X" for base 16 */
+    /* optional "0x" or "0X" for base 16, "0b" or "0B" for base 2 */
     
        if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') )
                nptr += 2;              /* skip past this prefix */
+       else if ( base == 2 && *nptr == '0' && (nptr[1] == 'b' || nptr[1] == 
'B') )
+               nptr += 2;              /* skip past this prefix */
 
        /* check whether there is at least one valid digit */
 
diff --git a/mingw-w64-crt/misc/wcstoimax.c b/mingw-w64-crt/misc/wcstoimax.c
index 86c7347bb..9d8e1ae7b 100644
--- a/mingw-w64-crt/misc/wcstoimax.c
+++ b/mingw-w64-crt/misc/wcstoimax.c
@@ -68,18 +68,24 @@ wcstoimax(const wchar_t * __restrict__ nptr, wchar_t ** 
__restrict__ endptr, int
             {
                        if ( nptr[1] == L'X' || nptr[1] == L'x' )
                                base = 16;
+                       else if ( nptr[1] == L'b' || nptr[1] == L'B' )
+                               base = 2;
                        else
                                base = 8;
             }
                else
                                base = 10;
         }
-       /* optional "0x" or "0X" for base 16 */
+       /* optional "0x" or "0X" for base 16, "0b" or "0B" for base 2 */
 
        if ( base == 16 && *nptr == L'0'
          && (nptr[1] == L'X' || nptr[1] == L'x')
           )
                nptr += 2;              /* skip past this prefix */
+       else if ( base == 2 && *nptr == L'0'
+         && (nptr[1] == L'b' || nptr[1] == L'B')
+          )
+               nptr += 2;              /* skip past this prefix */
 
        /* check whether there is at least one valid digit */
 
diff --git a/mingw-w64-crt/misc/wcstol.c b/mingw-w64-crt/misc/wcstol.c
new file mode 100644
index 000000000..8a6ff1172
--- /dev/null
+++ b/mingw-w64-crt/misc/wcstol.c
@@ -0,0 +1,117 @@
+/**
+ * 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 <errno.h>
+#include <wctype.h>
+#include <wchar.h>
+#include <limits.h>
+
+/* Helper macros */
+
+/* convert digit character to number, in any base */
+#define ToWNumber(c)   (iswdigit(c) ? (c) - L'0' : \
+                        iswupper(c) ? (c) - L'A' + 10 : \
+                        iswlower(c) ? (c) - L'a' + 10 : \
+                        -1             /* "invalid" flag */ \
+                       )
+/* validate converted digit character for specific base */
+#define valid(n, b)    ((n) >= 0 && (n) < (b))
+
+long
+__cdecl
+__wcstol(const wchar_t * __restrict__ nptr, wchar_t ** __restrict__ endptr, 
int base)
+       {
+       register unsigned long  accum;  /* accumulates converted value */
+       register int            n;      /* numeral from digit character */
+       int                     minus;  /* set iff minus sign seen */
+       int                     toobig; /* set iff value overflows */
+
+       if ( endptr != NULL )
+               *endptr = (wchar_t *)nptr;      /* in case no conv performed */
+
+       if ( base < 0 || base == 1 || base > 36 )
+               {
+               errno = EDOM;
+               return 0;               /* unspecified behavior */
+               }
+
+       /* skip initial, possibly empty sequence of white-space w.characters */
+
+       while ( iswspace(*nptr) )
+               ++nptr;
+
+       /* process subject sequence: */
+
+       /* optional sign */
+
+       if ( (minus = *nptr == L'-') || *nptr == L'+' )
+               ++nptr;
+
+       if ( base == 0 )
+        {
+               if ( *nptr == L'0' )
+            {
+                       if ( nptr[1] == L'X' || nptr[1] == L'x' )
+                               base = 16;
+                       else if ( nptr[1] == L'b' || nptr[1] == L'B' )
+                               base = 2;
+                       else
+                               base = 8;
+            }
+               else
+                               base = 10;
+        }
+       /* optional "0x" or "0X" for base 16, "0b" or "0B" for base 2 */
+
+       if ( base == 16 && *nptr == L'0'
+         && (nptr[1] == L'X' || nptr[1] == L'x')
+          )
+               nptr += 2;              /* skip past this prefix */
+       else if ( base == 2 && *nptr == L'0'
+         && (nptr[1] == L'b' || nptr[1] == L'B')
+          )
+               nptr += 2;              /* skip past this prefix */
+
+       /* check whether there is at least one valid digit */
+
+       n = ToWNumber(*nptr);
+       ++nptr;
+
+       if ( !valid(n, base) )
+               return 0;               /* subject seq. not of expected form */
+
+       accum = n;
+
+       for ( toobig = 0; n = ToWNumber(*nptr), valid(n, base); ++nptr )
+               if ( accum > (unsigned long)(LONG_MAX / base + 2) ) /* major 
wrap-around */
+                       toobig = 1;     /* but keep scanning */
+               else
+                       accum = base * accum + n;
+
+       if ( endptr != NULL )
+               *endptr = (wchar_t *)nptr;      /* points to first 
not-valid-digit */
+
+       if ( minus )
+               {
+               if ( accum > (unsigned long)LONG_MAX + 1 )
+                       toobig = 1;
+               }
+       else
+       if ( accum > (unsigned long)LONG_MAX )
+               toobig = 1;
+
+       if ( toobig )
+               {
+               errno = ERANGE;
+               return minus ? LONG_MIN : LONG_MAX;
+               }
+       else
+               return (long)(minus ? -accum : accum);
+       }
+
+long __cdecl __mingw_wcstol(const wchar_t * __restrict__ nptr, wchar_t ** 
__restrict__ endptr, int base)
+    __attribute__((alias("__wcstol")));
\ No newline at end of file
diff --git a/mingw-w64-crt/misc/wcstoul.c b/mingw-w64-crt/misc/wcstoul.c
new file mode 100644
index 000000000..f17323ed0
--- /dev/null
+++ b/mingw-w64-crt/misc/wcstoul.c
@@ -0,0 +1,114 @@
+/**
+ * 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 <errno.h>
+#include <wctype.h>
+#include <wchar.h>
+#include <limits.h>
+
+/* Helper macros */
+
+/* convert digit character to number, in any base */
+#define ToWNumber(c)   (iswdigit(c) ? (c) - L'0' : \
+                        iswupper(c) ? (c) - L'A' + 10 : \
+                        iswlower(c) ? (c) - L'a' + 10 : \
+                        -1             /* "invalid" flag */ \
+                       )
+/* validate converted digit character for specific base */
+#define valid(n, b)    ((n) >= 0 && (n) < (b))
+
+unsigned long
+__cdecl
+__wcstoul(const wchar_t * __restrict__ nptr, wchar_t ** __restrict__ endptr, 
int base)
+       {
+       register unsigned long  accum;  /* accumulates converted value */
+       register int            n;      /* numeral from digit character */
+       int                     minus;  /* set iff minus sign seen (yes!) */
+       int                     toobig; /* set iff value overflows */
+
+       if ( endptr != NULL )
+               *endptr = (wchar_t *)nptr;      /* in case no conversion's 
performed */
+
+       if ( base < 0 || base == 1 || base > 36 )
+               {
+               errno = EDOM;
+               return 0;               /* unspecified behavior */
+               }
+
+       /* skip initial, possibly empty sequence of white-space w.characters */
+
+       while ( iswspace(*nptr) )
+               ++nptr;
+
+       /* process subject sequence: */
+
+       /* optional sign (yes!) */
+
+       if ( (minus = *nptr == L'-') || *nptr == L'+' )
+               ++nptr;
+
+       if ( base == 0 )
+        {
+               if ( *nptr == L'0' )
+            {
+                       if ( nptr[1] == L'X' || nptr[1] == L'x' )
+                               base = 16;
+                       else if ( nptr[1] == L'b' || nptr[1] == L'B' )
+                               base = 2;
+                       else
+                               base = 8;
+            }
+               else
+                               base = 10;
+        }
+       /* optional "0x" or "0X" for base 16, "0b" or "0B" for base 2 */
+
+       if ( base == 16 && *nptr == L'0'
+         && (nptr[1] == L'X' || nptr[1] == L'x')
+          )
+               nptr += 2;              /* skip past this prefix */
+       else if ( base == 2 && *nptr == L'0'
+         && (nptr[1] == L'b' || nptr[1] == L'B')
+          )
+               nptr += 2;              /* skip past this prefix */
+
+       /* check whether there is at least one valid digit */
+
+       n = ToWNumber(*nptr);
+       ++nptr;
+
+       if ( !valid(n, base) )
+               return 0;               /* subject seq. not of expected form */
+
+       accum = n;
+
+       for ( toobig = 0; n = ToWNumber(*nptr), valid(n, base); ++nptr )
+               if ( accum > ULONG_MAX / base )
+                       toobig = 1;     /* but keep scanning */
+               else
+                       {
+                       accum *= base;
+                       if ( accum > ULONG_MAX - n )
+                               toobig = 1; /* but keep scanning */
+                       else
+                               accum += n;
+                       }
+
+       if ( endptr != NULL )
+               *endptr = (wchar_t *)nptr;      /* points to first 
not-valid-digit */
+
+       if ( toobig )
+               {
+               errno = ERANGE;
+               return ULONG_MAX;
+               }
+       else
+               return minus ? -accum : accum;
+       }
+
+unsigned long __cdecl __mingw_wcstoul(const wchar_t * __restrict__ nptr, 
wchar_t ** __restrict__ endptr, int base)
+    __attribute__((alias("__wcstoul")));
\ No newline at end of file
diff --git a/mingw-w64-crt/misc/wcstoumax.c b/mingw-w64-crt/misc/wcstoumax.c
index ad73cb46a..57858e540 100644
--- a/mingw-w64-crt/misc/wcstoumax.c
+++ b/mingw-w64-crt/misc/wcstoumax.c
@@ -69,18 +69,24 @@ wcstoumax(const wchar_t * __restrict__ nptr, wchar_t ** 
__restrict__ endptr, int
             {
                        if ( nptr[1] == L'X' || nptr[1] == L'x' )
                                base = 16;
+                       else if ( nptr[1] == L'b' || nptr[1] == L'B' )
+                               base = 2;
                        else
                                base = 8;
             }
                else
                                base = 10;
         }
-       /* optional "0x" or "0X" for base 16 */
+       /* optional "0x" or "0X" for base 16, "0b" or "0B" for base 2 */
 
        if ( base == 16 && *nptr == L'0'
          && (nptr[1] == L'X' || nptr[1] == L'x')
           )
                nptr += 2;              /* skip past this prefix */
+       else if ( base == 2 && *nptr == L'0'
+         && (nptr[1] == L'b' || nptr[1] == L'B')
+          )
+               nptr += 2;              /* skip past this prefix */
 
        /* check whether there is at least one valid digit */
 
diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h
index 2a4359352..503d061ce 100644
--- a/mingw-w64-headers/crt/stdlib.h
+++ b/mingw-w64-headers/crt/stdlib.h
@@ -400,12 +400,30 @@ float __cdecl __MINGW_NOTHROW strtof(const char * 
__restrict__ _Str,char ** __re
   float __cdecl __mingw_strtof (const char * __restrict__, char ** 
__restrict__);
   double __cdecl __mingw_strtod (const char * __restrict__, char ** 
__restrict__);
   long double __cdecl __mingw_strtold(const char * __restrict__, char ** 
__restrict__);
+  long __cdecl __mingw_strtol(const char * __restrict__, char ** __restrict__, 
int);
+  unsigned long __cdecl __mingw_strtoul(const char * __restrict__, char ** 
__restrict__, int);
 #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);
+#if defined(__USE_MINGW_STRTOX)
+__mingw_ovr
+long __cdecl __MINGW_NOTHROW strtol(const char * __restrict__ _Str,char ** 
__restrict__ _EndPtr,int _Radix)
+{
+  long __cdecl __mingw_strtol(const char * __restrict__, char ** __restrict__, 
int);
+  return __mingw_strtol( _Str, _EndPtr, _Radix);
+}
+
+__mingw_ovr
+unsigned long __cdecl __MINGW_NOTHROW strtoul(const char * __restrict__ 
_Str,char ** __restrict__ _EndPtr,int _Radix)
+{
+  unsigned long __cdecl __mingw_strtoul(const char * __restrict__, char ** 
__restrict__, int);
+  return __mingw_strtoul( _Str, _EndPtr, _Radix);
+}
+#else
   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);
   unsigned long __cdecl strtoul(const char * __restrict__ _Str,char ** 
__restrict__ _EndPtr,int _Radix);
+#endif /* defined(__USE_MINGW_STRTOX) */
+  _CRTIMP long __cdecl _strtol_l(const char * __restrict__ _Str,char ** 
__restrict__ _EndPtr,int _Radix,_locale_t _Locale);
   _CRTIMP unsigned long __cdecl _strtoul_l(const char * __restrict__ _Str,char 
** __restrict__ _EndPtr,int _Radix,_locale_t _Locale);
 #ifndef _CRT_SYSTEM_DEFINED
 #define _CRT_SYSTEM_DEFINED
@@ -491,6 +509,8 @@ float __cdecl __MINGW_NOTHROW strtof(const char * 
__restrict__ _Str,char ** __re
   double __cdecl __mingw_wcstod(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr);
   float __cdecl __mingw_wcstof(const wchar_t * __restrict__ nptr, wchar_t ** 
__restrict__ endptr);
   long double __cdecl __mingw_wcstold(const wchar_t * __restrict__, wchar_t ** 
__restrict__);
+  long __cdecl __mingw_wcstol(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix);
+  unsigned long __cdecl __mingw_wcstoul(const wchar_t * __restrict__ 
_Str,wchar_t ** __restrict__ _EndPtr,int _Radix);
 
 #if defined(__USE_MINGW_STRTOX) && !defined(_UCRT)
   __mingw_ovr
@@ -501,19 +521,27 @@ float __cdecl __MINGW_NOTHROW strtof(const char * 
__restrict__ _Str,char ** __re
   float __cdecl wcstof(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr){
     return __mingw_wcstof(_Str,_EndPtr);
   }
+  __mingw_ovr
+  long __cdecl wcstol(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix){
+    return __mingw_wcstol(_Str,_EndPtr,_Radix);
+  }
+  __mingw_ovr
+  unsigned long __cdecl wcstoul(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix){
+    return __mingw_wcstoul(_Str,_EndPtr,_Radix);
+  }
   /* wcstold is already a mingw implementation */
 #else
   double __cdecl wcstod(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr);
   float __cdecl wcstof(const wchar_t * __restrict__ nptr, wchar_t ** 
__restrict__ endptr);
+  long __cdecl wcstol(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix);
+  unsigned long __cdecl wcstoul(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix);
 #endif /* !defined(__USE_MINGW_STRTOX) || defined(_UCRT) */
 #if !defined __NO_ISOCEXT /* in libmingwex.a */
   long double __cdecl wcstold(const wchar_t * __restrict__, wchar_t ** 
__restrict__);
 #endif /* __NO_ISOCEXT */
   _CRTIMP double __cdecl _wcstod_l(const wchar_t * __restrict__ _Str,wchar_t 
** __restrict__ _EndPtr,_locale_t _Locale);
   _CRTIMP float __cdecl _wcstof_l(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,_locale_t _Locale);
-  long __cdecl wcstol(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix);
   _CRTIMP long __cdecl _wcstol_l(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix,_locale_t _Locale);
-  unsigned long __cdecl wcstoul(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix);
   _CRTIMP unsigned long __cdecl _wcstoul_l(const wchar_t * __restrict__ 
_Str,wchar_t ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale);
   _CRTIMP wchar_t *__cdecl _wgetenv(const wchar_t *_VarName) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 #ifndef _CRT_WSYSTEM_DEFINED
diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h
index 898d0e821..1bb19140d 100644
--- a/mingw-w64-headers/crt/wchar.h
+++ b/mingw-w64-headers/crt/wchar.h
@@ -994,6 +994,8 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf);
   double __cdecl __mingw_wcstod(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr);
   float __cdecl __mingw_wcstof(const wchar_t * __restrict__ nptr, wchar_t ** 
__restrict__ endptr);
   long double __cdecl __mingw_wcstold(const wchar_t * __restrict__, wchar_t ** 
__restrict__);
+  long __cdecl __mingw_wcstol(const wchar_t * __restrict__, wchar_t ** 
__restrict__, int);
+  unsigned long __cdecl __mingw_wcstoul(const wchar_t * __restrict__, wchar_t 
** __restrict__, int);
 
 #if defined(__USE_MINGW_STRTOX) && !defined(_UCRT)
   __mingw_ovr
@@ -1012,9 +1014,20 @@ __MINGW_ASM_CALL(__mingw_vsnwprintf);
 #if !defined __NO_ISOCEXT /* in libmingwex.a */
   long double __cdecl wcstold (const wchar_t * __restrict__, wchar_t ** 
__restrict__);
 #endif /* __NO_ISOCEXT */
+#if defined(__USE_MINGW_STRTOX)
+  __mingw_ovr
+  long __cdecl wcstol(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix){
+    return __mingw_wcstol(_Str,_EndPtr,_Radix);
+  }
+  __mingw_ovr
+  unsigned long __cdecl wcstoul(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix){
+    return __mingw_wcstoul(_Str,_EndPtr,_Radix);
+  }
+#else
   long __cdecl wcstol(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix);
-  _CRTIMP long __cdecl _wcstol_l(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix,_locale_t _Locale);
   unsigned long __cdecl wcstoul(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix);
+#endif /* defined(__USE_MINGW_STRTOX) */
+  _CRTIMP long __cdecl _wcstol_l(const wchar_t * __restrict__ _Str,wchar_t ** 
__restrict__ _EndPtr,int _Radix,_locale_t _Locale);
   _CRTIMP unsigned long __cdecl _wcstoul_l(const wchar_t * __restrict__ 
_Str,wchar_t ** __restrict__ _EndPtr,int _Radix,_locale_t _Locale);
   _CRTIMP wchar_t *__cdecl _wgetenv(const wchar_t *_VarName) 
__MINGW_ATTRIB_DEPRECATED_SEC_WARN;
 #ifndef _CRT_WSYSTEM_DEFINED
-- 
2.47.3



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

Reply via email to