attempts to fix vsnprintf() detection under HP-UX

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18808 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2003-01-18 02:33:13 +00:00
parent 677eb52d3f
commit ec0d6da38d
4 changed files with 48 additions and 0 deletions

View File

@@ -3151,11 +3151,44 @@ AC_LANG_SAVE
AC_LANG_CPLUSPLUS AC_LANG_CPLUSPLUS
dnl check for vsnprintf() -- a safe version of vsprintf()) dnl check for vsnprintf() -- a safe version of vsprintf())
dnl
dnl the trouble here is that on some systems (notable HP-UX) this function is
dnl present in libc but not in the system headers and so AC_CHECK_FUNCS (which,
dnl stupidly, provides a dummy function declaration inside its extension)
dnl succeeds, even with C++ compiler, but the compilation of wxWindows fails
dnl
dnl so we first check if the function is in the library
AC_CHECK_FUNCS(vsnprintf) AC_CHECK_FUNCS(vsnprintf)
if test "$ac_cv_func_vsnprintf" = "yes"; then
dnl yes it is -- now check if it is in the headers
AC_CACHE_CHECK([for vsnprintf declaration], wx_cv_func_vsnprintf_decl,
[
AC_TRY_COMPILE(
[
#include <stdio.h>
#include <stdarg.h>
],
[
char *buf;
va_list ap;
vsnprintf(buf, 10u, "%s", ap);
],
wx_cv_func_vsnprintf_decl=yes,
wx_cv_func_vsnprintf_decl=no
)
]
)
if test "$wx_cv_func_vsnprintf_decl" = "yes"; then
AC_DEFINE(HAVE_VSNPRINTF_DECL)
fi
fi
if test "$wxUSE_UNICODE" = yes; then if test "$wxUSE_UNICODE" = yes; then
dnl also look if we have wide char IO functions dnl also look if we have wide char IO functions
AC_CHECK_FUNCS(fputwc wprintf vswprintf) AC_CHECK_FUNCS(fputwc wprintf vswprintf)
dnl MinGW has a vswprintf with a different prototype, and dnl MinGW has a vswprintf with a different prototype, and
dnl a _vsnwprintf with the correct prototype, but AC_CHECK_FUNCS dnl a _vsnwprintf with the correct prototype, but AC_CHECK_FUNCS
dnl finds it even if it is not declared in some versions... dnl finds it even if it is not declared in some versions...

View File

@@ -594,6 +594,15 @@ WXDLLEXPORT bool wxOKlibc(); // for internal use
// printf() family saga // printf() family saga
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
/*
For some systems vsnprintf() exists in the system libraries but not in the
headers, so we need to declare it ourselves to be able to use it.
*/
#ifndef HAVE_VSNPRINTF_DECL
extern "C"
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
#endif // !HAVE_VSNPRINTF_DECL
/* /*
First of all, we always want to define safe snprintf() function to be used First of all, we always want to define safe snprintf() function to be used
instead of sprintf(). Some compilers already have it (or rather vsnprintf() instead of sprintf(). Some compilers already have it (or rather vsnprintf()

View File

@@ -964,6 +964,9 @@
/* Define if you have vsnprintf() */ /* Define if you have vsnprintf() */
#undef HAVE_VSNPRINTF #undef HAVE_VSNPRINTF
/* Define if you have vsnprintf() declaration in the header */
#undef HAVE_VSNPRINTF_DECL
/* Define if you have usleep() */ /* Define if you have usleep() */
#undef HAVE_USLEEP #undef HAVE_USLEEP

View File

@@ -993,6 +993,9 @@
/* Define if you have vsnprintf() */ /* Define if you have vsnprintf() */
#undef HAVE_VSNPRINTF #undef HAVE_VSNPRINTF
/* Define if you have vsnprintf() declaration in the header */
#undef HAVE_VSNPRINTF_DECL
/* Define if you have usleep() */ /* Define if you have usleep() */
#define HAVE_USLEEP 1 #define HAVE_USLEEP 1