Martin Storsjo : ucrtbase: Handle the C99 'z' size_t specifier for integers.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Nov 4 09:40:40 CST 2015
Module: wine
Branch: master
Commit: 4a79e54917a0e4d0581b62b9fcd8242291d545b4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4a79e54917a0e4d0581b62b9fcd8242291d545b4
Author: Martin Storsjo <martin at martin.st>
Date: Tue Nov 3 20:40:40 2015 +0200
ucrtbase: Handle the C99 'z' size_t specifier for integers.
Signed-off-by: Martin Storsjo <martin at martin.st>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msvcrt/printf.h | 4 ++++
dlls/msvcrt/tests/printf.c | 5 +++++
dlls/ucrtbase/tests/printf.c | 24 ++++++++++++++++++++++++
3 files changed, 33 insertions(+)
diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h
index f68eaf6..ce7a70e 100644
--- a/dlls/msvcrt/printf.h
+++ b/dlls/msvcrt/printf.h
@@ -473,6 +473,10 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
flags.IntegerNative = *p++;
} else if(*p == 'w')
flags.WideString = *p++;
+#if _MSVCR_VER >= 140
+ else if(*p == 'z')
+ flags.IntegerNative = *p++;
+#endif
else if((*p == 'F' || *p == 'N') && legacy_msvcrt_compat)
p++; /* ignore */
else
diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c
index c8797f3..295c6dd 100644
--- a/dlls/msvcrt/tests/printf.c
+++ b/dlls/msvcrt/tests/printf.c
@@ -321,6 +321,11 @@ static void test_sprintf( void )
ok(!strcmp(buffer,"D"),"I64D failed: %s\n",buffer);
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";
r = sprintf(buffer,format,1);
ok(!strcmp(buffer, " 1"),"Problem with sign place-holder: '%s'\n",buffer);
diff --git a/dlls/ucrtbase/tests/printf.c b/dlls/ucrtbase/tests/printf.c
index ae12b60..6c719ea 100644
--- a/dlls/ucrtbase/tests/printf.c
+++ b/dlls/ucrtbase/tests/printf.c
@@ -423,6 +423,29 @@ static void test_printf_legacy_three_digit_exp(void)
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)
{
if (!init()) return;
@@ -434,4 +457,5 @@ START_TEST(printf)
test_printf_legacy_wide();
test_printf_legacy_msvcrt();
test_printf_legacy_three_digit_exp();
+ test_printf_c99();
}
More information about the wine-cvs
mailing list