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

oleaut32: Take lcid into account while parsing input variant in VARIANT_FormatNumber.

parent 0e92f07f
...@@ -558,6 +558,40 @@ static void test_VarWeekdayName(void) ...@@ -558,6 +558,40 @@ static void test_VarWeekdayName(void)
} }
} }
static void test_VarFormatFromTokens(void)
{
static WCHAR number_fmt[] = {'#','#','#',',','#','#','0','.','0','0',0};
static const WCHAR number[] = {'6',',','9','0',0};
static const WCHAR number_us[] = {'6','9','0','.','0','0',0};
BYTE buff[256];
LCID lcid;
VARIANT var;
BSTR bstr;
HRESULT hres;
V_VT(&var) = VT_BSTR;
V_BSTR(&var) = SysAllocString(number);
lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
hres = VarTokenizeFormatString(number_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
hres = VarFormatFromTokens(&var, number_fmt, buff, 0, &bstr, lcid);
ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
ok(!strcmpW(bstr, number_us), "incorrectly formatted number: %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
lcid = MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT);
hres = VarTokenizeFormatString(number_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
hres = VarFormatFromTokens(&var, number_fmt, buff, 0, &bstr, lcid);
ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
ok(!strcmpW(bstr, number), "incorrectly formatted number: %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
VariantClear(&var);
}
START_TEST(varformat) START_TEST(varformat)
{ {
hOleaut32 = GetModuleHandleA("oleaut32.dll"); hOleaut32 = GetModuleHandleA("oleaut32.dll");
...@@ -567,4 +601,5 @@ START_TEST(varformat) ...@@ -567,4 +601,5 @@ START_TEST(varformat)
test_VarFormatNumber(); test_VarFormatNumber();
test_VarFormat(); test_VarFormat();
test_VarWeekdayName(); test_VarWeekdayName();
test_VarFormatFromTokens();
} }
...@@ -1212,13 +1212,13 @@ static HRESULT VARIANT_FormatNumber(LPVARIANT pVarIn, LPOLESTR lpszFormat, ...@@ -1212,13 +1212,13 @@ static HRESULT VARIANT_FormatNumber(LPVARIANT pVarIn, LPOLESTR lpszFormat,
else else
{ {
/* Get a number string from pVarIn, and parse it */ /* Get a number string from pVarIn, and parse it */
hRes = VariantChangeTypeEx(&vString, pVarIn, LCID_US, VARIANT_NOUSEROVERRIDE, VT_BSTR); hRes = VariantChangeTypeEx(&vString, pVarIn, lcid, VARIANT_NOUSEROVERRIDE, VT_BSTR);
if (FAILED(hRes)) if (FAILED(hRes))
return hRes; return hRes;
np.cDig = sizeof(rgbDig); np.cDig = sizeof(rgbDig);
np.dwInFlags = NUMPRS_STD; np.dwInFlags = NUMPRS_STD;
hRes = VarParseNumFromStr(V_BSTR(&vString), LCID_US, 0, &np, rgbDig); hRes = VarParseNumFromStr(V_BSTR(&vString), lcid, 0, &np, rgbDig);
if (FAILED(hRes)) if (FAILED(hRes))
return hRes; return hRes;
......
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