Commit c50dff86 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

oleaut32: Setting sThousand to a non-breaking space also matches regular spaces.

As the test_VarParseNumFromStrMisc() tests show the converse is not true. Note also that the " 1 000" test was failing as expected because in the French locale Wine was not recognizing regular spaces as thousands separators. Now it does and Wine incorrectly allows them before the first digit, just like it does for the English tests. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51450Signed-off-by: 's avatarFrancois Gouget <fgouget@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 4eb35fb2
...@@ -1916,7 +1916,6 @@ static void test_VarParseNumFromStrFr(void) ...@@ -1916,7 +1916,6 @@ static void test_VarParseNumFromStrFr(void)
if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */) if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */)
{ {
/* Trailing thousands separators are allowed as usual */ /* Trailing thousands separators are allowed as usual */
todo_wine_if(spaces[i] == ' ')
EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,2,0,0); EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,2,0,0);
EXPECT2(3,FAILDIG); EXPECT2(3,FAILDIG);
} }
...@@ -1949,7 +1948,6 @@ static void test_VarParseNumFromStrFr(void) ...@@ -1949,7 +1948,6 @@ static void test_VarParseNumFromStrFr(void)
if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */) if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */)
{ {
/* Non-breaking space and regular spaces work */ /* Non-breaking space and regular spaces work */
todo_wine_if(i == 0)
EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,5,0,3); EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,5,0,3);
EXPECTRGB(0,1); /* Don't test extra digits, see "1,000" test */ EXPECTRGB(0,1); /* Don't test extra digits, see "1,000" test */
EXPECTRGB(4,FAILDIG); EXPECTRGB(4,FAILDIG);
...@@ -1965,34 +1963,31 @@ static void test_VarParseNumFromStrFr(void) ...@@ -1965,34 +1963,31 @@ static void test_VarParseNumFromStrFr(void)
/* With flag and decimal point, thousands sep. but not decimals consumed */ /* With flag and decimal point, thousands sep. but not decimals consumed */
CONVERT("1 001,0", NUMPRS_THOUSANDS); CONVERT("1 001,0", NUMPRS_THOUSANDS);
if (broken(1)) /* FIXME Reenable once Wine is less broken */
EXPECT(4,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,0); EXPECT(4,NUMPRS_THOUSANDS,NUMPRS_THOUSANDS,5,0,0);
todo_wine ok(np.cDig == 4, "Expected cDig = 4, got %d\n", np.cDig); EXPECT2(1,0);
EXPECTRGB(0,1); EXPECTRGB(2,0);
todo_wine EXPECTRGB(1,0); EXPECTRGB(3,1);
todo_wine EXPECTRGB(2,0);
todo_wine EXPECTRGB(3,1);
EXPECTRGB(4,FAILDIG); EXPECTRGB(4,FAILDIG);
/* With flag, consecutive thousands separators are allowed */ /* With flag, consecutive thousands separators are allowed */
CONVERT("1 000", NUMPRS_THOUSANDS|NUMPRS_USE_ALL); CONVERT("1 000", NUMPRS_THOUSANDS|NUMPRS_USE_ALL);
todo_wine EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,6,0,3); EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,6,0,3);
EXPECTRGB(0,1); /* Don't test extra digits, see "1,000" test */ EXPECTRGB(0,1); /* Don't test extra digits, see "1,000" test */
EXPECTRGB(4,FAILDIG); EXPECTRGB(4,FAILDIG);
/* With flag, thousands separators can be sprinkled at random */ /* With flag, thousands separators can be sprinkled at random */
CONVERT("1 00 0 ", NUMPRS_THOUSANDS|NUMPRS_USE_ALL); CONVERT("1 00 0 ", NUMPRS_THOUSANDS|NUMPRS_USE_ALL);
todo_wine EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,8,0,3); EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,8,0,3);
EXPECTRGB(0,1); /* Don't test extra digits, see "1,000" test */ EXPECTRGB(0,1); /* Don't test extra digits, see "1,000" test */
EXPECTRGB(4,FAILDIG); EXPECTRGB(4,FAILDIG);
/* With flag, but leading thousands separators are not allowed */ /* With flag, but leading thousands separators are not allowed */
CONVERT(" 1 000", NUMPRS_THOUSANDS); CONVERT(" 1 000", NUMPRS_THOUSANDS);
EXPECTFAIL; todo_wine EXPECTFAIL;
/* With flag, thousands separator not needed but still reported */ /* With flag, thousands separator not needed but still reported */
CONVERT("1 ", NUMPRS_THOUSANDS|NUMPRS_USE_ALL); CONVERT("1 ", NUMPRS_THOUSANDS|NUMPRS_USE_ALL);
todo_wine EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,2,0,0); EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,2,0,0);
EXPECT2(1,FAILDIG); EXPECT2(1,FAILDIG);
...@@ -2039,7 +2034,7 @@ static void test_VarParseNumFromStrFr(void) ...@@ -2039,7 +2034,7 @@ static void test_VarParseNumFromStrFr(void)
if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */) if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */)
{ {
/* Spaces aliased to thousands separator are never allowed! */ /* Spaces aliased to thousands separator are never allowed! */
todo_wine_if(i==0) EXPECT(2,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,4,0,0); EXPECT(2,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_THOUSANDS,4,0,0);
EXPECT2(1,2); EXPECT2(1,2);
EXPECTRGB(2,FAILDIG); EXPECTRGB(2,FAILDIG);
} }
...@@ -2067,12 +2062,11 @@ static void test_VarParseNumFromStrFr(void) ...@@ -2067,12 +2062,11 @@ static void test_VarParseNumFromStrFr(void)
/* Thousands flag can also be used with currency */ /* Thousands flag can also be used with currency */
WCONVERT(L"1 234,5 \x20ac", NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_DECIMAL|NUMPRS_USE_ALL); WCONVERT(L"1 234,5 \x20ac", NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_DECIMAL|NUMPRS_USE_ALL);
todo_wine EXPECT(5,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_DECIMAL|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_DECIMAL,9,0,-1); EXPECT(5,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_DECIMAL|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_DECIMAL,9,0,-1);
EXPECTRGB(0,1); EXPECT2(1,2);
todo_wine EXPECTRGB(1,2); EXPECTRGB(2,3);
todo_wine EXPECTRGB(2,3); EXPECTRGB(3,4);
todo_wine EXPECTRGB(3,4); EXPECTRGB(4,5);
todo_wine EXPECTRGB(4,5);
EXPECTRGB(5,FAILDIG); EXPECTRGB(5,FAILDIG);
......
...@@ -1615,6 +1615,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla ...@@ -1615,6 +1615,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla
DWORD dwState = B_EXPONENT_START|B_INEXACT_ZEROS; DWORD dwState = B_EXPONENT_START|B_INEXACT_ZEROS;
int iMaxDigits = ARRAY_SIZE(rgbTmp); int iMaxDigits = ARRAY_SIZE(rgbTmp);
int cchUsed = 0; int cchUsed = 0;
OLECHAR cDigitSeparator2;
TRACE("(%s,%d,0x%08x,%p,%p)\n", debugstr_w(lpszStr), lcid, dwFlags, pNumprs, rgbDig); TRACE("(%s,%d,0x%08x,%p,%p)\n", debugstr_w(lpszStr), lcid, dwFlags, pNumprs, rgbDig);
...@@ -1634,6 +1635,10 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla ...@@ -1634,6 +1635,10 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla
return DISP_E_TYPEMISMATCH; return DISP_E_TYPEMISMATCH;
VARIANT_GetLocalisedNumberChars(&chars, lcid, dwFlags); VARIANT_GetLocalisedNumberChars(&chars, lcid, dwFlags);
/* Setting the thousands separator to a non-breaking space implies regular
* spaces are allowed too. But the converse is not true.
*/
cDigitSeparator2 = chars.cDigitSeparator == 0xa0 ? ' ' : 0;
/* First consume all the leading symbols and space from the string */ /* First consume all the leading symbols and space from the string */
while (1) while (1)
...@@ -1674,6 +1679,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla ...@@ -1674,6 +1679,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla
/* Only accept currency characters */ /* Only accept currency characters */
chars.cDecimalPoint = chars.cCurrencyDecimalPoint; chars.cDecimalPoint = chars.cCurrencyDecimalPoint;
chars.cDigitSeparator = chars.cCurrencyDigitSeparator; chars.cDigitSeparator = chars.cCurrencyDigitSeparator;
cDigitSeparator2 = chars.cDigitSeparator == 0xa0 ? ' ' : 0;
} }
else if (pNumprs->dwInFlags & NUMPRS_PARENS && *lpszStr == '(' && else if (pNumprs->dwInFlags & NUMPRS_PARENS && *lpszStr == '(' &&
!(pNumprs->dwOutFlags & NUMPRS_PARENS)) !(pNumprs->dwOutFlags & NUMPRS_PARENS))
...@@ -1781,7 +1787,9 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla ...@@ -1781,7 +1787,9 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla
cchUsed++; cchUsed++;
} }
} }
else if (*lpszStr == chars.cDigitSeparator && pNumprs->dwInFlags & NUMPRS_THOUSANDS) else if (pNumprs->dwInFlags & NUMPRS_THOUSANDS &&
((chars.cDigitSeparator && *lpszStr == chars.cDigitSeparator) ||
(cDigitSeparator2 && *lpszStr == cDigitSeparator2)))
{ {
pNumprs->dwOutFlags |= NUMPRS_THOUSANDS; pNumprs->dwOutFlags |= NUMPRS_THOUSANDS;
cchUsed++; cchUsed++;
......
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