Francois Gouget : oleaut32: VarParseNumFromStr() accepts trailing currency symbols.
Alexandre Julliard
julliard at winehq.org
Fri Feb 25 07:30:22 CST 2022
Module: wine
Branch: oldstable
Commit: bf217a1a47f4aa34e41c92b5c4f279abf077de63
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bf217a1a47f4aa34e41c92b5c4f279abf077de63
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Tue Jul 20 14:02:12 2021 +0200
oleaut32: VarParseNumFromStr() accepts trailing currency symbols.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51450
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit e02a7e579cc48079d70f2ef00957255d28d119d6)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
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 c2cf93caf6e..bf6152554ad 100644
--- a/dlls/oleaut32/tests/vartest.c
+++ b/dlls/oleaut32/tests/vartest.c
@@ -1641,7 +1641,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);
@@ -1687,7 +1687,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);
@@ -2005,7 +2005,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);
@@ -2024,12 +2024,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);
}
@@ -2038,7 +2038,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);
}
@@ -2059,7 +2059,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);
@@ -2158,7 +2158,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 143895bde2f..b80a8537380 100644
--- a/dlls/oleaut32/variant.c
+++ b/dlls/oleaut32/variant.c
@@ -1940,6 +1940,14 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
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;
}
More information about the wine-cvs
mailing list