Commit ba43e4cf authored by Alexandre Julliard's avatar Alexandre Julliard

kernelbase: Reimplement number formatting values in GetLocaleInfoW/Ex using the locale.nls data.

parent bc54bcf8
...@@ -887,6 +887,42 @@ static int locale_return_number( UINT val, LCTYPE type, WCHAR *buffer, int len ) ...@@ -887,6 +887,42 @@ static int locale_return_number( UINT val, LCTYPE type, WCHAR *buffer, int len )
} }
static int locale_return_grouping( DWORD pos, LCTYPE type, WCHAR *buffer, int len )
{
WORD i, count = locale_strings[pos];
const WCHAR *str = locale_strings + pos + 1;
int ret;
if (type & LOCALE_RETURN_NUMBER)
{
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}
ret = 2 * count;
if (str[count - 1]) ret += 2; /* for final zero */
if (!len) return ret;
if (ret > len)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return 0;
}
for (i = 0; i < count; i++)
{
if (!str[i]) /* explicit null termination */
{
buffer[-1] = 0;
return ret;
}
*buffer++ = '0' + str[i];
*buffer++ = ';';
}
*buffer++ = '0';
*buffer = 0;
return ret;
}
static int locale_return_strarray( DWORD pos, WORD idx, LCTYPE type, WCHAR *buffer, int len ) static int locale_return_strarray( DWORD pos, WORD idx, LCTYPE type, WCHAR *buffer, int len )
{ {
const DWORD *array = (const DWORD *)(locale_strings + pos + 1); const DWORD *array = (const DWORD *)(locale_strings + pos + 1);
...@@ -1052,25 +1088,25 @@ static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE typ ...@@ -1052,25 +1088,25 @@ static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE typ
return locale_return_number( val, type, buffer, len ); return locale_return_number( val, type, buffer, len );
case LOCALE_SLIST: case LOCALE_SLIST:
return -1; return locale_return_string( locale->slist, type, buffer, len );
case LOCALE_IMEASURE: case LOCALE_IMEASURE:
return locale_return_number( locale->imeasure, type, buffer, len ); return locale_return_number( locale->imeasure, type, buffer, len );
case LOCALE_SDECIMAL: case LOCALE_SDECIMAL:
return -1; return locale_return_string( locale->sdecimal, type, buffer, len );
case LOCALE_STHOUSAND: case LOCALE_STHOUSAND:
return -1; return locale_return_string( locale->sthousand, type, buffer, len );
case LOCALE_SGROUPING: case LOCALE_SGROUPING:
return -1; return locale_return_grouping( locale->sgrouping, type, buffer, len );
case LOCALE_IDIGITS: case LOCALE_IDIGITS:
return -1; return locale_return_number( locale->idigits, type, buffer, len );
case LOCALE_ILZERO: case LOCALE_ILZERO:
return -1; return locale_return_number( locale->ilzero, type, buffer, len );
case LOCALE_SNATIVEDIGITS: case LOCALE_SNATIVEDIGITS:
return locale_return_strarray_concat( locale->snativedigits, type, buffer, len ); return locale_return_strarray_concat( locale->snativedigits, type, buffer, len );
...@@ -1192,10 +1228,10 @@ static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE typ ...@@ -1192,10 +1228,10 @@ static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE typ
type - LOCALE_SABBREVMONTHNAME1, type, buffer, len ); type - LOCALE_SABBREVMONTHNAME1, type, buffer, len );
case LOCALE_SPOSITIVESIGN: case LOCALE_SPOSITIVESIGN:
return -1; return locale_return_string( locale->spositivesign, type, buffer, len );
case LOCALE_SNEGATIVESIGN: case LOCALE_SNEGATIVESIGN:
return -1; return locale_return_string( locale->snegativesign, type, buffer, len );
case LOCALE_IPOSSIGNPOSN: case LOCALE_IPOSSIGNPOSN:
return -1; return -1;
...@@ -1379,7 +1415,7 @@ static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE typ ...@@ -1379,7 +1415,7 @@ static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE typ
12, type, buffer, len ); 12, type, buffer, len );
case LOCALE_INEGNUMBER: case LOCALE_INEGNUMBER:
return -1; return locale_return_number( locale->inegnumber, type, buffer, len );
case LOCALE_IDEFAULTMACCODEPAGE: case LOCALE_IDEFAULTMACCODEPAGE:
val = locale->idefaultmaccodepage == CP_UTF8 ? CP_MACCP : locale->idefaultmaccodepage; val = locale->idefaultmaccodepage == CP_UTF8 ? CP_MACCP : locale->idefaultmaccodepage;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment