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=51450
Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Francois Gouget 2021-07-22 00:03:43 +02:00 committed by Alexandre Julliard
parent 4eb35fb237
commit c50dff867d
2 changed files with 22 additions and 20 deletions

View File

@ -1916,7 +1916,6 @@ static void test_VarParseNumFromStrFr(void)
if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */)
{
/* Trailing thousands separators are allowed as usual */
todo_wine_if(spaces[i] == ' ')
EXPECT(1,NUMPRS_THOUSANDS|NUMPRS_USE_ALL,NUMPRS_THOUSANDS,2,0,0);
EXPECT2(3,FAILDIG);
}
@ -1949,7 +1948,6 @@ static void test_VarParseNumFromStrFr(void)
if (spaces[i] == ' ' || spaces[i] == 0xa0 /* non-breaking space */)
{
/* Non-breaking space and regular spaces work */
todo_wine_if(i == 0)
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(4,FAILDIG);
@ -1965,34 +1963,31 @@ static void test_VarParseNumFromStrFr(void)
/* With flag and decimal point, thousands sep. but not decimals consumed */
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);
todo_wine ok(np.cDig == 4, "Expected cDig = 4, got %d\n", np.cDig);
EXPECTRGB(0,1);
todo_wine EXPECTRGB(1,0);
todo_wine EXPECTRGB(2,0);
todo_wine EXPECTRGB(3,1);
EXPECT2(1,0);
EXPECTRGB(2,0);
EXPECTRGB(3,1);
EXPECTRGB(4,FAILDIG);
/* With flag, consecutive thousands separators are allowed */
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(4,FAILDIG);
/* With flag, thousands separators can be sprinkled at random */
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(4,FAILDIG);
/* With flag, but leading thousands separators are not allowed */
CONVERT(" 1 000", NUMPRS_THOUSANDS);
EXPECTFAIL;
todo_wine EXPECTFAIL;
/* With flag, thousands separator not needed but still reported */
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);
@ -2039,7 +2034,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_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);
EXPECTRGB(2,FAILDIG);
}
@ -2067,12 +2062,11 @@ static void test_VarParseNumFromStrFr(void)
/* Thousands flag can also be used with currency */
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);
EXPECTRGB(0,1);
todo_wine EXPECTRGB(1,2);
todo_wine EXPECTRGB(2,3);
todo_wine EXPECTRGB(3,4);
todo_wine EXPECTRGB(4,5);
EXPECT(5,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_DECIMAL|NUMPRS_USE_ALL,NUMPRS_CURRENCY|NUMPRS_THOUSANDS|NUMPRS_DECIMAL,9,0,-1);
EXPECT2(1,2);
EXPECTRGB(2,3);
EXPECTRGB(3,4);
EXPECTRGB(4,5);
EXPECTRGB(5,FAILDIG);

View File

@ -1615,6 +1615,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla
DWORD dwState = B_EXPONENT_START|B_INEXACT_ZEROS;
int iMaxDigits = ARRAY_SIZE(rgbTmp);
int cchUsed = 0;
OLECHAR cDigitSeparator2;
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
return DISP_E_TYPEMISMATCH;
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 */
while (1)
@ -1674,6 +1679,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla
/* Only accept currency characters */
chars.cDecimalPoint = chars.cCurrencyDecimalPoint;
chars.cDigitSeparator = chars.cCurrencyDigitSeparator;
cDigitSeparator2 = chars.cDigitSeparator == 0xa0 ? ' ' : 0;
}
else if (pNumprs->dwInFlags & NUMPRS_PARENS && *lpszStr == '(' &&
!(pNumprs->dwOutFlags & NUMPRS_PARENS))
@ -1781,7 +1787,9 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla
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;
cchUsed++;