pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

test patch for gnulib to fix snprintf


From: Ben Pfaff
Subject: test patch for gnulib to fix snprintf
Date: Thu, 08 Feb 2007 16:50:43 -0800
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

Hi.  Would you mind trying the following patch against gnulib to
see if it fixes the problem with snprintf under mingw?  After you
apply it to the gnulib tree, you'll need to run "gnulib-tool
--update" or "make -f Smake" in the PSPP tree, and then "make".

If this works, I'll throw it over to the gnulib list and they can
tell me what's wrong with it ;-)

Index: lib/vasnprintf.c
===================================================================
RCS file: /sources/gnulib/gnulib/lib/vasnprintf.c,v
retrieving revision 1.22
diff -u -p -r1.22 vasnprintf.c
--- lib/vasnprintf.c    30 Jan 2007 01:07:22 -0000      1.22
+++ lib/vasnprintf.c    9 Feb 2007 00:47:17 -0000
@@ -27,6 +27,9 @@
 # include <alloca.h>
 #endif
 
+/* If we're replacing snprintf with rpl_snprintf, avoid a loop. */
+#undef snprintf
+
 /* Specification.  */
 #if WIDE_CHAR_VERSION
 # include "vasnwprintf.h"
Index: m4/snprintf.m4
===================================================================
RCS file: /sources/gnulib/gnulib/m4/snprintf.m4,v
retrieving revision 1.3
diff -u -p -r1.3 snprintf.m4
--- m4/snprintf.m4      23 Jan 2005 08:06:57 -0000      1.3
+++ m4/snprintf.m4      9 Feb 2007 00:47:17 -0000
@@ -6,7 +6,22 @@ dnl with or without modifications, as lo
 
 AC_DEFUN([gl_FUNC_SNPRINTF],
 [
-  AC_REPLACE_FUNCS(snprintf)
+  AC_CACHE_CHECK([whether snprintf works],
+    [gl_cv_func_snprintf],
+    [AC_RUN_IFELSE(
+       [AC_LANG_PROGRAM(
+         [[#include <stdio.h>]],
+         [[char s[2];
+return !(snprintf (s, 2, "foo") == 3 && s[0] == 'f' && s[1] == '\0');]])],
+       [gl_cv_func_snprintf=yes],
+       [gl_cv_func_snprintf=no],
+       [gl_cv_func_snprintf=no])])
+
+  if test $gl_cv_func_snprintf = no; then
+    AC_LIBOBJ(snprintf)
+    AC_DEFINE(snprintf, rpl_snprintf,
+      [Define to rpl_snprintf if the replacement function should be used.])
+  fi
   AC_CHECK_DECLS_ONCE(snprintf)
   gl_PREREQ_SNPRINTF
 ])

-- 
"In the PARTIES partition there is a small section called the BEER.
 Prior to turning control over to the PARTIES partition,
 the BIOS must measure the BEER area into PCR[5]."
--TCPA PC Specific Implementation Specification




reply via email to

[Prev in Thread] Current Thread [Next in Thread]