Fix the printf issue for 64 bits. The following case:
printf("%1$s %1$s\n", "test");
would print garbage instead of the second "test". The problem is __find_arguments
and the patch is a backport of two patches from OpenBSD that fix the issue:
Author: tedu <tedu@cvs.openbsd.org>
Date: Sat Apr 29 23:00:24 2006 +0000
check mmap for failure. the helper functions using it return -1, but
callers do not yet check since printf() for example is not documented
to return an error.
some formatting cleanups.
mostly ok deraadt millert
Author: millert <millert@cvs.openbsd.org>
Date: Fri May 16 14:28:54 2008 +0000
C99 says that for each va_copy() there must be a matching va_end().
Replace the non-portable hackery in __find_arguments() with a union.
From FreeBSD.
Change-Id: I6ea392ce6fcf4a319ae6a67ec58cc52fe7cbe534
Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 8c1cef9..cc1fd85 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -297,6 +297,9 @@
snprintf(buf, sizeof(buf), "a_%g_b", 3.14);
EXPECT_STREQ("a_3.14_b", buf);
+
+ snprintf(buf, sizeof(buf), "%1$s %1$s", "print_me_twice");
+ EXPECT_STREQ("print_me_twice print_me_twice", buf);
}
TEST(stdio, snprintf_d_INT_MAX) {