Bill Medland (medbi01@accpac.com) Correct GetNumberFormatA for zero decimals and for zero grouping Index: wine/dlls/kernel/tests/locale.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/tests/locale.c,v retrieving revision 1.6 diff -u -r1.6 locale.c --- wine/dlls/kernel/tests/locale.c 8 Nov 2002 18:51:56 -0000 1.6 +++ wine/dlls/kernel/tests/locale.c 25 Nov 2002 23:39:20 -0000 @@ -285,6 +285,7 @@ int ret, error, cmp; char buffer[BUFFER_SIZE], Expected[BUFFER_SIZE], input[BUFFER_SIZE]; LCID lcid; +NUMBERFMTA format; lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT ); @@ -319,6 +320,23 @@ cmp = strncmp (Expected, buffer, BUFFER_SIZE); ok (cmp == 0, "GetNumberFormat got %s instead of %s", buffer, Expected); eq (ret, strlen(Expected)+1, "GetNumberFormat", "%d"); + + /* If the number of decimals is zero there should be no decimal + * separator. + * If the grouping size is zero there should be no grouping symbol + */ + format.NumDigits = 0; + format.LeadingZero = 0; + format.Grouping = 0; + format.NegativeOrder = 0; + format.lpDecimalSep = "."; + format.lpThousandSep = ","; + strcpy (Expected, "123456789"); + memset( buffer, 'x', sizeof (buffer)/sizeof(buffer[0]) ); + ret = GetNumberFormatA (0, 0, "123456789.0", &format, buffer, sizeof(buffer)); + cmp = strncmp (Expected, buffer ,sizeof(buffer)); + ok (cmp == 0, "GetNumberFormat got %s instead of %s", buffer, Expected); + } Index: wine/ole/ole2nls.c =================================================================== RCS file: /home/wine/wine/ole/ole2nls.c,v retrieving revision 1.107 diff -u -r1.107 ole2nls.c --- wine/ole/ole2nls.c 8 Nov 2002 18:51:56 -0000 1.107 +++ wine/ole/ole2nls.c 25 Nov 2002 23:39:28 -0000 @@ -2230,6 +2230,7 @@ sprintf(sNumberDigits, "%d",lpFormat->NumDigits); strcpy(sDecimalSymbol, lpFormat->lpDecimalSep); sprintf(sDigitsInGroup, "%d;0",lpFormat->Grouping); + /* Win95-WinME only allow 0-9 for grouping, no matter what MSDN says. */ strcpy(sDigitGroupSymbol, lpFormat->lpThousandSep); sprintf(sILZero, "%d",lpFormat->LeadingZero); sprintf(sNegNumber, "%d",lpFormat->NegativeOrder); @@ -2275,6 +2276,8 @@ nStep = nCounter = i = j = 0; nRuleIndex = 1; nGrouping = OLE_GetGrouping(sRule, nRuleIndex); + if (nGrouping == 0) /* If the first grouping is zero */ + nGrouping = nNumberDecimal; /* Don't do grouping */ /* Here, we will loop until we reach the end of the string. * An internal counter (j) is used in order to know when to @@ -2343,7 +2346,7 @@ for (i=0; i<j; i++) memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), sDigitsAfterDecimal + i, 1); - memcpy(sNumber + nCounter+i+strlen(sDecimalSymbol), "\0", 1); + memcpy(sNumber + nCounter+i+ (i ? strlen(sDecimalSymbol) : 0), "\0", 1); /* Is it a negative number */ if (bNegative == TRUE)