ntdll: Use proper flags instead of characters for printf flags.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3a3c7cbd20
commit
1a43c5de71
|
@ -50,11 +50,10 @@ typedef struct pf_output_t
|
|||
|
||||
typedef struct pf_flags_t
|
||||
{
|
||||
char Sign, LeftAlign, Alternate, PadZero;
|
||||
enum { LEN_DEFAULT, LEN_SHORT, LEN_LONG } IntegerLength;
|
||||
BOOLEAN IntegerDouble, IntegerNative, LeftAlign, Alternate, PadZero, WideString;
|
||||
int FieldLength, Precision;
|
||||
char IntegerLength, IntegerDouble, IntegerNative;
|
||||
char WideString;
|
||||
char Format;
|
||||
char Sign, Format;
|
||||
} pf_flags;
|
||||
|
||||
/*
|
||||
|
@ -268,9 +267,9 @@ static int pf_handle_string_format( pf_output *out, const void* str, int len,
|
|||
return pf_output_format_A( out, "(null)", -1, flags);
|
||||
|
||||
/* prefixes take priority over %c,%s vs. %C,%S, so we handle them first */
|
||||
if(flags->WideString || flags->IntegerLength == 'l')
|
||||
if (flags->WideString || flags->IntegerLength == LEN_LONG)
|
||||
return pf_output_format_W( out, str, len, flags);
|
||||
if(flags->IntegerLength == 'h')
|
||||
if (flags->IntegerLength == LEN_SHORT)
|
||||
return pf_output_format_A( out, str, len, flags);
|
||||
|
||||
/* %s,%c -> chars in ansi functions & wchars in unicode
|
||||
|
@ -310,7 +309,7 @@ static void pf_integer_conv( char *buf, pf_flags *flags, LONGLONG x )
|
|||
i = 0;
|
||||
if( x == 0 )
|
||||
{
|
||||
flags->Alternate = 0;
|
||||
flags->Alternate = FALSE;
|
||||
if( flags->Precision )
|
||||
buf[i++] = '0';
|
||||
}
|
||||
|
@ -410,11 +409,11 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
|
|||
flags.Sign = *p;
|
||||
}
|
||||
else if( *p == '-' )
|
||||
flags.LeftAlign = *p;
|
||||
flags.LeftAlign = TRUE;
|
||||
else if( *p == '0' )
|
||||
flags.PadZero = *p;
|
||||
flags.PadZero = TRUE;
|
||||
else if( *p == '#' )
|
||||
flags.Alternate = *p;
|
||||
flags.Alternate = TRUE;
|
||||
else
|
||||
break;
|
||||
p++;
|
||||
|
@ -427,7 +426,7 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
|
|||
flags.FieldLength = va_arg( valist, int );
|
||||
if (flags.FieldLength < 0)
|
||||
{
|
||||
flags.LeftAlign = '-';
|
||||
flags.LeftAlign = TRUE;
|
||||
flags.FieldLength = -flags.FieldLength;
|
||||
}
|
||||
p++;
|
||||
|
@ -461,19 +460,24 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
|
|||
{
|
||||
if (*p == 'l' && *(p+1) == 'l')
|
||||
{
|
||||
flags.IntegerDouble++;
|
||||
flags.IntegerDouble = TRUE;
|
||||
p += 2;
|
||||
}
|
||||
else if( *p == 'h' || *p == 'l' || *p == 'L' )
|
||||
else if( *p == 'l' || *p == 'L' )
|
||||
{
|
||||
flags.IntegerLength = *p;
|
||||
flags.IntegerLength = LEN_LONG;
|
||||
p++;
|
||||
}
|
||||
else if( *p == 'h')
|
||||
{
|
||||
flags.IntegerLength = LEN_SHORT;
|
||||
p++;
|
||||
}
|
||||
else if( *p == 'I' )
|
||||
{
|
||||
if( *(p+1) == '6' && *(p+2) == '4' )
|
||||
{
|
||||
flags.IntegerDouble++;
|
||||
flags.IntegerDouble = TRUE;
|
||||
p += 3;
|
||||
}
|
||||
else if( *(p+1) == '3' && *(p+2) == '2' )
|
||||
|
@ -481,7 +485,7 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
|
|||
else if( p[1] && strchr( "diouxX", p[1] ) )
|
||||
{
|
||||
if( sizeof(void *) == 8 )
|
||||
flags.IntegerDouble = *p;
|
||||
flags.IntegerDouble = TRUE;
|
||||
p++;
|
||||
}
|
||||
else if( isDigit(*(p+1)) || *(p+1) == 0 )
|
||||
|
@ -490,12 +494,18 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
|
|||
p++;
|
||||
}
|
||||
else if( *p == 'w' )
|
||||
flags.WideString = *p++;
|
||||
{
|
||||
flags.WideString = TRUE;
|
||||
p++;
|
||||
}
|
||||
else if ((*p == 'z' || *p == 't') && p[1] && strchr("diouxX", p[1]))
|
||||
flags.IntegerNative = *p++;
|
||||
{
|
||||
flags.IntegerNative = TRUE;
|
||||
p++;
|
||||
}
|
||||
else if (*p == 'j')
|
||||
{
|
||||
flags.IntegerDouble++;
|
||||
flags.IntegerDouble = TRUE;
|
||||
p++;
|
||||
}
|
||||
else if( *p == 'F' )
|
||||
|
@ -532,10 +542,10 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
|
|||
void *ptr = va_arg( valist, void * );
|
||||
int prec = flags.Precision;
|
||||
flags.Format = 'X';
|
||||
flags.PadZero = '0';
|
||||
flags.PadZero = TRUE;
|
||||
flags.Precision = 2*sizeof(void*);
|
||||
pf_integer_conv( pointer, &flags, (ULONG_PTR)ptr );
|
||||
flags.PadZero = 0;
|
||||
flags.PadZero = FALSE;
|
||||
flags.Precision = prec;
|
||||
r = pf_output_format_A( out, pointer, -1, &flags );
|
||||
}
|
||||
|
@ -563,10 +573,10 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, __ms_va_list valis
|
|||
if(flags.IntegerDouble || (flags.IntegerNative && sizeof(void*) == 8))
|
||||
pf_integer_conv( x, &flags, va_arg(valist, LONGLONG) );
|
||||
else if(flags.Format=='d' || flags.Format=='i')
|
||||
pf_integer_conv( x, &flags, flags.IntegerLength!='h' ?
|
||||
pf_integer_conv( x, &flags, flags.IntegerLength != LEN_SHORT ?
|
||||
va_arg(valist, int) : (short)va_arg(valist, int) );
|
||||
else
|
||||
pf_integer_conv( x, &flags, flags.IntegerLength!='h' ?
|
||||
pf_integer_conv( x, &flags, flags.IntegerLength != LEN_SHORT ?
|
||||
(unsigned int)va_arg(valist, int) : (unsigned short)va_arg(valist, int) );
|
||||
|
||||
r = pf_output_format_A( out, x, -1, &flags );
|
||||
|
|
Loading…
Reference in New Issue