• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <windows.h>
2 #include <stdio.h>
3 
4 long double __cdecl
5 __mingw_wcstold (const wchar_t * __restrict__ _Str, wchar_t ** __restrict__ _EndPtr);
6 
7 long double __cdecl
__mingw_wcstold(const wchar_t * __restrict__ _Str,wchar_t ** __restrict__ _EndPtr)8 __mingw_wcstold (const wchar_t * __restrict__ _Str, wchar_t ** __restrict__ _EndPtr)
9 {
10   long double r;
11   char *n, *ep = NULL;
12   size_t l, l2;
13 
14   l = WideCharToMultiByte(CP_UTF8, 0, _Str, -1, NULL, 0, NULL, NULL);
15   n = alloca (l + 1);
16   if (l != 0) WideCharToMultiByte (CP_UTF8, 0, _Str, -1, n, l, NULL, NULL);
17   n[l] = 0;
18   r = __mingw_strtold (n, &ep);
19   if (ep != NULL)
20   {
21     *ep = 0;
22     l2 = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, n, -1, NULL, 0);
23     if (l2 > 0)
24       l2 -= 1; /* Remove zero terminator from length.  */
25     if (_EndPtr)
26       *_EndPtr = (wchar_t *) &_Str[l2];
27   }
28   else if (_EndPtr)
29    *_EndPtr = NULL;
30   return r;
31 }
32 
33