Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51452 Signed-off-by: Francois Gouget fgouget@codeweavers.com --- This is only a partial fix for bug 51452: two character currencies should now work but longer currencies still fail. --- dlls/oleaut32/tests/vartest.c | 7 +++---- dlls/oleaut32/variant.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 136d2ddd521..52a27750f45 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -2154,14 +2154,13 @@ static void test_VarParseNumFromStrMisc(void) /* 2 Polish zloty */ lcid = MAKELCID(MAKELANGID(LANG_POLISH,SUBLANG_POLISH_POLAND),SORT_DEFAULT); WCONVERT(L"z\x142\x32", NUMPRS_CURRENCY|NUMPRS_USE_ALL); - todo_wine EXPECT(1,NUMPRS_CURRENCY|NUMPRS_USE_ALL,NUMPRS_CURRENCY,3,0,0); - todo_wine EXPECT2(2,FAILDIG); + EXPECT(1,NUMPRS_CURRENCY|NUMPRS_USE_ALL,NUMPRS_CURRENCY,3,0,0); + EXPECT2(2,FAILDIG);
/* Multi-character currencies can be repeated too "zl2zlzl" */ WCONVERT(L"z\x142\x32z\x142z\x142", NUMPRS_CURRENCY|NUMPRS_USE_ALL); todo_wine EXPECT(1,NUMPRS_CURRENCY|NUMPRS_USE_ALL,NUMPRS_CURRENCY,7,0,0); - todo_wine EXPECTRGB(0,2); - EXPECTRGB(1,FAILDIG); + EXPECT2(2,FAILDIG);
lcid = MAKELCID(MAKELANGID(LANG_FRENCH,SUBLANG_FRENCH_SWISS),SORT_DEFAULT); WCONVERT(L"3CHF", NUMPRS_CURRENCY|NUMPRS_USE_ALL); diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index fdc402c7a62..71c3204e0a0 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -1669,8 +1669,8 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla (!chars.cCurrencyLocal2 || lpszStr[1] == chars.cCurrencyLocal2)) { pNumprs->dwOutFlags |= NUMPRS_CURRENCY; - cchUsed++; - lpszStr++; + cchUsed += chars.cCurrencyLocal2 ? 2 : 1; + lpszStr += chars.cCurrencyLocal2 ? 2 : 1; /* Only accept currency characters */ chars.cDecimalPoint = chars.cCurrencyDecimalPoint; chars.cDigitSeparator = chars.cCurrencyDigitSeparator;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51450 Signed-off-by: Francois Gouget fgouget@codeweavers.com --- This is a partial fix for bug 51450: it still needs better support for non-breaking vs. regular spaces. The test on line 2030 was working because Wine did not support trailing currency symbols at all and now it fails because Wine does not correctly handle sThousand vs. space aliasing. --- dlls/oleaut32/tests/vartest.c | 16 ++++++++-------- dlls/oleaut32/variant.c | 8 ++++++++ 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 52a27750f45..489ab9f650c 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -1642,7 +1642,7 @@ static void test_VarParseNumFromStrEn(void)
/* With flag, but is allowed after the amount and can even be repeated! */ CONVERT("$11$$", NUMPRS_CURRENCY|NUMPRS_USE_ALL); - todo_wine EXPECT(2,NUMPRS_CURRENCY|NUMPRS_USE_ALL,NUMPRS_CURRENCY,5,0,0); + EXPECT(2,NUMPRS_CURRENCY|NUMPRS_USE_ALL,NUMPRS_CURRENCY,5,0,0); EXPECT2(1,1); EXPECTRGB(2,FAILDIG);
@@ -1688,7 +1688,7 @@ static void test_VarParseNumFromStrEn(void)
/* With flag, unless explicitly allowed */ WCONVERT(wstr, NUMPRS_CURRENCY|NUMPRS_TRAILING_WHITE|NUMPRS_USE_ALL); - todo_wine EXPECT(2,NUMPRS_CURRENCY|NUMPRS_TRAILING_WHITE|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_TRAILING_WHITE,4,0,0); + EXPECT(2,NUMPRS_CURRENCY|NUMPRS_TRAILING_WHITE|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_TRAILING_WHITE,4,0,0); EXPECT2(1,1); EXPECTRGB(2,FAILDIG);
@@ -2006,7 +2006,7 @@ static void test_VarParseNumFromStrFr(void)
/* With flag, consumes all currency signs! "E12EE" */ WCONVERT(L"\x20ac\x31\x32\x20ac\x20ac", NUMPRS_CURRENCY|NUMPRS_USE_ALL); - todo_wine EXPECT(2,NUMPRS_CURRENCY|NUMPRS_USE_ALL,NUMPRS_CURRENCY,5,0,0); + EXPECT(2,NUMPRS_CURRENCY|NUMPRS_USE_ALL,NUMPRS_CURRENCY,5,0,0); EXPECT2(1,2); EXPECTRGB(2,FAILDIG);
@@ -2025,12 +2025,12 @@ static void test_VarParseNumFromStrFr(void) if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */) { /* Spaces aliased to thousands separator are never allowed! */ - EXPECTFAIL; + todo_wine EXPECTFAIL; } else { /* The others behave normally */ - todo_wine EXPECT(2,NUMPRS_CURRENCY|NUMPRS_TRAILING_WHITE|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_TRAILING_WHITE,4,0,0); + EXPECT(2,NUMPRS_CURRENCY|NUMPRS_TRAILING_WHITE|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_TRAILING_WHITE,4,0,0); EXPECT2(1,2); EXPECTRGB(2,FAILDIG); } @@ -2039,7 +2039,7 @@ static void test_VarParseNumFromStrFr(void) if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */) { /* Spaces aliased to thousands separator are never allowed! */ - todo_wine EXPECT(2,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,4,0,0); + todo_wine_if(i==0) EXPECT(2,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,4,0,0); EXPECT2(1,2); EXPECTRGB(2,FAILDIG); } @@ -2060,7 +2060,7 @@ static void test_VarParseNumFromStrFr(void)
/* With flag and decimal flag, consumes decimal point and following digits */ WCONVERT(L"12,1\x20ac", NUMPRS_CURRENCY|NUMPRS_DECIMAL|NUMPRS_USE_ALL); - todo_wine EXPECT(3,NUMPRS_CURRENCY|NUMPRS_DECIMAL|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,5,0,-1); + EXPECT(3,NUMPRS_CURRENCY|NUMPRS_DECIMAL|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,5,0,-1); EXPECT2(1,2); EXPECTRGB(2,1); EXPECTRGB(3,FAILDIG); @@ -2159,7 +2159,7 @@ static void test_VarParseNumFromStrMisc(void)
/* Multi-character currencies can be repeated too "zl2zlzl" */ WCONVERT(L"z\x142\x32z\x142z\x142", NUMPRS_CURRENCY|NUMPRS_USE_ALL); - todo_wine EXPECT(1,NUMPRS_CURRENCY|NUMPRS_USE_ALL,NUMPRS_CURRENCY,7,0,0); + EXPECT(1,NUMPRS_CURRENCY|NUMPRS_USE_ALL,NUMPRS_CURRENCY,7,0,0); EXPECT2(2,FAILDIG);
lcid = MAKELCID(MAKELANGID(LANG_FRENCH,SUBLANG_FRENCH_SWISS),SORT_DEFAULT); diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index 71c3204e0a0..208d5b63c8f 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -1941,6 +1941,14 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla lpszStr++; pNumprs->dwOutFlags |= NUMPRS_NEG; } + else if (pNumprs->dwInFlags & NUMPRS_CURRENCY && + *lpszStr == chars.cCurrencyLocal && + (!chars.cCurrencyLocal2 || lpszStr[1] == chars.cCurrencyLocal2)) + { + pNumprs->dwOutFlags |= NUMPRS_CURRENCY; + cchUsed += chars.cCurrencyLocal2 ? 2 : 1; + lpszStr += chars.cCurrencyLocal2 ? 2 : 1; + } else break; }