Commit 4a79e549 authored by Martin Storsjo's avatar Martin Storsjo Committed by Alexandre Julliard

ucrtbase: Handle the C99 'z' size_t specifier for integers.

parent 494572ed
...@@ -473,6 +473,10 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API ...@@ -473,6 +473,10 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
flags.IntegerNative = *p++; flags.IntegerNative = *p++;
} else if(*p == 'w') } else if(*p == 'w')
flags.WideString = *p++; flags.WideString = *p++;
#if _MSVCR_VER >= 140
else if(*p == 'z')
flags.IntegerNative = *p++;
#endif
else if((*p == 'F' || *p == 'N') && legacy_msvcrt_compat) else if((*p == 'F' || *p == 'N') && legacy_msvcrt_compat)
p++; /* ignore */ p++; /* ignore */
else else
......
...@@ -321,6 +321,11 @@ static void test_sprintf( void ) ...@@ -321,6 +321,11 @@ static void test_sprintf( void )
ok(!strcmp(buffer,"D"),"I64D failed: %s\n",buffer); ok(!strcmp(buffer,"D"),"I64D failed: %s\n",buffer);
ok( r==1, "return count wrong\n"); ok( r==1, "return count wrong\n");
format = "%zx";
r = sprintf(buffer,format,1);
ok(!strcmp(buffer, "zx"), "Problem with \"z\" interpretation\n");
ok( r==2, "return count wrong\n");
format = "% d"; format = "% d";
r = sprintf(buffer,format,1); r = sprintf(buffer,format,1);
ok(!strcmp(buffer, " 1"),"Problem with sign place-holder: '%s'\n",buffer); ok(!strcmp(buffer, " 1"),"Problem with sign place-holder: '%s'\n",buffer);
......
...@@ -423,6 +423,29 @@ static void test_printf_legacy_three_digit_exp(void) ...@@ -423,6 +423,29 @@ static void test_printf_legacy_three_digit_exp(void)
ok(!strcmp(buf, "1.230000E+123"), "buf = %s\n", buf); ok(!strcmp(buf, "1.230000E+123"), "buf = %s\n", buf);
} }
static void test_printf_c99(void)
{
char buf[20];
/* The msvcrt compatibility flag doesn't affect whether 'z' is interpreted
* as size_t size for integers. */
if (sizeof(void*) == 8) {
vsprintf_wrapper(0, buf, sizeof(buf), "%zx %d",
(size_t) 0x12345678123456, 1);
ok(!strcmp(buf, "12345678123456 1"), "buf = %s\n", buf);
vsprintf_wrapper(UCRTBASE_PRINTF_LEGACY_MSVCRT_COMPATIBILITY,
buf, sizeof(buf), "%zx %d", (size_t) 0x12345678123456, 1);
ok(!strcmp(buf, "12345678123456 1"), "buf = %s\n", buf);
} else {
vsprintf_wrapper(0, buf, sizeof(buf), "%zx %d",
(size_t) 0x123456, 1);
ok(!strcmp(buf, "123456 1"), "buf = %s\n", buf);
vsprintf_wrapper(UCRTBASE_PRINTF_LEGACY_MSVCRT_COMPATIBILITY,
buf, sizeof(buf), "%zx %d", (size_t) 0x123456, 1);
ok(!strcmp(buf, "123456 1"), "buf = %s\n", buf);
}
}
START_TEST(printf) START_TEST(printf)
{ {
if (!init()) return; if (!init()) return;
...@@ -434,4 +457,5 @@ START_TEST(printf) ...@@ -434,4 +457,5 @@ START_TEST(printf)
test_printf_legacy_wide(); test_printf_legacy_wide();
test_printf_legacy_msvcrt(); test_printf_legacy_msvcrt();
test_printf_legacy_three_digit_exp(); test_printf_legacy_three_digit_exp();
test_printf_c99();
} }
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