summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <matthiasc@src.gnome.org>2001-12-06 22:37:05 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2001-12-06 22:37:05 +0000
commit39e4c5afe8a4f4953e3a2905a51aeaa41a91b598 (patch)
tree7d812e03b85bc90d73bdc4656c9952f43e74ec2f
parent964ebaf18c4a16ecc650a21a9d95df18a3c32c37 (diff)
downloadglib-39e4c5afe8a4f4953e3a2905a51aeaa41a91b598.tar.gz
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().
-rw-r--r--ChangeLog22
-rw-r--r--ChangeLog.pre-2-022
-rw-r--r--ChangeLog.pre-2-1022
-rw-r--r--ChangeLog.pre-2-1222
-rw-r--r--ChangeLog.pre-2-222
-rw-r--r--ChangeLog.pre-2-422
-rw-r--r--ChangeLog.pre-2-622
-rw-r--r--ChangeLog.pre-2-822
-rw-r--r--acinclude.m444
-rw-r--r--configure.in2
-rw-r--r--glib/ghash.h4
-rw-r--r--glib/glibintl.h2
-rw-r--r--glib/gmacros.h14
-rw-r--r--glib/gmessages.c7
14 files changed, 238 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 2e562abaa..a48780eea 100644
--- 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
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 2e562abaa..a48780eea 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -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
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 2e562abaa..a48780eea 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -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
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 2e562abaa..a48780eea 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -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
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 2e562abaa..a48780eea 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -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
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 2e562abaa..a48780eea 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -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
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 2e562abaa..a48780eea 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -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
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 2e562abaa..a48780eea 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -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
diff --git a/acinclude.m4 b/acinclude.m4
index 583b7b8fc..b529e17e4 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 <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
+
diff --git a/configure.in b/configure.in
index 473852a27..59fed86c4 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 acc2d176e..fccff0eec 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 c7a1b6acc..c16b42d83 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 <libintl.h>
#define _(String) _glib_gettext(String)
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 896948e87..204b24d1a 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 6781ed0ac..13b5cac48 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