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++;