From 5ee517ac3d7304f29fd84237af06100f07f33b40 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Fri, 9 Aug 2002 19:49:31 +0000 Subject: [PATCH] Copy va_lists by using va_copy, not by just assigning them. --- configure | 113 ++++++++++++++++++++++++++++++++++++++++++ configure.ac | 28 +++++++++++ dlls/msvcrt/process.c | 16 +++++- include/config.h.in | 6 +++ 4 files changed, 162 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 2b224744cfa..0dd4cb6297f 100755 --- a/configure +++ b/configure @@ -8586,6 +8586,119 @@ _ACEOF fi +echo "$as_me:$LINENO: checking for va_copy" >&5 +echo $ECHO_N "checking for va_copy... $ECHO_C" >&6 +if test "${ac_cv_c_va_copy+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +va_list ap1, ap2; + va_copy(ap1,ap2); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_va_copy="yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_c_va_copy="no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_va_copy" >&5 +echo "${ECHO_T}$ac_cv_c_va_copy" >&6 +if test "$ac_cv_c_va_copy" = "yes" +then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_VA_COPY 1 +_ACEOF + +fi +echo "$as_me:$LINENO: checking for __va_copy" >&5 +echo $ECHO_N "checking for __va_copy... $ECHO_C" >&6 +if test "${ac_cv_c___va_copy+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +#include "confdefs.h" +#include +#ifdef F77_DUMMY_MAIN +# ifdef __cplusplus + extern "C" +# endif + int F77_DUMMY_MAIN() { return 1; } +#endif +int +main () +{ +va_list ap1, ap2; + __va_copy(ap1,ap2); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c___va_copy="yes" +else + echo "$as_me: failed program was:" >&5 +cat conftest.$ac_ext >&5 +ac_cv_c___va_copy="no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + +fi +echo "$as_me:$LINENO: result: $ac_cv_c___va_copy" >&5 +echo "${ECHO_T}$ac_cv_c___va_copy" >&6 +if test "$ac_cv_c___va_copy" = "yes" +then + +cat >>confdefs.h <<\_ACEOF +#define HAVE___VA_COPY 1 +_ACEOF + +fi + echo "$as_me:$LINENO: checking for GNU style IPX support" >&5 echo $ECHO_N "checking for GNU style IPX support... $ECHO_C" >&6 if test "${ac_cv_c_ipx_gnu+set}" = set; then diff --git a/configure.ac b/configure.ac index 3e34fe9aad5..37aeb2ec216 100644 --- a/configure.ac +++ b/configure.ac @@ -447,6 +447,34 @@ then AC_DEFINE(HAVE_PPDEV, 1, [Define if we can use ppdev.h for parallel port access]) fi +dnl **** Check for va_copy **** +AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy, + AC_TRY_LINK( + [#include ], + [va_list ap1, ap2; + va_copy(ap1,ap2); + ], + [ac_cv_c_va_copy="yes"], + [ac_cv_c_va_copy="no"]) + ) +if test "$ac_cv_c_va_copy" = "yes" +then + AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy]) +fi +AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy, + AC_TRY_LINK( + [#include ], + [va_list ap1, ap2; + __va_copy(ap1,ap2); + ], + [ac_cv_c___va_copy="yes"], + [ac_cv_c___va_copy="no"]) + ) +if test "$ac_cv_c___va_copy" = "yes" +then + AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy]) +fi + dnl **** Check for IPX (currently Linux only) **** AC_CACHE_CHECK([for GNU style IPX support], ac_cv_c_ipx_gnu, AC_TRY_COMPILE( diff --git a/dlls/msvcrt/process.c b/dlls/msvcrt/process.c index 74796349e8f..fe95ec4d751 100644 --- a/dlls/msvcrt/process.c +++ b/dlls/msvcrt/process.c @@ -25,6 +25,10 @@ * open file handles, sometimes not. The docs are confusing * -No check for maximum path/argument/environment size is done */ +#include "config.h" + +#include + #include "msvcrt.h" #include "ms_errno.h" @@ -141,12 +145,22 @@ static char* msvcrt_argvtos(const char* const* arg, char delim) */ static char* msvcrt_valisttos(const char* arg0, va_list alist, char delim) { - va_list alist2 = alist; + va_list alist2; long size; const char *arg; char* p; char *ret; +#if HAVE_VA_COPY + va_copy(alist2,alist); +#else +# if HAVE___VA_COPY + __va_copy(alist2,alist); +# else + alist2 = alist; +# endif +#endif + if (!arg0 && !delim) { /* Return NULL for an empty environment list */ diff --git a/include/config.h.in b/include/config.h.in index 4a4f258b6c5..61c97ef6f93 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -575,6 +575,9 @@ /* Define to 1 if you have the `usleep' function. */ #undef HAVE_USLEEP +/* Define if we have va_copy */ +#undef HAVE_VA_COPY + /* Define to 1 if you have the `vfscanf' function. */ #undef HAVE_VFSCANF @@ -638,6 +641,9 @@ /* Define to 1 if you have the `__libc_fork' function. */ #undef HAVE___LIBC_FORK +/* Define if we have __va_copy */ +#undef HAVE___VA_COPY + /* Define if stdcall symbols need to be decorated */ #undef NEED_STDCALL_DECORATION