Make the various printf feature test macros reflect the system printf,
authorMatthias Clasen <maclas@gmx.de>
Sat, 4 Oct 2003 23:24:02 +0000 (23:24 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sat, 4 Oct 2003 23:24:02 +0000 (23:24 +0000)
2003-10-05  Matthias Clasen  <maclas@gmx.de>

* configure.in: Make the various printf feature test macros
reflect the system printf, even when using the included printf.
In particular, don't force HAVE_C99_SNPRINTF, since g-gnulib.h
needs that test result.  (#122973)

* glib/gprintf.c (g_vasprintf): Don't rely on HAVE_VASPRINTF,
directly check for _g_vasprintf.

* glib/gprintfint.h (_g_vasprintf): Only define _g_vasprintf()
if vasprintf() is available.

* glib/gnulib/printf.c (_g_gnulib_vfprintf): Don't write
trailing nul to the file. (#122973)

* acinclude.m4 (AC_FUNC_VSNPRINTF_C99): Make the test
detect non-C99-compliance of AIX 5.1 and Solaris
vsnprintf().  (#122496)

12 files changed:
ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
acinclude.m4
configure.in
glib/gnulib/README
glib/gnulib/printf.c
glib/gprintf.c
glib/gprintfint.h

index 3edb2e81d8425ac6529a89fca129667fb682f21c..612015a14987ef360a93d1962e10da5a11a26c5a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2003-10-05  Matthias Clasen  <maclas@gmx.de>
+
+       * configure.in: Make the various printf feature test macros
+       reflect the system printf, even when using the included printf.
+       In particular, don't force HAVE_C99_SNPRINTF, since g-gnulib.h 
+       needs that test result.  (#122973)
+
+       * glib/gprintf.c (g_vasprintf): Don't rely on HAVE_VASPRINTF,
+       directly check for _g_vasprintf.
+
+       * glib/gprintfint.h (_g_vasprintf): Only define _g_vasprintf()
+       if vasprintf() is available.
+
+       * glib/gnulib/printf.c (_g_gnulib_vfprintf): Don't write
+       trailing nul to the file. (#122973)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): Make the test 
+       detect non-C99-compliance of AIX 5.1 and Solaris 
+       vsnprintf().  (#122496)
+
 Thu Oct  2 01:15:46 2003  Owen Taylor  <otaylor@redhat.com>
 
        * tests/gobject/ifacecheck.c: Test case for
index 3edb2e81d8425ac6529a89fca129667fb682f21c..612015a14987ef360a93d1962e10da5a11a26c5a 100644 (file)
@@ -1,3 +1,23 @@
+2003-10-05  Matthias Clasen  <maclas@gmx.de>
+
+       * configure.in: Make the various printf feature test macros
+       reflect the system printf, even when using the included printf.
+       In particular, don't force HAVE_C99_SNPRINTF, since g-gnulib.h 
+       needs that test result.  (#122973)
+
+       * glib/gprintf.c (g_vasprintf): Don't rely on HAVE_VASPRINTF,
+       directly check for _g_vasprintf.
+
+       * glib/gprintfint.h (_g_vasprintf): Only define _g_vasprintf()
+       if vasprintf() is available.
+
+       * glib/gnulib/printf.c (_g_gnulib_vfprintf): Don't write
+       trailing nul to the file. (#122973)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): Make the test 
+       detect non-C99-compliance of AIX 5.1 and Solaris 
+       vsnprintf().  (#122496)
+
 Thu Oct  2 01:15:46 2003  Owen Taylor  <otaylor@redhat.com>
 
        * tests/gobject/ifacecheck.c: Test case for
index 3edb2e81d8425ac6529a89fca129667fb682f21c..612015a14987ef360a93d1962e10da5a11a26c5a 100644 (file)
@@ -1,3 +1,23 @@
+2003-10-05  Matthias Clasen  <maclas@gmx.de>
+
+       * configure.in: Make the various printf feature test macros
+       reflect the system printf, even when using the included printf.
+       In particular, don't force HAVE_C99_SNPRINTF, since g-gnulib.h 
+       needs that test result.  (#122973)
+
+       * glib/gprintf.c (g_vasprintf): Don't rely on HAVE_VASPRINTF,
+       directly check for _g_vasprintf.
+
+       * glib/gprintfint.h (_g_vasprintf): Only define _g_vasprintf()
+       if vasprintf() is available.
+
+       * glib/gnulib/printf.c (_g_gnulib_vfprintf): Don't write
+       trailing nul to the file. (#122973)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): Make the test 
+       detect non-C99-compliance of AIX 5.1 and Solaris 
+       vsnprintf().  (#122496)
+
 Thu Oct  2 01:15:46 2003  Owen Taylor  <otaylor@redhat.com>
 
        * tests/gobject/ifacecheck.c: Test case for
index 3edb2e81d8425ac6529a89fca129667fb682f21c..612015a14987ef360a93d1962e10da5a11a26c5a 100644 (file)
@@ -1,3 +1,23 @@
+2003-10-05  Matthias Clasen  <maclas@gmx.de>
+
+       * configure.in: Make the various printf feature test macros
+       reflect the system printf, even when using the included printf.
+       In particular, don't force HAVE_C99_SNPRINTF, since g-gnulib.h 
+       needs that test result.  (#122973)
+
+       * glib/gprintf.c (g_vasprintf): Don't rely on HAVE_VASPRINTF,
+       directly check for _g_vasprintf.
+
+       * glib/gprintfint.h (_g_vasprintf): Only define _g_vasprintf()
+       if vasprintf() is available.
+
+       * glib/gnulib/printf.c (_g_gnulib_vfprintf): Don't write
+       trailing nul to the file. (#122973)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): Make the test 
+       detect non-C99-compliance of AIX 5.1 and Solaris 
+       vsnprintf().  (#122496)
+
 Thu Oct  2 01:15:46 2003  Owen Taylor  <otaylor@redhat.com>
 
        * tests/gobject/ifacecheck.c: Test case for
index 3edb2e81d8425ac6529a89fca129667fb682f21c..612015a14987ef360a93d1962e10da5a11a26c5a 100644 (file)
@@ -1,3 +1,23 @@
+2003-10-05  Matthias Clasen  <maclas@gmx.de>
+
+       * configure.in: Make the various printf feature test macros
+       reflect the system printf, even when using the included printf.
+       In particular, don't force HAVE_C99_SNPRINTF, since g-gnulib.h 
+       needs that test result.  (#122973)
+
+       * glib/gprintf.c (g_vasprintf): Don't rely on HAVE_VASPRINTF,
+       directly check for _g_vasprintf.
+
+       * glib/gprintfint.h (_g_vasprintf): Only define _g_vasprintf()
+       if vasprintf() is available.
+
+       * glib/gnulib/printf.c (_g_gnulib_vfprintf): Don't write
+       trailing nul to the file. (#122973)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): Make the test 
+       detect non-C99-compliance of AIX 5.1 and Solaris 
+       vsnprintf().  (#122496)
+
 Thu Oct  2 01:15:46 2003  Owen Taylor  <otaylor@redhat.com>
 
        * tests/gobject/ifacecheck.c: Test case for
index 3edb2e81d8425ac6529a89fca129667fb682f21c..612015a14987ef360a93d1962e10da5a11a26c5a 100644 (file)
@@ -1,3 +1,23 @@
+2003-10-05  Matthias Clasen  <maclas@gmx.de>
+
+       * configure.in: Make the various printf feature test macros
+       reflect the system printf, even when using the included printf.
+       In particular, don't force HAVE_C99_SNPRINTF, since g-gnulib.h 
+       needs that test result.  (#122973)
+
+       * glib/gprintf.c (g_vasprintf): Don't rely on HAVE_VASPRINTF,
+       directly check for _g_vasprintf.
+
+       * glib/gprintfint.h (_g_vasprintf): Only define _g_vasprintf()
+       if vasprintf() is available.
+
+       * glib/gnulib/printf.c (_g_gnulib_vfprintf): Don't write
+       trailing nul to the file. (#122973)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): Make the test 
+       detect non-C99-compliance of AIX 5.1 and Solaris 
+       vsnprintf().  (#122496)
+
 Thu Oct  2 01:15:46 2003  Owen Taylor  <otaylor@redhat.com>
 
        * tests/gobject/ifacecheck.c: Test case for
index f686739fa1a56d6184bdd3e9c77cb789b37b155f..f86034d75d23ccbf84ac4cf4c53a3289d130f612 100644 (file)
@@ -20,6 +20,16 @@ doit(char * s, ...)
   r = vsnprintf(buffer, 5, s, args);
   va_end(args);
 
+  if (r != 7)
+    exit(1);
+
+  /* AIX 5.1 and Solaris seems to have a half-baked vsnprintf()
+     implementation. The above will return 7 but if you replace
+     the size of the buffer with 0, it borks! */
+  va_start(args, s);
+  r = vsnprintf(buffer, 0, s, args);
+  va_end(args);
+
   if (r != 7)
     exit(1);
 
index f37faff2a750cf3b943a6e10cd9ca6410bf5ab0b..378bcb3a71e912b581bfc80939c0860729e8dd20 100644 (file)
@@ -773,9 +773,6 @@ if test "$enable_included_printf" != "yes" ; then
 else
   glib_cv_long_long_format="ll"
   AC_DEFINE(HAVE_VASPRINTF,1)
-  AC_DEFINE(HAVE_C99_VSNPRINTF,1)
-  AC_DEFINE(HAVE_C99_SNPRINTF,1)
-  AC_DEFINE(HAVE_UNIX98_PRINTF,1)
 fi
 
 # Checks needed for gnulib vasnprintf
@@ -1932,7 +1929,6 @@ AC_ARG_ENABLE(man,
               [AC_HELP_STRING([--enable-man],
                               [regenerate man pages from Docbook [default=no]])],enable_man=yes,
               enable_man=no)
-
 dnl
 dnl Check for xsltproc
 dnl
index cd07d8688b77e7e2ef4ea7b4bb52d512e0b1843e..0b23d6ca13caf182309f60d4a7e3a26e386bcb31 100644 (file)
@@ -13,22 +13,22 @@ be found at:
 
  http://www.gnu.org/software/gnulib/
 
-They have been modified to include g-gnulib.h. vasnprintf.c has also been modified to 
-include support for long long printing if the system printf doesn't. This code is protected
-by #ifndef HAVE_LON_LONG_FORMAT.
+They have been modified to include g-gnulib.h. vasnprintf.c has also
+been modified to include support for long long printing if the system
+printf doesn't. This code is protected by #ifndef HAVE_LON_LONG_FORMAT.
  
-The files 
+The files
 
  printf.h 
  printf.c
  g-gnulib.h
 
-have been written by me. printf.[hc] contain implementations of the
-remaining functions in the printf family based on
-vasnprintf. g-gnulib.h is included by all source files in order to
-move all exported functions to the _g_gnulib namespace, replace malloc
-by g_malloc and make sure that snprintf is only used if it implements
-C99 return value semantics.
+have been written by me. printf.[hc] contain implementations of the  
+remaining functions in the printf family based on vasnprintf. 
+g-gnulib.h is included by all source files in order to move all
+exported functions to the _g_gnulib namespace, replace malloc by
+g_malloc and make sure that snprintf is only used if it implements 
+C99 return value semantics. 
 
 Matthias Clasen
 July 28, 2003
index 18d29dde6d883da33483d41fc95f45f0154b41f8..b3392999f787ad90697ad72f786125718d1613e4 100644 (file)
@@ -96,7 +96,7 @@ int _g_gnulib_vfprintf (FILE *file, char const *format, va_list args)
   if (result == NULL) 
     return -1;
 
-  fwrite (result, 1, length + 1, file);
+  fwrite (result, 1, length, file);
   free (result);
   
   return length;
index 754b1913787ca102c5f2fcbb7e516819092b3789..9b511ead84d14531d6a934e85073358359820c83 100644 (file)
@@ -300,7 +300,7 @@ g_vasprintf (gchar      **string,
   gint len;
   g_return_val_if_fail (string != NULL, -1);
 
-#ifdef HAVE_VASPRINTF
+#ifdef _g_vasprintf
   len = _g_vasprintf (string, format, args);
   if (len < 0)
     *string = NULL;
index 103981b9c266da0b78c9f6119fdb914d7b543ce9..2195e6fcb50bce3cf2fbd98db1dcd15e7f456474 100644 (file)
@@ -39,7 +39,9 @@
 #define _g_vsprintf  vsprintf
 #define _g_vsnprintf vsnprintf
 
+#ifdef HAVE_VASPRINTF
 #define _g_vasprintf vasprintf
+#endif
 
 #else