changeset 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 cd68431b395a
children 07966ebb1055
files ChangeLog aclocal.m4 configure.in src/ChangeLog src/utils.cc
diffstat 5 files changed, 46 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon May 04 15:47:05 2009 -0400
+++ b/ChangeLog	Mon May 04 15:57:28 2009 -0400
@@ -1,5 +1,8 @@
 2009-05-04  Peter O'Gorman  <pogma@thewrittenword.com>
 
+	* aclocal.m4 (OCTAVE_HAVE_C99_VSNPRINTF): New macro.
+	* configure.in: Use it.
+
 	* configure.in (rs6000-ibm-aix* | powerpc-ibm-aix*): Set
 	library_path_var to LIBPATH.
 	(hppa*-hp-hpux*): Set library_path_var to SHLIB_PATH.
--- 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
+])
--- a/configure.in	Mon May 04 15:47:05 2009 -0400
+++ b/configure.in	Mon May 04 15:57:28 2009 -0400
@@ -1646,6 +1646,7 @@
   ;;
 esac
 
+OCTAVE_HAVE_C99_VSNPRINTF
 OCTAVE_STRPTIME_BROKEN
 OCTAVE_SMART_PUTENV
 
--- a/src/ChangeLog	Mon May 04 15:47:05 2009 -0400
+++ b/src/ChangeLog	Mon May 04 15:57:28 2009 -0400
@@ -1,3 +1,7 @@
+2009-05-04  Peter O'Gorman  <pogma@thewrittenword.com>
+
+	* utils.cc: Don't define HAVE_C99_VSNPRINTF here.
+
 2009-05-01  John W. Eaton  <jwe@octave.org>
 
 	* error.cc (Vlast_error_file, Vlast_error_name, Vlast_error_line,
--- a/src/utils.cc	Mon May 04 15:47:05 2009 -0400
+++ b/src/utils.cc	Mon May 04 15:57:28 2009 -0400
@@ -1081,12 +1081,6 @@
   return retval;
 }
 
-/* FIXME -- we really need a configure test for this.  */
-
-#if defined __GNUC__ && __GNUC__ >= 3 && ! defined __MINGW32__
-#define HAVE_C99_VSNPRINTF 1
-#endif
-
 // We manage storage.  User should not free it, and its contents are
 // only valid until next call to vsnprintf.