From aae7c8b73a7ca2712d53448f1b8e5ba72312effe Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 10 Sep 2001 22:15:05 +0000 Subject: [PATCH] fixed configure check for c99 vsnprintf --- acconfig.h | 3 +++ configure.ac | 26 ++++++++++++++++++++++++++ configure.in | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/acconfig.h b/acconfig.h index 9264956b..a1ec4531 100644 --- a/acconfig.h +++ b/acconfig.h @@ -89,3 +89,6 @@ /* define if you want Hermes support */ #undef HAVE_HERMES +/* define if you have vsnprintf with C99 semantics */ +#undef HAVE_C99_VSNPRINTF + diff --git a/configure.ac b/configure.ac index dfaed03e..48bd150a 100644 --- a/configure.ac +++ b/configure.ac @@ -103,6 +103,32 @@ AC_FUNC_ALLOCA AC_CHECK_FUNCS(gethostname select poll strerror strcasecmp strncasecmp setpgid atexit mallinfo snprintf vsnprintf asprintf vasprintf mkstemp) +dnl ripped from samba +dnl +AC_CACHE_CHECK([for C99 vsnprintf],_cv_HAVE_C99_VSNPRINTF,[ +AC_TRY_RUN([ +#include +#include +void foo(const char *format, ...) { + va_list ap; + int len; + char buf[5]; + + va_start(ap, format); + len = vsnprintf(0, 0, format, ap); + va_end(ap); + if (len != 5) exit(1); + + if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); + + exit(0); +} +main() { foo("hello"); } +], +_cv_HAVE_C99_VSNPRINTF=yes,_cv_HAVE_C99_VSNPRINTF=no,_cv_HAVE_C99_VSNPRINTF=cross)]) +if test x"$_cv_HAVE_C99_VSNPRINTF" = x"yes"; then + AC_DEFINE(HAVE_C99_VSNPRINTF) +fi dnl Loading of dynamic libraries at runtime dnl ======================================= diff --git a/configure.in b/configure.in index 85dd1690..48bd150a 100644 --- a/configure.in +++ b/configure.in @@ -105,7 +105,7 @@ AC_CHECK_FUNCS(gethostname select poll strerror strcasecmp strncasecmp setpgid a dnl ripped from samba dnl -C_CACHE_CHECK([for C99 vsnprintf],_cv_HAVE_C99_VSNPRINTF,[ +AC_CACHE_CHECK([for C99 vsnprintf],_cv_HAVE_C99_VSNPRINTF,[ AC_TRY_RUN([ #include #include -- 2.11.4.GIT