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

Alexandre Julliard julliard at winehq.org
Fri Feb 25 07:30:23 CST 2022


Module: wine
Branch: oldstable
Commit: bb652772af76c76d1dfd4844616abbfeac41c4c2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=bb652772af76c76d1dfd4844616abbfeac41c4c2

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Jul 22 00:03:43 2021 +0200

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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit c50dff867d797f7c43a8a319afb735fea6e8bf31)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/oleaut32/tests/vartest.c | 32 +++++++++++++-------------------
 dlls/oleaut32/variant.c       | 10 +++++++++-
 2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c
index bf6152554ad..258b747b03d 100644
--- a/dlls/oleaut32/tests/vartest.c
+++ b/dlls/oleaut32/tests/vartest.c
@@ -1915,7 +1915,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);
     }
@@ -1948,7 +1947,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);
@@ -1964,34 +1962,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);
 
 
@@ -2038,7 +2033,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);
     }
@@ -2066,12 +2061,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);
 
 
diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c
index b80a8537380..5e71d0a536d 100644
--- a/dlls/oleaut32/variant.c
+++ b/dlls/oleaut32/variant.c
@@ -1614,6 +1614,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
   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);
 
@@ -1633,6 +1634,10 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
     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)
@@ -1673,6 +1678,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
       /* 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))
@@ -1780,7 +1786,9 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
         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++;




More information about the wine-cvs mailing list