OSDN Git Service

Fix the printf issue for 64 bits. The following case:
authorAlexander Ivchenko <alexander.ivchenko@intel.com>
Tue, 1 Apr 2014 13:01:39 +0000 (17:01 +0400)
committerAlexander Ivchenko <alexander.ivchenko@intel.com>
Wed, 2 Apr 2014 14:30:55 +0000 (18:30 +0400)
commitedd7c2ec256548702d275b3023f54bd91b4dcfc4
tree185b4c42aa947850753ef8caa171dc2e6ecd1b2e
parent9c9ef0db91c816ca81a22a94c3ddd896a0f0f1bc
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>
libc/stdio/vfprintf.c
tests/stdio_test.cpp