Commit 45001578 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Introduce fpnum structure that can be used to represent 64 and 80-bit double.

parent 74958219
......@@ -1197,7 +1197,6 @@ char* __cdecl MSVCRT_strstr(const char*, const char*);
unsigned int __cdecl MSVCRT__get_output_format(void);
char* __cdecl MSVCRT_strtok_s(char*, const char*, char**);
char* __cdecl MSVCRT__itoa(int, char*, int);
double parse_double(MSVCRT_wchar_t (*)(void*), void (*)(void*), void*, MSVCRT_pthreadlocinfo, int*);
int __cdecl MSVCRT_wcsncmp(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, MSVCRT_size_t);
int __cdecl MSVCRT__wcsnicmp(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, MSVCRT_size_t);
int __cdecl MSVCRT_towlower(MSVCRT_wint_t);
......@@ -1215,6 +1214,24 @@ MSVCRT_wchar_t* __cdecl MSVCRT_wcscpy(MSVCRT_wchar_t*, const MSVCRT_wchar_t*);
MSVCRT_wchar_t* __cdecl MSVCRT_wcschr(const MSVCRT_wchar_t*, MSVCRT_wchar_t);
MSVCRT_wchar_t* __cdecl MSVCRT_wcscat(MSVCRT_wchar_t*, const MSVCRT_wchar_t*);
enum fpmod {
FP_ROUND_ZERO, /* only used when dropped part contains only zeros */
FP_ROUND_DOWN,
FP_ROUND_EVEN,
FP_ROUND_UP,
FP_VAL_INFINITY,
FP_VAL_NAN
};
struct fpnum {
int sign;
int exp;
ULONGLONG m;
enum fpmod mod;
};
struct fpnum fpnum_parse(MSVCRT_wchar_t (*)(void*), void (*)(void*),
void*, MSVCRT_pthreadlocinfo) DECLSPEC_HIDDEN;
int fpnum_double(struct fpnum*, double*) DECLSPEC_HIDDEN;
/* Maybe one day we'll enable the invalid parameter handlers with the full set of information (msvcrXXd)
* #define MSVCRT_INVALID_PMT(x) MSVCRT_call_invalid_parameter_handler(x, __FUNCTION__, __FILE__, __LINE__, 0)
* #define MSVCRT_CHECK_PMT(x) ((x) ? TRUE : MSVCRT_INVALID_PMT(#x),FALSE)
......
......@@ -388,6 +388,7 @@ _FUNCTION_ {
struct _STRTOD_NAME_(strtod_scanf_ctx) ctx = {locinfo, file, width};
#endif
int negative = 0;
struct fpnum fp;
double cur;
/* skip initial whitespace */
......@@ -403,8 +404,9 @@ _FUNCTION_ {
if(ctx.length > length-consumed+1) ctx.length = length-consumed+1;
#endif
cur = parse_double(_STRTOD_NAME_(strtod_scanf_get),
_STRTOD_NAME_(strtod_scanf_unget), &ctx, locinfo, NULL);
fp = fpnum_parse(_STRTOD_NAME_(strtod_scanf_get),
_STRTOD_NAME_(strtod_scanf_unget), &ctx, locinfo);
fpnum_double(&fp, &cur);
if(!rd && ctx.err) {
_UNLOCK_FILE_(file);
return _EOF_RET;
......
......@@ -510,7 +510,9 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
{
MSVCRT_pthreadlocinfo locinfo;
const MSVCRT_wchar_t *beg, *p;
struct fpnum fp;
double ret;
int err;
if (!MSVCRT_CHECK_PMT(str != NULL)) {
if (end) *end = NULL;
......@@ -527,8 +529,11 @@ double CDECL MSVCRT__wcstod_l(const MSVCRT_wchar_t* str, MSVCRT_wchar_t** end,
p++;
beg = p;
ret = parse_double(strtod_wstr_get, strtod_wstr_unget, &p, locinfo, NULL);
fp = fpnum_parse(strtod_wstr_get, strtod_wstr_unget, &p, locinfo);
if (end) *end = (p == beg ? (MSVCRT_wchar_t*)str : (MSVCRT_wchar_t*)p);
err = fpnum_double(&fp, &ret);
if(err) *MSVCRT__errno() = err;
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment