The following patch corrects some function attributes. (#61780)
authorMatthias Clasen <matthiasc@src.gnome.org>
Thu, 6 Dec 2001 22:37:05 +0000 (22:37 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 6 Dec 2001 22:37:05 +0000 (22:37 +0000)
        The following patch corrects some function attributes. (#61780)

        * glib/ghash.h (g_int_equal, g_int_hash): These are not const.

        * glib/glibintl.h (_glib_gettext): Add G_GNUC_FORMAT(1).

        * glib/gmacros.h: Use reserved symbols in function attribute macros.

        The following patch avoids manual printf()-format parsing
        if a C99-conforming vsnprintf() is available. (#55106)

        * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): New macro to test for a
        C99 conforming vsnprintf.

        * configure.in: Use AC_FUNC_VSNPRINTF_C99.

        * glib/gmessages.c (g_printf_string_upper_bound): Use C99 vsnprintf().

14 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
acinclude.m4
configure.in
glib/ghash.h
glib/glibintl.h
glib/gmacros.h
glib/gmessages.c

index 2e562ab..a48780e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch corrects some function attributes. (#61780)
+
+       * glib/ghash.h (g_int_equal, g_int_hash): These are not const.
+
+       * glib/glibintl.h (_glib_gettext): Add G_GNUC_FORMAT(1).
+
+       * glib/gmacros.h: Use reserved symbols in function attribute macros.
+
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch avoids manual printf()-format parsing 
+       if a C99-conforming vsnprintf() is available. (#55106)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): New macro to test for a
+       C99 conforming vsnprintf.
+
+       * configure.in: Use AC_FUNC_VSNPRINTF_C99. 
+
+       * glib/gmessages.c (g_printf_string_upper_bound): Use C99 vsnprintf().
+       
 2001-12-05  Sven Neumann  <sven@gimp.org>
 
        * glib/gtree.c (g_tree_foreach): mention the fact that the tree is
index 2e562ab..a48780e 100644 (file)
@@ -1,3 +1,25 @@
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch corrects some function attributes. (#61780)
+
+       * glib/ghash.h (g_int_equal, g_int_hash): These are not const.
+
+       * glib/glibintl.h (_glib_gettext): Add G_GNUC_FORMAT(1).
+
+       * glib/gmacros.h: Use reserved symbols in function attribute macros.
+
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch avoids manual printf()-format parsing 
+       if a C99-conforming vsnprintf() is available. (#55106)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): New macro to test for a
+       C99 conforming vsnprintf.
+
+       * configure.in: Use AC_FUNC_VSNPRINTF_C99. 
+
+       * glib/gmessages.c (g_printf_string_upper_bound): Use C99 vsnprintf().
+       
 2001-12-05  Sven Neumann  <sven@gimp.org>
 
        * glib/gtree.c (g_tree_foreach): mention the fact that the tree is
index 2e562ab..a48780e 100644 (file)
@@ -1,3 +1,25 @@
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch corrects some function attributes. (#61780)
+
+       * glib/ghash.h (g_int_equal, g_int_hash): These are not const.
+
+       * glib/glibintl.h (_glib_gettext): Add G_GNUC_FORMAT(1).
+
+       * glib/gmacros.h: Use reserved symbols in function attribute macros.
+
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch avoids manual printf()-format parsing 
+       if a C99-conforming vsnprintf() is available. (#55106)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): New macro to test for a
+       C99 conforming vsnprintf.
+
+       * configure.in: Use AC_FUNC_VSNPRINTF_C99. 
+
+       * glib/gmessages.c (g_printf_string_upper_bound): Use C99 vsnprintf().
+       
 2001-12-05  Sven Neumann  <sven@gimp.org>
 
        * glib/gtree.c (g_tree_foreach): mention the fact that the tree is
index 2e562ab..a48780e 100644 (file)
@@ -1,3 +1,25 @@
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch corrects some function attributes. (#61780)
+
+       * glib/ghash.h (g_int_equal, g_int_hash): These are not const.
+
+       * glib/glibintl.h (_glib_gettext): Add G_GNUC_FORMAT(1).
+
+       * glib/gmacros.h: Use reserved symbols in function attribute macros.
+
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch avoids manual printf()-format parsing 
+       if a C99-conforming vsnprintf() is available. (#55106)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): New macro to test for a
+       C99 conforming vsnprintf.
+
+       * configure.in: Use AC_FUNC_VSNPRINTF_C99. 
+
+       * glib/gmessages.c (g_printf_string_upper_bound): Use C99 vsnprintf().
+       
 2001-12-05  Sven Neumann  <sven@gimp.org>
 
        * glib/gtree.c (g_tree_foreach): mention the fact that the tree is
index 2e562ab..a48780e 100644 (file)
@@ -1,3 +1,25 @@
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch corrects some function attributes. (#61780)
+
+       * glib/ghash.h (g_int_equal, g_int_hash): These are not const.
+
+       * glib/glibintl.h (_glib_gettext): Add G_GNUC_FORMAT(1).
+
+       * glib/gmacros.h: Use reserved symbols in function attribute macros.
+
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch avoids manual printf()-format parsing 
+       if a C99-conforming vsnprintf() is available. (#55106)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): New macro to test for a
+       C99 conforming vsnprintf.
+
+       * configure.in: Use AC_FUNC_VSNPRINTF_C99. 
+
+       * glib/gmessages.c (g_printf_string_upper_bound): Use C99 vsnprintf().
+       
 2001-12-05  Sven Neumann  <sven@gimp.org>
 
        * glib/gtree.c (g_tree_foreach): mention the fact that the tree is
index 2e562ab..a48780e 100644 (file)
@@ -1,3 +1,25 @@
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch corrects some function attributes. (#61780)
+
+       * glib/ghash.h (g_int_equal, g_int_hash): These are not const.
+
+       * glib/glibintl.h (_glib_gettext): Add G_GNUC_FORMAT(1).
+
+       * glib/gmacros.h: Use reserved symbols in function attribute macros.
+
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch avoids manual printf()-format parsing 
+       if a C99-conforming vsnprintf() is available. (#55106)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): New macro to test for a
+       C99 conforming vsnprintf.
+
+       * configure.in: Use AC_FUNC_VSNPRINTF_C99. 
+
+       * glib/gmessages.c (g_printf_string_upper_bound): Use C99 vsnprintf().
+       
 2001-12-05  Sven Neumann  <sven@gimp.org>
 
        * glib/gtree.c (g_tree_foreach): mention the fact that the tree is
index 2e562ab..a48780e 100644 (file)
@@ -1,3 +1,25 @@
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch corrects some function attributes. (#61780)
+
+       * glib/ghash.h (g_int_equal, g_int_hash): These are not const.
+
+       * glib/glibintl.h (_glib_gettext): Add G_GNUC_FORMAT(1).
+
+       * glib/gmacros.h: Use reserved symbols in function attribute macros.
+
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch avoids manual printf()-format parsing 
+       if a C99-conforming vsnprintf() is available. (#55106)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): New macro to test for a
+       C99 conforming vsnprintf.
+
+       * configure.in: Use AC_FUNC_VSNPRINTF_C99. 
+
+       * glib/gmessages.c (g_printf_string_upper_bound): Use C99 vsnprintf().
+       
 2001-12-05  Sven Neumann  <sven@gimp.org>
 
        * glib/gtree.c (g_tree_foreach): mention the fact that the tree is
index 2e562ab..a48780e 100644 (file)
@@ -1,3 +1,25 @@
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch corrects some function attributes. (#61780)
+
+       * glib/ghash.h (g_int_equal, g_int_hash): These are not const.
+
+       * glib/glibintl.h (_glib_gettext): Add G_GNUC_FORMAT(1).
+
+       * glib/gmacros.h: Use reserved symbols in function attribute macros.
+
+2001-12-06  Matthias Clasen  <matthiasc@poet.de>
+
+       The following patch avoids manual printf()-format parsing 
+       if a C99-conforming vsnprintf() is available. (#55106)
+
+       * acinclude.m4 (AC_FUNC_VSNPRINTF_C99): New macro to test for a
+       C99 conforming vsnprintf.
+
+       * configure.in: Use AC_FUNC_VSNPRINTF_C99. 
+
+       * glib/gmessages.c (g_printf_string_upper_bound): Use C99 vsnprintf().
+       
 2001-12-05  Sven Neumann  <sven@gimp.org>
 
        * glib/gtree.c (g_tree_foreach): mention the fact that the tree is
index 583b7b8..b529e17 100644 (file)
@@ -235,3 +235,47 @@ strdup __argz_count __argz_stringify __argz_next])
        < $srcdir/po/POTFILES.in > po/POTFILES
   ])
 
+dnl @synopsis AC_FUNC_VSNPRINTF_C99
+dnl
+dnl Check whether there is a vsnprintf() function with C99 semantics installed.
+dnl
+AC_DEFUN([AC_FUNC_VSNPRINTF_C99],
+[AC_CACHE_CHECK(for C99 vsnprintf,
+  ac_cv_func_vsnprintf_c99,
+[AC_TRY_RUN(
+[#include <stdio.h>
+#include <stdarg.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);
+}
+
+int
+main(void)
+{
+  doit("1234567");
+  exit(1);
+}], ac_cv_func_vsnprintf_c99=yes, ac_cv_func_vsnprintf_c99=no, ac_cv_func_vsnprintf_c99=no)])
+dnl Note that the default is to be pessimistic in the case of cross compilation.
+dnl If you know that the target has a C99 vsnprintf(), you can get around this
+dnl by setting ac_func_vsnprintf_c99 to yes, as described in the Autoconf manual.
+if test $ac_cv_func_vsnprintf_c99 = yes; then
+  AC_DEFINE(HAVE_C99_VSNPRINTF, 1,
+            [Define if you have a version of the vsnprintf function
+             with semantics as specified by the ISO C99 standard.])
+fi
+])# AC_FUNC_VSNPRINTF_C99
+
index 473852a..59fed86 100644 (file)
@@ -561,6 +561,8 @@ GLIB_SIZEOF([$size_includes], intmax_t, intmax_t)
 # Check for some functions
 AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf stpcpy strcasecmp strncasecmp poll getcwd nanosleep vasprintf)
 
+AC_FUNC_VSNPRINTF_C99
+
 # Check if bcopy can be used for overlapping copies, if memmove isn't found.
 # The check is borrowed from the PERL Configure script.
 if test "$ac_cv_func_memmove" != "yes"; then
index acc2d17..fccff0e 100644 (file)
@@ -89,8 +89,8 @@ gboolean g_str_equal (gconstpointer  v,
 guint    g_str_hash  (gconstpointer  v);
 
 gboolean g_int_equal (gconstpointer  v,
-                      gconstpointer  v2) G_GNUC_CONST;
-guint    g_int_hash  (gconstpointer  v) G_GNUC_CONST;
+                      gconstpointer  v2);
+guint    g_int_hash  (gconstpointer  v);
 
 /* This "hash" function will just return the key's adress as an
  * unsigned integer. Useful for hashing on plain adresses or
index c7a1b6a..c16b42d 100644 (file)
@@ -5,7 +5,7 @@
 
 #ifdef ENABLE_NLS
 
-gchar *_glib_gettext (const gchar *str);
+gchar *_glib_gettext (const gchar *str) G_GNUC_FORMAT (1);
 
 #include <libintl.h>
 #define _(String) _glib_gettext(String)
index 896948e..204b24d 100644 (file)
 
 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
 #define G_GNUC_PRINTF( format_idx, arg_idx )    \
-  __attribute__((format (printf, format_idx, arg_idx)))
+  __attribute__((__format__ (__printf__, format_idx, arg_idx)))
 #define G_GNUC_SCANF( format_idx, arg_idx )     \
-  __attribute__((format (scanf, format_idx, arg_idx)))
+  __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
 #define G_GNUC_FORMAT( arg_idx )                \
-  __attribute__((format_arg (arg_idx)))
+  __attribute__((__format_arg__ (arg_idx)))
 #define G_GNUC_NORETURN                         \
-  __attribute__((noreturn))
+  __attribute__((__noreturn__))
 #define G_GNUC_CONST                            \
-  __attribute__((const))
+  __attribute__((__const__))
 #define G_GNUC_UNUSED                           \
-  __attribute__((unused))
+  __attribute__((__unused__))
 #define G_GNUC_NO_INSTRUMENT                   \
-  __attribute__((no_instrument_function))
+  __attribute__((__no_instrument_function__))
 #else   /* !__GNUC__ */
 #define G_GNUC_PRINTF( format_idx, arg_idx )
 #define G_GNUC_SCANF( format_idx, arg_idx )
index 6781ed0..13b5cac 100644 (file)
@@ -477,7 +477,7 @@ g_logv (const gchar   *log_domain,
 
 #ifndef  HAVE_VSNPRINTF
   va_list args2;
-#endif /* !HAVE_VSNPRINTF */
+#endif /* HAVE_VSNPRINTF */
   
   log_level &= G_LOG_LEVEL_MASK;
   if (!log_level)
@@ -1172,7 +1172,12 @@ gsize
 g_printf_string_upper_bound (const gchar *format,
                             va_list      args)
 {
+#if HAVE_C99_VSNPRINTF
+  gchar c;
+  return vsnprintf (&c, 1, format, args);
+#else
   return printf_string_upper_bound (format, TRUE, args);
+#endif
 }
 
 void