msvcrt: Fixed 'h' modifier handling when printing integers.

This commit is contained in:
Piotr Caban 2012-04-16 15:21:47 +02:00 committed by Alexandre Julliard
parent 5c9ca5cb53
commit 0cc16fc8a5
2 changed files with 16 additions and 4 deletions

View file

@ -525,11 +525,13 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
FUNC_NAME(pf_integer_conv)(tmp, max_len, &flags, pf_args(args_ctx, pos,
VT_I8, valist).get_longlong);
else if(flags.Format=='d' || flags.Format=='i')
FUNC_NAME(pf_integer_conv)(tmp, max_len, &flags, pf_args(args_ctx, pos,
VT_INT, valist).get_int);
FUNC_NAME(pf_integer_conv)(tmp, max_len, &flags, flags.IntegerLength!='h' ?
pf_args(args_ctx, pos, VT_INT, valist).get_int :
(short)pf_args(args_ctx, pos, VT_INT, valist).get_int);
else
FUNC_NAME(pf_integer_conv)(tmp, max_len, &flags, (unsigned)pf_args(
args_ctx, pos, VT_INT, valist).get_int);
FUNC_NAME(pf_integer_conv)(tmp, max_len, &flags, flags.IntegerLength!='h' ?
(unsigned)pf_args(args_ctx, pos, VT_INT, valist).get_int :
(unsigned short)pf_args(args_ctx, pos, VT_INT, valist).get_int);
#ifdef PRINTF_WIDE
i = FUNC_NAME(pf_output_format_wstr)(pf_puts, puts_ctx, tmp, -1, &flags, locinfo);

View file

@ -607,6 +607,16 @@ static void test_sprintf( void )
r = sprintf(buffer, format);
ok(!strcmp(buffer,"%0"), "failed: \"%s\"\n", buffer);
ok( r==2, "return count wrong\n");
format = "%hx";
r = sprintf(buffer, format, 0x12345);
ok(!strcmp(buffer,"2345"), "failed \"%s\"\n", buffer);
format = "%hhx";
r = sprintf(buffer, format, 0x123);
ok(!strcmp(buffer,"123"), "failed: \"%s\"\n", buffer);
r = sprintf(buffer, format, 0x12345);
ok(!strcmp(buffer,"2345"), "failed \"%s\"\n", buffer);
}
static void test_swprintf( void )