msvcr120: Implement strtof and _strtof_l.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Bernhard Übelacker 2016-02-18 16:10:00 +01:00 committed by Alexandre Julliard
parent aff5d2c1f3
commit 78716aebf8
6 changed files with 73 additions and 8 deletions

View File

@ -30,7 +30,7 @@
@ cdecl _ltow(long ptr long) ucrtbase._ltow
@ cdecl _ltow_s(long ptr long long) ucrtbase._ltow_s
@ cdecl _strtod_l(str ptr ptr) ucrtbase._strtod_l
@ stub _strtof_l
@ cdecl _strtof_l(str ptr ptr) ucrtbase._strtof_l
@ cdecl -ret64 _strtoi64(str ptr long) ucrtbase._strtoi64
@ cdecl -ret64 _strtoi64_l(str ptr long ptr) ucrtbase._strtoi64_l
@ stub _strtoimax_l
@ -93,7 +93,7 @@
@ cdecl mbstowcs_s(ptr ptr long str long) ucrtbase.mbstowcs_s
@ cdecl mbtowc(ptr str long) ucrtbase.mbtowc
@ cdecl strtod(str ptr) ucrtbase.strtod
@ stub strtof
@ cdecl strtof(str ptr) ucrtbase.strtof
@ stub strtoimax
@ cdecl strtol(str ptr long) ucrtbase.strtol
@ stub strtold

View File

@ -1731,7 +1731,7 @@
@ cdecl _strtime(ptr) MSVCRT__strtime
@ cdecl _strtime_s(ptr long)
@ cdecl _strtod_l(str ptr ptr) MSVCRT_strtod_l
@ stub _strtof_l
@ cdecl _strtof_l(str ptr ptr) MSVCRT__strtof_l
@ cdecl -ret64 _strtoi64(str ptr long) MSVCRT_strtoi64
@ cdecl -ret64 _strtoi64_l(str ptr long ptr) MSVCRT_strtoi64_l
@ stub _strtoimax_l
@ -2386,7 +2386,7 @@
@ cdecl strspn(str str) ntdll.strspn
@ cdecl strstr(str str) MSVCRT_strstr
@ cdecl strtod(str ptr) MSVCRT_strtod
@ stub strtof
@ cdecl strtof(str ptr) MSVCRT_strtof
@ stub strtoimax
@ cdecl strtok(str str) MSVCRT_strtok
@ cdecl strtok_s(ptr str ptr) MSVCRT_strtok_s

View File

@ -21,6 +21,8 @@
#include <stdlib.h>
#include <wchar.h>
#include <stdio.h>
#include <float.h>
#include <limits.h>
#include <windef.h>
#include <winbase.h>
@ -83,6 +85,8 @@ static wchar_t** (CDECL *p____lc_locale_name_func)(void);
static unsigned int (CDECL *p__GetConcurrency)(void);
static void* (CDECL *p__W_Gettnames)(void);
static void (CDECL *p_free)(void*);
static float (CDECL *p_strtof)(const char *, char **);
static int (CDECL *p__finite)(double);
static BOOL init(void)
{
@ -105,6 +109,8 @@ static BOOL init(void)
p__GetConcurrency = (void*)GetProcAddress(module,"?_GetConcurrency@details@Concurrency@@YAIXZ");
p__W_Gettnames = (void*)GetProcAddress(module, "_W_Gettnames");
p_free = (void*)GetProcAddress(module, "free");
p_strtof = (void*)GetProcAddress(module, "strtof");
p__finite = (void*)GetProcAddress(module, "_finite");
return TRUE;
}
@ -321,6 +327,48 @@ static void test__W_Gettnames(void)
p_setlocale(LC_ALL, "C");
}
static void test__strtof(void)
{
const char float1[] = "12.0";
const char float2[] = "3.402823466e+38"; /* FLT_MAX */
const char float3[] = "-3.402823466e+38";
const char float4[] = "1.7976931348623158e+308"; /* DBL_MAX */
char *end;
float f;
f = p_strtof(float1, &end);
ok(f == 12.0, "f = %lf\n", f);
ok(end == float1+4, "incorrect end (%d)\n", (int)(end-float1));
f = p_strtof(float2, &end);
ok(f == FLT_MAX, "f = %lf\n", f);
ok(end == float2+15, "incorrect end (%d)\n", (int)(end-float2));
f = p_strtof(float3, &end);
ok(f == -FLT_MAX, "f = %lf\n", f);
ok(end == float3+16, "incorrect end (%d)\n", (int)(end-float3));
f = p_strtof(float4, &end);
ok(!p__finite(f), "f = %lf\n", f);
ok(end == float4+23, "incorrect end (%d)\n", (int)(end-float4));
f = p_strtof("inf", NULL);
ok(f == 0, "f = %lf\n", f);
f = p_strtof("INF", NULL);
ok(f == 0, "f = %lf\n", f);
f = p_strtof("1.#inf", NULL);
ok(f == 1, "f = %lf\n", f);
f = p_strtof("INFINITY", NULL);
ok(f == 0, "f = %lf\n", f);
f = p_strtof("0x12", NULL);
ok(f == 0, "f = %lf\n", f);
}
START_TEST(msvcr120)
{
if (!init()) return;
@ -330,4 +378,5 @@ START_TEST(msvcr120)
test____lc_locale_name_func();
test__GetConcurrency();
test__W_Gettnames();
test__strtof();
}

View File

@ -1442,7 +1442,7 @@
@ cdecl _strtime(ptr) msvcr120._strtime
@ cdecl _strtime_s(ptr long) msvcr120._strtime_s
@ cdecl _strtod_l(str ptr ptr) msvcr120._strtod_l
@ stub _strtof_l
@ cdecl _strtof_l(str ptr ptr) msvcr120._strtof_l
@ cdecl -ret64 _strtoi64(str ptr long) msvcr120._strtoi64
@ cdecl -ret64 _strtoi64_l(str ptr long ptr) msvcr120._strtoi64_l
@ stub _strtoimax_l
@ -2049,7 +2049,7 @@
@ cdecl strspn(str str) msvcr120.strspn
@ cdecl strstr(str str) msvcr120.strstr
@ cdecl strtod(str ptr) msvcr120.strtod
@ stub strtof
@ cdecl strtof(str ptr) msvcr120.strtof
@ stub strtoimax
@ cdecl strtok(str str) msvcr120.strtok
@ cdecl strtok_s(ptr str ptr) msvcr120.strtok_s

View File

@ -496,6 +496,22 @@ double CDECL MSVCRT_strtod( const char *str, char **end )
return MSVCRT_strtod_l( str, end, NULL );
}
/*********************************************************************
* strtof_l (MSVCR120.@)
*/
float CDECL MSVCRT__strtof_l( const char *str, char **end, MSVCRT__locale_t locale )
{
return MSVCRT_strtod_l(str, end, locale);
}
/*********************************************************************
* strtof (MSVCR120.@)
*/
float CDECL MSVCRT_strtof( const char *str, char **end )
{
return MSVCRT__strtof_l(str, end, NULL);
}
/*********************************************************************
* atof (MSVCRT.@)
*/

View File

@ -1949,7 +1949,7 @@
@ cdecl _strtime(ptr) MSVCRT__strtime
@ cdecl _strtime_s(ptr long)
@ cdecl _strtod_l(str ptr ptr) MSVCRT_strtod_l
@ stub _strtof_l
@ cdecl _strtof_l(str ptr ptr) MSVCRT__strtof_l
@ cdecl -ret64 _strtoi64(str ptr long) MSVCRT_strtoi64
@ cdecl -ret64 _strtoi64_l(str ptr long ptr) MSVCRT_strtoi64_l
@ stub _strtoimax_l
@ -2516,7 +2516,7 @@
@ cdecl strspn(str str) ntdll.strspn
@ cdecl strstr(str str) MSVCRT_strstr
@ cdecl strtod(str ptr) MSVCRT_strtod
@ stub strtof
@ cdecl strtof(str ptr) MSVCRT_strtof
@ stub strtoimax
@ cdecl strtok(str str) MSVCRT_strtok
@ cdecl strtok_s(ptr str ptr) MSVCRT_strtok_s