From: Daniel Lehman dlehman25@gmail.com
--- dlls/oleaut32/tests/vartype.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c index c6772a7be14..e58e840a6a9 100644 --- a/dlls/oleaut32/tests/vartype.c +++ b/dlls/oleaut32/tests/vartype.c @@ -4549,10 +4549,12 @@ static void test_VarBstrFromR4(void)
{ 1.000e16, L"1E+16" }, { 1.234e16, L"1.234E+16" }, + { 3.14159300, L"3.141593" }, + { 3.14159265, L"3.141593" }, { M_PI, L"3.141593" }, - { 37.86626157, L"37.86626" }, - { 137.86626157, L"137.8663" }, - { 1137.86626157, L"1137.866" }, + { 12.34567890, L"12.34568" }, + { 123.45678901, L"123.4568" }, + { 1234.56789012, L"1234.568" },
{ 0.0, NULL } }; @@ -4575,7 +4577,12 @@ static void test_VarBstrFromR4(void)
{ 1.000e16, L"1E+16" }, { 1.234e16, L"1,234E+16" }, + { 3.14159300, L"3,141593" }, + { 3.14159265, L"3,141593" }, { M_PI, L"3,141593" }, + { 12.34567890, L"12,34568" }, + { 123.45678901, L"123,4568" }, + { 1234.56789012, L"1234,568" },
{ 0.0, NULL } }; @@ -4693,6 +4700,12 @@ static void test_VarBstrFromR8(void)
{ 1.000e16, L"1E+16" }, { 1.234e16, L"1.234E+16" }, + { 3.141592653590000, L"3.14159265359" }, + { 3.141592653589793, L"3.14159265358979" }, + { M_PI, L"3.14159265358979" }, + { 12.345678901234567, L"12.3456789012346" }, + { 123.456789012345678, L"123.456789012346" }, + { 1234.567890123456789, L"1234.56789012346" },
{ 0.0, NULL } }; @@ -4715,6 +4728,12 @@ static void test_VarBstrFromR8(void)
{ 1.000e16, L"1E+16" }, { 1.234e16, L"1,234E+16" }, + { 3.141592653590000, L"3,14159265359" }, + { 3.141592653589793, L"3,14159265358979" }, + { M_PI, L"3,14159265358979" }, + { 12.345678901234567, L"12,3456789012346" }, + { 123.456789012345678, L"123,456789012346" }, + { 1234.567890123456789, L"1234,56789012346" },
{ 0.0, NULL } };
From: Daniel Lehman dlehman25@gmail.com
--- dlls/oleaut32/tests/vartype.c | 22 ++++++++-------------- dlls/oleaut32/vartype.c | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c index e58e840a6a9..795446d0987 100644 --- a/dlls/oleaut32/tests/vartype.c +++ b/dlls/oleaut32/tests/vartype.c @@ -4525,7 +4525,6 @@ struct r4_test { float val; const wchar_t *expect; - BOOL todo; };
static void test_VarBstrFromR4(void) @@ -4536,8 +4535,8 @@ static void test_VarBstrFromR4(void) { 0.05, L"0.05" }, { 0.005, L"0.005" }, { 0.0005, L"0.0005" }, - { 0.00005, L"0.00005", TRUE }, - { 0.000005, L"0.000005", TRUE }, + { 0.00005, L"0.00005" }, + { 0.000005, L"0.000005" },
{ 1.0e8, L"1E+08" }, { 1.0e12, L"1E+12" }, @@ -4564,8 +4563,8 @@ static void test_VarBstrFromR4(void) { 0.05, L"0,05" }, { 0.005, L"0,005" }, { 0.0005, L"0,0005" }, - { 0.00005, L"0,00005", TRUE }, - { 0.000005, L"0,000005", TRUE }, + { 0.00005, L"0,00005" }, + { 0.000005, L"0,000005" },
{ 1.0e8, L"1E+08" }, { 1.0e12, L"1E+12" }, @@ -4648,7 +4647,6 @@ static void test_VarBstrFromR4(void) ok(hres == S_OK, "got hres 0x%08lx\n", hres); if (bstr) { - todo_wine_if(cur->todo) ok(wcscmp(bstr, cur->expect) == 0, "expected '%ls', got '%ls'\n", cur->expect, bstr); SysFreeString(bstr); } @@ -4664,7 +4662,6 @@ static void test_VarBstrFromR4(void) ok(hres == S_OK, "got hres 0x%08lx\n", hres); if (bstr) { - todo_wine_if(cur->todo) ok(wcscmp(bstr, cur->expect) == 0, "expected '%ls', got '%ls'\n", cur->expect, bstr); SysFreeString(bstr); } @@ -4676,7 +4673,6 @@ struct r8_test { double val; const wchar_t *expect; - BOOL todo; };
static void test_VarBstrFromR8(void) @@ -4687,8 +4683,8 @@ static void test_VarBstrFromR8(void) { 0.05, L"0.05" }, { 0.005, L"0.005" }, { 0.0005, L"0.0005" }, - { 0.00005, L"0.00005", TRUE }, - { 0.000005, L"0.000005", TRUE }, + { 0.00005, L"0.00005" }, + { 0.000005, L"0.000005" },
{ 1.0e8, L"100000000" }, { 1.0e12, L"1000000000000" }, @@ -4715,8 +4711,8 @@ static void test_VarBstrFromR8(void) { 0.05, L"0,05" }, { 0.005, L"0,005" }, { 0.0005, L"0,0005" }, - { 0.00005, L"0,00005", TRUE }, - { 0.000005, L"0,000005", TRUE }, + { 0.00005, L"0,00005" }, + { 0.000005, L"0,000005" },
{ 1.0e8, L"100000000" }, { 1.0e12, L"1000000000000" }, @@ -4751,7 +4747,6 @@ static void test_VarBstrFromR8(void) ok(hres == S_OK, "got hres 0x%08lx\n", hres); if (bstr) { - todo_wine_if(cur->todo) ok(wcscmp(bstr, cur->expect) == 0, "expected '%ls', got '%ls'\n", cur->expect, bstr); SysFreeString(bstr); } @@ -4767,7 +4762,6 @@ static void test_VarBstrFromR8(void) ok(hres == S_OK, "got hres 0x%08lx\n", hres); if (bstr) { - todo_wine_if(cur->todo) ok(wcscmp(bstr, cur->expect) == 0, "expected '%ls', got '%ls'\n", cur->expect, bstr); SysFreeString(bstr); } diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c index 3ab404f33f8..d11fb41d1b3 100644 --- a/dlls/oleaut32/vartype.c +++ b/dlls/oleaut32/vartype.c @@ -6538,16 +6538,24 @@ static BSTR VARIANT_BstrReplaceDecimal(const WCHAR * buff, LCID lcid, ULONG dwFl }
static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags, - BSTR* pbstrOut, LPCWSTR lpszFormat) + BSTR* pbstrOut, int ndigits) { _locale_t locale; - WCHAR buff[256]; + WCHAR *e, buff[256]; + int len;
if (!pbstrOut) return E_INVALIDARG;
if (!(locale = _create_locale(LC_ALL, "C"))) return E_OUTOFMEMORY; - _swprintf_l(buff, ARRAY_SIZE(buff), lpszFormat, locale, dblIn); + len = _swprintf_l(buff, ARRAY_SIZE(buff), L"%.*G", locale, ndigits, dblIn); + e = wcschr(buff, 'E'); + if (e && labs(wcstol(e+1, NULL, 10)) < ndigits) + { + len = _swprintf_l(buff, ARRAY_SIZE(buff), L"%.*f", locale, ndigits, dblIn); + while (len > 0 && (buff[len-1] == '0')) len--; + } + buff[len] = 0; _free_locale(locale);
/* Negative zeroes are disallowed (some applications depend on this). @@ -6598,7 +6606,7 @@ static HRESULT VARIANT_BstrFromReal(DOUBLE dblIn, LCID lcid, ULONG dwFlags, */ HRESULT WINAPI VarBstrFromR4(FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut) { - return VARIANT_BstrFromReal(fltIn, lcid, dwFlags, pbstrOut, L"%.7G"); + return VARIANT_BstrFromReal(fltIn, lcid, dwFlags, pbstrOut, 7); }
/****************************************************************************** @@ -6619,7 +6627,7 @@ HRESULT WINAPI VarBstrFromR4(FLOAT fltIn, LCID lcid, ULONG dwFlags, BSTR* pbstrO */ HRESULT WINAPI VarBstrFromR8(double dblIn, LCID lcid, ULONG dwFlags, BSTR* pbstrOut) { - return VARIANT_BstrFromReal(dblIn, lcid, dwFlags, pbstrOut, L"%.15G"); + return VARIANT_BstrFromReal(dblIn, lcid, dwFlags, pbstrOut, 15); }
/******************************************************************************
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=143082
Your paranoid android.
=== debian11 (32 bit report) ===
oleaut32: varformat.c:365: Test failed: VT 5|0x0000 Format #####.####e-0%: expected 0x00000000, '30401.e-15%', got 0x00000000, '30400.e-15%'
=== debian11b (64 bit WoW report) ===
oleaut32: varformat.c:365: Test failed: VT 5|0x0000 Format #####.####e-0%: expected 0x00000000, '30401.e-15%', got 0x00000000, '30400.e-15%'