From 39e4c5afe8a4f4953e3a2905a51aeaa41a91b598 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 6 Dec 2001 22:37:05 +0000 Subject: [PATCH] The following patch corrects some function attributes. (#61780) 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(). --- ChangeLog | 22 ++++++++++++++++++++++ ChangeLog.pre-2-0 | 22 ++++++++++++++++++++++ ChangeLog.pre-2-10 | 22 ++++++++++++++++++++++ ChangeLog.pre-2-12 | 22 ++++++++++++++++++++++ ChangeLog.pre-2-2 | 22 ++++++++++++++++++++++ ChangeLog.pre-2-4 | 22 ++++++++++++++++++++++ ChangeLog.pre-2-6 | 22 ++++++++++++++++++++++ ChangeLog.pre-2-8 | 22 ++++++++++++++++++++++ acinclude.m4 | 44 ++++++++++++++++++++++++++++++++++++++++++++ configure.in | 2 ++ glib/ghash.h | 4 ++-- glib/glibintl.h | 2 +- glib/gmacros.h | 14 +++++++------- glib/gmessages.c | 7 ++++++- 14 files changed, 238 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2e562ab..a48780e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2001-12-06 Matthias Clasen + + 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 + + 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 * glib/gtree.c (g_tree_foreach): mention the fact that the tree is diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 2e562ab..a48780e 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,25 @@ +2001-12-06 Matthias Clasen + + 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 + + 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 * glib/gtree.c (g_tree_foreach): mention the fact that the tree is diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 2e562ab..a48780e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,25 @@ +2001-12-06 Matthias Clasen + + 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 + + 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 * glib/gtree.c (g_tree_foreach): mention the fact that the tree is diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 2e562ab..a48780e 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,25 @@ +2001-12-06 Matthias Clasen + + 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 + + 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 * glib/gtree.c (g_tree_foreach): mention the fact that the tree is diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 2e562ab..a48780e 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,25 @@ +2001-12-06 Matthias Clasen + + 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 + + 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 * glib/gtree.c (g_tree_foreach): mention the fact that the tree is diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 2e562ab..a48780e 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,25 @@ +2001-12-06 Matthias Clasen + + 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 + + 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 * glib/gtree.c (g_tree_foreach): mention the fact that the tree is diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 2e562ab..a48780e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,25 @@ +2001-12-06 Matthias Clasen + + 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 + + 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 * glib/gtree.c (g_tree_foreach): mention the fact that the tree is diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 2e562ab..a48780e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,25 @@ +2001-12-06 Matthias Clasen + + 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 + + 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 * glib/gtree.c (g_tree_foreach): mention the fact that the tree is diff --git a/acinclude.m4 b/acinclude.m4 index 583b7b8..b529e17 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 +#include + +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 + diff --git a/configure.in b/configure.in index 473852a..59fed86 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/glib/ghash.h b/glib/ghash.h index acc2d17..fccff0e 100644 --- a/glib/ghash.h +++ b/glib/ghash.h @@ -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 diff --git a/glib/glibintl.h b/glib/glibintl.h index c7a1b6a..c16b42d 100644 --- a/glib/glibintl.h +++ b/glib/glibintl.h @@ -5,7 +5,7 @@ #ifdef ENABLE_NLS -gchar *_glib_gettext (const gchar *str); +gchar *_glib_gettext (const gchar *str) G_GNUC_FORMAT (1); #include #define _(String) _glib_gettext(String) diff --git a/glib/gmacros.h b/glib/gmacros.h index 896948e..204b24d 100644 --- a/glib/gmacros.h +++ b/glib/gmacros.h @@ -56,19 +56,19 @@ #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 ) diff --git a/glib/gmessages.c b/glib/gmessages.c index 6781ed0..13b5cac 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -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 -- 2.7.4