diff aclocal.m4 @ 9173:224634b2e6e3

configure.in, aclocal.m4: check for c99 vsnprintf
author Peter O'Gorman <pogma@thewrittenword.com>
date Mon, 04 May 2009 15:57:28 -0400
parents 56018fcd28b0
children 8a5a04b6c46b
line wrap: on
line diff
--- a/aclocal.m4	Mon May 04 15:47:05 2009 -0400
+++ b/aclocal.m4	Mon May 04 15:57:28 2009 -0400
@@ -1422,3 +1422,41 @@
     [$5]
   fi
 ])
+dnl
+dnl Do we have a working c99 vsnprintf function?
+dnl
+dnl OCTAVE_HAVE_C99_VSNPRINTF
+AC_DEFUN(OCTAVE_HAVE_C99_VSNPRINTF, [
+  AC_CACHE_CHECK([for c99 vsnprintf], [oct_cv_c99_vsnprintf],
+    [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+int
+doit(char * s, ...)
+{
+  char buffer[32];
+  va_list args;
+  int r;
+
+  va_start(args, s);
+  r = vsnprintf(buffer, 5, s, args);
+  va_end(args);
+
+  if (r != 7)
+    exit(1);
+
+  exit(0);
+}
+  ]],[
+doit("1234567");])],
+  [oct_cv_c99_vsnprintf=yes],
+  [oct_cv_c99_vsnprintf=no],
+  [oct_cv_c99_vsnprintf="guessing no"])])
+
+case $oct_cv_c99_vsnprintf in
+yes)
+    AC_DEFINE([HAVE_C99_VSNPRINTF], [1], [Define if you have a c99 vsnprintf])
+  ;;
+esac
+])