Added a test case too thanks to Fabian Maurer
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52476 Signed-off-by: David Kahurani k.kahurani@gmail.com --- dlls/oleaut32/tests/vartest.c | 5 +++++ dlls/oleaut32/variant.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index f25a448..44b2dd8 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -1764,6 +1764,11 @@ static void test_VarParseNumFromStrEn(void)
/** NUMPRS_DECIMAL **/
+ /* Decimal with no leading zero */ + CONVERT(".308", NUMPRS_DECIMAL); + EXPECT(3, NUMPRS_DECIMAL, NUMPRS_DECIMAL, 4, 0, -3); + EXPECT2(3, 0); + /* With flag, consumes decimal point */ CONVERT("1.1", NUMPRS_DECIMAL); EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1); diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index bf8f041..66bd905 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -1633,7 +1633,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla /* If we have no digits so far, skip leading zeros */ if (!pNumprs->cDig) { - while (lpszStr[1] == '0') + while (lpszStr[0] == '0') { dwState |= B_LEADING_ZERO; cchUsed++;
From: David Kahurani k.kahurani@gmail.com Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52476 Signed-off-by: Francois Gouget fgouget@codeweavers.com --- I hope the way I sent this modified patch is ok.
I added some more tests to David's patch to make sure we handle cases where the dot is immediately followed by a 0 as well as those where it's only the next character which is 0 (such as in the original .308).
I also tweaked the VarParseNumFromStr() patch to use *lpszStr for consistency with other parts of that function though that's really just cosmetic. --- dlls/oleaut32/tests/vartest.c | 31 +++++++++++++++++++++++++++++++ dlls/oleaut32/variant.c | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 0a8b56bb2ee..9887fcb3100 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -1775,6 +1775,29 @@ static void test_VarParseNumFromStrEn(void) EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,0); EXPECT2(1,FAILDIG);
+ /* Skipping the integer part is not an error */ + CONVERT(".2", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,-1); + EXPECT2(2,FAILDIG); + + CONVERT("$.02", NUMPRS_CURRENCY|NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_CURRENCY|NUMPRS_DECIMAL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,4,0,-2); + EXPECT2(2,FAILDIG); + + CONVERT(".001", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,4,0,-3); + EXPECT2(1,FAILDIG); + + CONVERT(".101", NUMPRS_DECIMAL); + EXPECT(3,NUMPRS_DECIMAL,NUMPRS_DECIMAL,4,0,-3); + EXPECT2(1,0); + EXPECTRGB(2,1); + EXPECTRGB(3,FAILDIG); + + CONVERT(".30", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1); + EXPECT2(3,FAILDIG); + /* Consumes only one decimal point */ CONVERT("1.1.", NUMPRS_DECIMAL); EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1); @@ -2131,6 +2154,14 @@ static void test_VarParseNumFromStrFr(void) CONVERT("1.2", NUMPRS_DECIMAL); EXPECT(1,NUMPRS_DECIMAL,0,1,0,0); EXPECT2(1,FAILDIG); + + /* The integer part can still be omitted */ + CONVERT(",2", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,-1); + EXPECT2(2,FAILDIG); + + CONVERT(".2", NUMPRS_DECIMAL); + EXPECTFAIL; }
static void test_VarParseNumFromStrMisc(void) diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index bf8f041b9c6..885082cc659 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -1633,7 +1633,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla /* If we have no digits so far, skip leading zeros */ if (!pNumprs->cDig) { - while (lpszStr[1] == '0') + while (*lpszStr == '0') { dwState |= B_LEADING_ZERO; cchUsed++;
Thanks for the feedback, Francois, much appreciated.
On Mon, Feb 21, 2022 at 5:04 PM Francois Gouget fgouget@codeweavers.com wrote:
From: David Kahurani k.kahurani@gmail.com Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52476 Signed-off-by: Francois Gouget fgouget@codeweavers.com
I hope the way I sent this modified patch is ok.
I added some more tests to David's patch to make sure we handle cases where the dot is immediately followed by a 0 as well as those where it's only the next character which is 0 (such as in the original .308).
I also tweaked the VarParseNumFromStr() patch to use *lpszStr for consistency with other parts of that function though that's really just cosmetic.
dlls/oleaut32/tests/vartest.c | 31 +++++++++++++++++++++++++++++++ dlls/oleaut32/variant.c | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 0a8b56bb2ee..9887fcb3100 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -1775,6 +1775,29 @@ static void test_VarParseNumFromStrEn(void) EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,0); EXPECT2(1,FAILDIG);
- /* Skipping the integer part is not an error */
- CONVERT(".2", NUMPRS_DECIMAL);
- EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,-1);
- EXPECT2(2,FAILDIG);
- CONVERT("$.02", NUMPRS_CURRENCY|NUMPRS_DECIMAL);
EXPECT(1,NUMPRS_CURRENCY|NUMPRS_DECIMAL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,4,0,-2);
- EXPECT2(2,FAILDIG);
- CONVERT(".001", NUMPRS_DECIMAL);
- EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,4,0,-3);
- EXPECT2(1,FAILDIG);
- CONVERT(".101", NUMPRS_DECIMAL);
- EXPECT(3,NUMPRS_DECIMAL,NUMPRS_DECIMAL,4,0,-3);
- EXPECT2(1,0);
- EXPECTRGB(2,1);
- EXPECTRGB(3,FAILDIG);
- CONVERT(".30", NUMPRS_DECIMAL);
- EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
- EXPECT2(3,FAILDIG);
- /* Consumes only one decimal point */ CONVERT("1.1.", NUMPRS_DECIMAL); EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1);
@@ -2131,6 +2154,14 @@ static void test_VarParseNumFromStrFr(void) CONVERT("1.2", NUMPRS_DECIMAL); EXPECT(1,NUMPRS_DECIMAL,0,1,0,0); EXPECT2(1,FAILDIG);
- /* The integer part can still be omitted */
- CONVERT(",2", NUMPRS_DECIMAL);
- EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,-1);
- EXPECT2(2,FAILDIG);
- CONVERT(".2", NUMPRS_DECIMAL);
- EXPECTFAIL;
}
static void test_VarParseNumFromStrMisc(void) diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index bf8f041b9c6..885082cc659 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -1633,7 +1633,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla /* If we have no digits so far, skip leading zeros */ if (!pNumprs->cDig) {
while (lpszStr[1] == '0')
while (*lpszStr == '0') { dwState |= B_LEADING_ZERO; cchUsed++;
-- 2.30.2
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108779
Your paranoid android.
=== build (build log) ===
error: corrupt patch at line 117 Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
=== debian11 (build log) ===
Task: Patch failed to apply
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=108777
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w7u_adm (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w7u_el (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w8 (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w8adm (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w864 (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w1064v1507 (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w1064v1809 (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w1064 (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w1064_tsign (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w10pro64 (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w864 (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w1064v1507 (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w1064v1809 (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w1064 (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w1064_2qxl (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w1064_tsign (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w10pro64 (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w10pro64_ar (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w10pro64_he (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w10pro64_ja (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
=== w10pro64_zh_CN (64 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
On Mon, 21 Feb 2022, Marvin wrote: [...]
=== w7u_2qxl (32 bit report) ===
oleaut32: vartest.c:1799: Test failed: Digit[1], expected 255, got 0
Ah, right. Windows copies the trailing zeroes while Wine does not. I'll send a modified patch.
From: David Kahurani k.kahurani@gmail.com Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52476 Signed-off-by: Francois Gouget fgouget@codeweavers.com --- v2: Fix an issue with trailing zeroes.
I added some more tests to David's patch to make sure we handle cases where the dot is immediately followed by a zero as well as those where it's only the next character which is zero (such as in the original .308).
I also tweaked the VarParseNumFromStr() patch to use *lpszStr for consistency with other parts of that function though that's really just cosmetic. --- dlls/oleaut32/tests/vartest.c | 47 +++++++++++++++++++++++++++++++++++ dlls/oleaut32/variant.c | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c index 0a8b56bb2ee..dc1fb476307 100644 --- a/dlls/oleaut32/tests/vartest.c +++ b/dlls/oleaut32/tests/vartest.c @@ -1775,6 +1775,45 @@ static void test_VarParseNumFromStrEn(void) EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,0); EXPECT2(1,FAILDIG);
+ /* Skipping the integer part is not an error */ + CONVERT(".2", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,-1); + EXPECT2(2,FAILDIG); + + /* Even zero gets an exponent (it sort of indicates 'precision') */ + CONVERT(".0", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,-1); + EXPECT2(0,FAILDIG); + + CONVERT(".000", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,4,0,-3); + EXPECTRGB(0,0); + EXPECTRGB(3,FAILDIG); + + CONVERT("$.02", NUMPRS_CURRENCY|NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_CURRENCY|NUMPRS_DECIMAL,NUMPRS_CURRENCY|NUMPRS_DECIMAL,4,0,-2); + EXPECT2(2,FAILDIG); + + CONVERT(".001", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,4,0,-3); + EXPECT2(1,FAILDIG); + + CONVERT(".101", NUMPRS_DECIMAL); + EXPECT(3,NUMPRS_DECIMAL,NUMPRS_DECIMAL,4,0,-3); + EXPECT2(1,0); + EXPECTRGB(2,1); + EXPECTRGB(3,FAILDIG); + + CONVERT(".30", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1); + /* See the NUMPRS_THOUSANDS comment about trailing zeroes */ + EXPECTRGB(0,3); + EXPECTRGB(2,FAILDIG); + + /* But skipping both the integer and decimal part is not allowed */ + CONVERT(".", NUMPRS_DECIMAL); + EXPECTFAIL; + /* Consumes only one decimal point */ CONVERT("1.1.", NUMPRS_DECIMAL); EXPECT(2,NUMPRS_DECIMAL,NUMPRS_DECIMAL,3,0,-1); @@ -2131,6 +2170,14 @@ static void test_VarParseNumFromStrFr(void) CONVERT("1.2", NUMPRS_DECIMAL); EXPECT(1,NUMPRS_DECIMAL,0,1,0,0); EXPECT2(1,FAILDIG); + + /* The integer part can still be omitted */ + CONVERT(",2", NUMPRS_DECIMAL); + EXPECT(1,NUMPRS_DECIMAL,NUMPRS_DECIMAL,2,0,-1); + EXPECT2(2,FAILDIG); + + CONVERT(".2", NUMPRS_DECIMAL); + EXPECTFAIL; }
static void test_VarParseNumFromStrMisc(void) diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c index bf8f041b9c6..885082cc659 100644 --- a/dlls/oleaut32/variant.c +++ b/dlls/oleaut32/variant.c @@ -1633,7 +1633,7 @@ HRESULT WINAPI VarParseNumFromStr(const OLECHAR *lpszStr, LCID lcid, ULONG dwFla /* If we have no digits so far, skip leading zeros */ if (!pNumprs->cDig) { - while (lpszStr[1] == '0') + while (*lpszStr == '0') { dwState |= B_LEADING_ZERO; cchUsed++;