master
 1#include <windows.h>
 2#include <stdio.h>
 3
 4float __cdecl
 5__mingw_wcstof (const wchar_t * __restrict__ _Str, wchar_t ** __restrict__ _EndPtr);
 6
 7float __cdecl
 8__mingw_wcstof (const wchar_t * __restrict__ _Str, wchar_t ** __restrict__ _EndPtr)
 9{
10  float 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_strtof (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) *_EndPtr = (wchar_t *) &_Str[l2];
26  }
27  else
28   if (_EndPtr) *_EndPtr = NULL;
29  return r;
30}
31