diff --git a/ChangeLog b/ChangeLog index d20b2011a..daad4fbab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2004-09-29 Matthias Clasen + * glib/glib.symbols: Add g_assert_warning. + + * glib/gmessages.h: + * glib/gmessages.c (g_assert_warning): Treat g_assert + in the same way as g_return_if_fail and move the string + constants into a helper function, which also takes + care of removing the "IA__" prefix from internal aliases. + * glib/gmessages.h: Move the declaration of g_return_if_fail_warning() out of the ifdefs, so that building with G_DISABLE_ASSERT works. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d20b2011a..daad4fbab 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,13 @@ 2004-09-29 Matthias Clasen + * glib/glib.symbols: Add g_assert_warning. + + * glib/gmessages.h: + * glib/gmessages.c (g_assert_warning): Treat g_assert + in the same way as g_return_if_fail and move the string + constants into a helper function, which also takes + care of removing the "IA__" prefix from internal aliases. + * glib/gmessages.h: Move the declaration of g_return_if_fail_warning() out of the ifdefs, so that building with G_DISABLE_ASSERT works. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index d20b2011a..daad4fbab 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,5 +1,13 @@ 2004-09-29 Matthias Clasen + * glib/glib.symbols: Add g_assert_warning. + + * glib/gmessages.h: + * glib/gmessages.c (g_assert_warning): Treat g_assert + in the same way as g_return_if_fail and move the string + constants into a helper function, which also takes + care of removing the "IA__" prefix from internal aliases. + * glib/gmessages.h: Move the declaration of g_return_if_fail_warning() out of the ifdefs, so that building with G_DISABLE_ASSERT works. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d20b2011a..daad4fbab 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,5 +1,13 @@ 2004-09-29 Matthias Clasen + * glib/glib.symbols: Add g_assert_warning. + + * glib/gmessages.h: + * glib/gmessages.c (g_assert_warning): Treat g_assert + in the same way as g_return_if_fail and move the string + constants into a helper function, which also takes + care of removing the "IA__" prefix from internal aliases. + * glib/gmessages.h: Move the declaration of g_return_if_fail_warning() out of the ifdefs, so that building with G_DISABLE_ASSERT works. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d20b2011a..daad4fbab 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,13 @@ 2004-09-29 Matthias Clasen + * glib/glib.symbols: Add g_assert_warning. + + * glib/gmessages.h: + * glib/gmessages.c (g_assert_warning): Treat g_assert + in the same way as g_return_if_fail and move the string + constants into a helper function, which also takes + care of removing the "IA__" prefix from internal aliases. + * glib/gmessages.h: Move the declaration of g_return_if_fail_warning() out of the ifdefs, so that building with G_DISABLE_ASSERT works. diff --git a/glib/glib.symbols b/glib/glib.symbols index dc10b5476..e3ddcb442 100644 --- a/glib/glib.symbols +++ b/glib/glib.symbols @@ -24,6 +24,7 @@ g_ascii_strup g_ascii_tolower g_ascii_toupper g_ascii_xdigit_value +g_assert_warning g_async_queue_length g_async_queue_length_unlocked g_async_queue_lock diff --git a/glib/gmessages.c b/glib/gmessages.c index 938712b10..7457899c6 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -526,6 +526,30 @@ g_return_if_fail_warning (const char *log_domain, expression); } +void +g_assert_warning (const char *log_domain, + const char *file, + const int line, + const char *pretty_function, + const char *expression) +{ + /* + * Omit the prefix used by the PLT-reduction + * technique used in GTK+. + */ + if (g_str_has_prefix (pretty_function, "IA__")) + pretty_function += 4; + g_log (log_domain, + G_LOG_LEVEL_ERROR, + expression + ? "file %s: line %d (%s): assertion failed: (%s)" + : "file %s: line %d (%s): should not be reached", + file, + line, + pretty_function, + expression); +} + #define CHAR_IS_SAFE(wc) (!((wc < 0x20 && wc != '\t' && wc != '\n' && wc != '\r') || \ (wc == 0x7f) || \ (wc >= 0x80 && wc < 0xa0))) diff --git a/glib/gmessages.h b/glib/gmessages.h index c38fd0ee8..381e7853b 100644 --- a/glib/gmessages.h +++ b/glib/gmessages.h @@ -108,10 +108,15 @@ void _g_log_fallback_handler (const gchar *log_domain, const gchar *message, gpointer unused_data) G_GNUC_INTERNAL; -/* Internal function, used to implement the following macros */ +/* Internal functions, used to implement the following macros */ void g_return_if_fail_warning (const char *log_domain, const char *pretty_function, const char *expression); +void g_assert_warning (const char *log_domain, + const char *file, + const int line, + const char *pretty_function, + const char *expression); #ifndef G_LOG_DOMAIN @@ -224,21 +229,18 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func); #define g_assert(expr) G_STMT_START{ \ if G_LIKELY(expr) { } else \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_ERROR, \ - "file %s: line %d (%s): assertion failed: (%s)", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - #expr); }G_STMT_END + g_assert_warning (G_LOG_DOMAIN, \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + #expr); }G_STMT_END #define g_assert_not_reached() G_STMT_START{ \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_ERROR, \ - "file %s: line %d (%s): should not be reached", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__); }G_STMT_END + g_assert_warning (G_LOG_DOMAIN, \ + __FILE__, \ + __LINE__, \ + __PRETTY_FUNCTION__, \ + NULL); }G_STMT_END #else /* !__GNUC__ */