msvcrt: Format strings according to specified locale in pf_vsnprintf.

This commit is contained in:
Piotr Caban 2010-04-19 10:57:14 +02:00 committed by Alexandre Julliard
parent d8504e0550
commit 419f902546
1 changed files with 11 additions and 4 deletions

View File

@ -554,12 +554,15 @@ static void pf_fixup_exponent( char *buf )
* *
* implements both A and W vsnprintf functions * implements both A and W vsnprintf functions
*/ */
static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valist ) static int pf_vsnprintf( pf_output *out, const WCHAR *format, MSVCRT__locale_t locale, __ms_va_list valist )
{ {
int r; int r;
LPCWSTR q, p = format; LPCWSTR q, p = format;
pf_flags flags; pf_flags flags;
if(!locale)
locale = get_locale();
TRACE("format is %s\n",debugstr_w(format)); TRACE("format is %s\n",debugstr_w(format));
while (*p) while (*p)
{ {
@ -751,7 +754,7 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
/* deal with integers and floats using libc's printf */ /* deal with integers and floats using libc's printf */
else if( pf_is_valid_format( flags.Format ) ) else if( pf_is_valid_format( flags.Format ) )
{ {
char fmt[20], number[40], *x = number; char fmt[20], number[40], *x = number, *decimal_point;
/* Estimate largest possible required buffer size: /* Estimate largest possible required buffer size:
* Chooses the larger of the field or precision * Chooses the larger of the field or precision
@ -775,6 +778,10 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
else else
sprintf( x, fmt, va_arg(valist, int) ); sprintf( x, fmt, va_arg(valist, int) );
decimal_point = strchr(x, '.');
if(decimal_point)
*decimal_point = *locale->locinfo->lconv->decimal_point;
r = pf_output_stringA( out, x, -1 ); r = pf_output_stringA( out, x, -1 );
if( x != number ) if( x != number )
HeapFree( GetProcessHeap(), 0, x ); HeapFree( GetProcessHeap(), 0, x );
@ -814,7 +821,7 @@ int CDECL MSVCRT_vsnprintf( char *str, unsigned int len,
formatW = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) ); formatW = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, format, -1, formatW, sz ); MultiByteToWideChar( CP_ACP, 0, format, -1, formatW, sz );
r = pf_vsnprintf( &out, formatW, valist ); r = pf_vsnprintf( &out, formatW, NULL, valist );
HeapFree( GetProcessHeap(), 0, formatW ); HeapFree( GetProcessHeap(), 0, formatW );
@ -871,7 +878,7 @@ int CDECL MSVCRT_vsnwprintf( MSVCRT_wchar_t *str, unsigned int len,
out.used = 0; out.used = 0;
out.len = len; out.len = len;
return pf_vsnprintf( &out, format, valist ); return pf_vsnprintf( &out, format, NULL, valist );
} }
/********************************************************************* /*********************************************************************