mirror of
https://github.com/reactos/reactos.git
synced 2024-07-12 07:35:10 +00:00
trim leading zeros in GetNumberFormat
patch by <zooba at aanet dot com dot au> See issue #3400 for more details. svn path=/trunk/; revision=38930
This commit is contained in:
parent
9a921d3209
commit
c1f8a4fdc2
|
@ -1013,6 +1013,7 @@ INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags,
|
||||||
WCHAR szNegBuff[8];
|
WCHAR szNegBuff[8];
|
||||||
const WCHAR *lpszNeg = NULL, *lpszNegStart, *szSrc;
|
const WCHAR *lpszNeg = NULL, *lpszNegStart, *szSrc;
|
||||||
DWORD dwState = 0, dwDecimals = 0, dwGroupCount = 0, dwCurrentGroupCount = 0;
|
DWORD dwState = 0, dwDecimals = 0, dwGroupCount = 0, dwCurrentGroupCount = 0;
|
||||||
|
DWORD dwLeadingZeros = 0;
|
||||||
INT iRet;
|
INT iRet;
|
||||||
|
|
||||||
TRACE("(0x%04lx,0x%08lx,%S,%p,%p,%d)\n", lcid, dwFlags, lpszValue,
|
TRACE("(0x%04lx,0x%08lx,%S,%p,%p,%d)\n", lcid, dwFlags, lpszValue,
|
||||||
|
@ -1063,7 +1064,11 @@ GetNumberFormatW_Error:
|
||||||
/* Check the number for validity */
|
/* Check the number for validity */
|
||||||
while (*szSrc)
|
while (*szSrc)
|
||||||
{
|
{
|
||||||
if (*szSrc >= '0' && *szSrc <= '9')
|
if (*szSrc == '0' && !(dwState & NF_DIGITS))
|
||||||
|
{
|
||||||
|
dwLeadingZeros++;
|
||||||
|
}
|
||||||
|
else if ((*szSrc >= '1' && *szSrc <= '9') || (*szSrc == '0' && (dwState & NF_DIGITS)))
|
||||||
{
|
{
|
||||||
dwState |= NF_DIGITS;
|
dwState |= NF_DIGITS;
|
||||||
if (dwState & NF_ISREAL)
|
if (dwState & NF_ISREAL)
|
||||||
|
@ -1176,7 +1181,7 @@ GetNumberFormatW_Error:
|
||||||
dwGroupCount = lpFormat->Grouping == 32 ? 3 : lpFormat->Grouping;
|
dwGroupCount = lpFormat->Grouping == 32 ? 3 : lpFormat->Grouping;
|
||||||
|
|
||||||
/* Write the remaining whole number digits, including grouping chars */
|
/* Write the remaining whole number digits, including grouping chars */
|
||||||
while (szSrc >= lpszValue && *szSrc >= '0' && *szSrc <= '9')
|
while (szSrc >= (lpszValue + dwLeadingZeros) && *szSrc >= '0' && *szSrc <= '9')
|
||||||
{
|
{
|
||||||
if (dwState & NF_ROUND)
|
if (dwState & NF_ROUND)
|
||||||
{
|
{
|
||||||
|
@ -1194,7 +1199,7 @@ GetNumberFormatW_Error:
|
||||||
|
|
||||||
dwState |= NF_DIGITS_OUT;
|
dwState |= NF_DIGITS_OUT;
|
||||||
dwCurrentGroupCount++;
|
dwCurrentGroupCount++;
|
||||||
if (szSrc >= lpszValue && dwCurrentGroupCount == dwGroupCount && *szSrc != '-')
|
if (szSrc >= (lpszValue + dwLeadingZeros) && dwCurrentGroupCount == dwGroupCount && *szSrc != '-')
|
||||||
{
|
{
|
||||||
LPWSTR lpszGrp = lpFormat->lpThousandSep + strlenW(lpFormat->lpThousandSep) - 1;
|
LPWSTR lpszGrp = lpFormat->lpThousandSep + strlenW(lpFormat->lpThousandSep) - 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue