diff --git a/ChangeLog b/ChangeLog index e9c5d4d03..5f0fc52df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2005-03-08 Matthias Clasen + * glib/gmacros.h: Define G_GNUC_NULL_TERMINATED. + (#164706, Marc Meissner) + + * glib/gstrfuncs.h: + * glib/gfileutils.h: Use G_GNUC_NULL_TERMINATED where + appropriate. + * glib/goption.c (parse_int): Fix an error message. (#168751, Hazael Maldonado Torres) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e9c5d4d03..5f0fc52df 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,12 @@ 2005-03-08 Matthias Clasen + * glib/gmacros.h: Define G_GNUC_NULL_TERMINATED. + (#164706, Marc Meissner) + + * glib/gstrfuncs.h: + * glib/gfileutils.h: Use G_GNUC_NULL_TERMINATED where + appropriate. + * glib/goption.c (parse_int): Fix an error message. (#168751, Hazael Maldonado Torres) diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index e9c5d4d03..5f0fc52df 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,5 +1,12 @@ 2005-03-08 Matthias Clasen + * glib/gmacros.h: Define G_GNUC_NULL_TERMINATED. + (#164706, Marc Meissner) + + * glib/gstrfuncs.h: + * glib/gfileutils.h: Use G_GNUC_NULL_TERMINATED where + appropriate. + * glib/goption.c (parse_int): Fix an error message. (#168751, Hazael Maldonado Torres) diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e9c5d4d03..5f0fc52df 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,12 @@ 2005-03-08 Matthias Clasen + * glib/gmacros.h: Define G_GNUC_NULL_TERMINATED. + (#164706, Marc Meissner) + + * glib/gstrfuncs.h: + * glib/gfileutils.h: Use G_GNUC_NULL_TERMINATED where + appropriate. + * glib/goption.c (parse_int): Fix an error message. (#168751, Hazael Maldonado Torres) diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 34aaadea3..d6ed02f2f 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,8 @@ +2005-03-08 Matthias Clasen + + * glib/glib-sections.txt: + * glib/tmpl/macros_misc.sgml: Document G_GNUC_NULL_TERMINATED. + 2005-03-07 Matthias Clasen * gobject/tmpl/gtype.sgml: diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt index a68bb2fae..0d9e58dfa 100644 --- a/docs/reference/glib/glib-sections.txt +++ b/docs/reference/glib/glib-sections.txt @@ -322,6 +322,7 @@ G_GNUC_UNUSED G_GNUC_PRINTF G_GNUC_SCANF G_GNUC_FORMAT +G_GNUC_NULL_TERMINATED G_GNUC_FUNCTION G_GNUC_PRETTY_FUNCTION G_GNUC_NO_INSTRUMENT diff --git a/docs/reference/glib/tmpl/macros_misc.sgml b/docs/reference/glib/tmpl/macros_misc.sgml index 2c57c7783..eacb95dba 100644 --- a/docs/reference/glib/tmpl/macros_misc.sgml +++ b/docs/reference/glib/tmpl/macros_misc.sgml @@ -227,6 +227,17 @@ gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2); @arg_idx: the index of the argument. + + +Expands to the GNU C sentinel function attribute if the +compiler is gcc, or "" if it isn't. This function attribute +only applies to variadic functions and instructs the compiler to check that +the argument list is terminated with an explicit %NULL. +See the GNU C documentation for details. + + +Since: 2.8 + Expands to the GNU C __FUNCTION__ variable if the diff --git a/glib/gfileutils.h b/glib/gfileutils.h index cc3b4941a..94dcaea9d 100644 --- a/glib/gfileutils.h +++ b/glib/gfileutils.h @@ -99,9 +99,9 @@ gint g_file_open_tmp (const gchar *tmpl, gchar *g_build_path (const gchar *separator, const gchar *first_element, - ...); + ...) G_GNUC_NULL_TERMINATED; gchar *g_build_filename (const gchar *first_element, - ...); + ...) G_GNUC_NULL_TERMINATED; G_END_DECLS diff --git a/glib/gmacros.h b/glib/gmacros.h index 10bae0324..84e8e10e3 100644 --- a/glib/gmacros.h +++ b/glib/gmacros.h @@ -57,6 +57,12 @@ #define G_GNUC_MALLOC #endif +#if __GNUC__ >= 4 +#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) +#else +#define G_GNUC_NULL_TERMINATED +#endif + #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) #define G_GNUC_PRINTF( format_idx, arg_idx ) \ __attribute__((__format__ (__printf__, format_idx, arg_idx))) diff --git a/glib/gstrfuncs.h b/glib/gstrfuncs.h index 7319cd929..9c41dcad0 100644 --- a/glib/gstrfuncs.h +++ b/glib/gstrfuncs.h @@ -189,9 +189,10 @@ gchar* g_strndup (const gchar *str, gchar* g_strnfill (gsize length, gchar fill_char) G_GNUC_MALLOC; gchar* g_strconcat (const gchar *string1, - ...) G_GNUC_MALLOC; /* NULL terminated */ + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; gchar* g_strjoin (const gchar *separator, - ...) G_GNUC_MALLOC; /* NULL terminated */ + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; + /* Make a copy of a string interpreting C string -style escape * sequences. Inverse of g_strescape. The recognized sequences are \b * \f \n \r \t \\ \" and the octal format. diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 47aaf02db..50eb694f9 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,5 +1,8 @@ 2005-03-08 Matthias Clasen + * gobject.h: Use G_GNUC_NULL_TERMINATED where + appropriate. (#164706, Marc Meissner) + * gvaluearray.h: Small cleanup (use G_BEGIN/END_DECLS). (#168474, Fabricio Barros Cabral) diff --git a/gobject/gobject.h b/gobject/gobject.h index 6522a0087..f3935ca9e 100644 --- a/gobject/gobject.h +++ b/gobject/gobject.h @@ -131,7 +131,7 @@ GParamSpec**g_object_interface_list_properties (gpointer g_iface, gpointer g_object_new (GType object_type, const gchar *first_property_name, - ...); + ...) G_GNUC_NULL_TERMINATED; gpointer g_object_newv (GType object_type, guint n_parameters, GParameter *parameters); @@ -140,16 +140,16 @@ GObject* g_object_new_valist (GType object_type, va_list var_args); void g_object_set (gpointer object, const gchar *first_property_name, - ...); + ...) G_GNUC_NULL_TERMINATED; void g_object_get (gpointer object, const gchar *first_property_name, - ...); + ...) G_GNUC_NULL_TERMINATED; gpointer g_object_connect (gpointer object, const gchar *signal_spec, - ...); + ...) G_GNUC_NULL_TERMINATED; void g_object_disconnect (gpointer object, const gchar *signal_spec, - ...); + ...) G_GNUC_NULL_TERMINATED; void g_object_set_valist (GObject *object, const gchar *first_property_name, va_list var_args);