Add g_assert_warning.

2004-09-29  Matthias Clasen  <mclasen@redhat.com>

	* 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.
This commit is contained in:
Matthias Clasen 2004-09-30 02:02:00 +00:00 committed by Matthias Clasen
parent 208a69d450
commit 0455122b1a
8 changed files with 81 additions and 14 deletions

View File

@ -1,5 +1,13 @@
2004-09-29 Matthias Clasen <mclasen@redhat.com> 2004-09-29 Matthias Clasen <mclasen@redhat.com>
* 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 * glib/gmessages.h: Move the declaration of
g_return_if_fail_warning() out of the ifdefs, so that g_return_if_fail_warning() out of the ifdefs, so that
building with G_DISABLE_ASSERT works. building with G_DISABLE_ASSERT works.

View File

@ -1,5 +1,13 @@
2004-09-29 Matthias Clasen <mclasen@redhat.com> 2004-09-29 Matthias Clasen <mclasen@redhat.com>
* 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 * glib/gmessages.h: Move the declaration of
g_return_if_fail_warning() out of the ifdefs, so that g_return_if_fail_warning() out of the ifdefs, so that
building with G_DISABLE_ASSERT works. building with G_DISABLE_ASSERT works.

View File

@ -1,5 +1,13 @@
2004-09-29 Matthias Clasen <mclasen@redhat.com> 2004-09-29 Matthias Clasen <mclasen@redhat.com>
* 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 * glib/gmessages.h: Move the declaration of
g_return_if_fail_warning() out of the ifdefs, so that g_return_if_fail_warning() out of the ifdefs, so that
building with G_DISABLE_ASSERT works. building with G_DISABLE_ASSERT works.

View File

@ -1,5 +1,13 @@
2004-09-29 Matthias Clasen <mclasen@redhat.com> 2004-09-29 Matthias Clasen <mclasen@redhat.com>
* 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 * glib/gmessages.h: Move the declaration of
g_return_if_fail_warning() out of the ifdefs, so that g_return_if_fail_warning() out of the ifdefs, so that
building with G_DISABLE_ASSERT works. building with G_DISABLE_ASSERT works.

View File

@ -1,5 +1,13 @@
2004-09-29 Matthias Clasen <mclasen@redhat.com> 2004-09-29 Matthias Clasen <mclasen@redhat.com>
* 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 * glib/gmessages.h: Move the declaration of
g_return_if_fail_warning() out of the ifdefs, so that g_return_if_fail_warning() out of the ifdefs, so that
building with G_DISABLE_ASSERT works. building with G_DISABLE_ASSERT works.

View File

@ -24,6 +24,7 @@ g_ascii_strup
g_ascii_tolower g_ascii_tolower
g_ascii_toupper g_ascii_toupper
g_ascii_xdigit_value g_ascii_xdigit_value
g_assert_warning
g_async_queue_length g_async_queue_length
g_async_queue_length_unlocked g_async_queue_length_unlocked
g_async_queue_lock g_async_queue_lock

View File

@ -526,6 +526,30 @@ g_return_if_fail_warning (const char *log_domain,
expression); 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') || \ #define CHAR_IS_SAFE(wc) (!((wc < 0x20 && wc != '\t' && wc != '\n' && wc != '\r') || \
(wc == 0x7f) || \ (wc == 0x7f) || \
(wc >= 0x80 && wc < 0xa0))) (wc >= 0x80 && wc < 0xa0)))

View File

@ -108,10 +108,15 @@ void _g_log_fallback_handler (const gchar *log_domain,
const gchar *message, const gchar *message,
gpointer unused_data) G_GNUC_INTERNAL; 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, void g_return_if_fail_warning (const char *log_domain,
const char *pretty_function, const char *pretty_function,
const char *expression); 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 #ifndef G_LOG_DOMAIN
@ -224,21 +229,18 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func);
#define g_assert(expr) G_STMT_START{ \ #define g_assert(expr) G_STMT_START{ \
if G_LIKELY(expr) { } else \ if G_LIKELY(expr) { } else \
g_log (G_LOG_DOMAIN, \ g_assert_warning (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d (%s): assertion failed: (%s)", \
__FILE__, \ __FILE__, \
__LINE__, \ __LINE__, \
__PRETTY_FUNCTION__, \ __PRETTY_FUNCTION__, \
#expr); }G_STMT_END #expr); }G_STMT_END
#define g_assert_not_reached() G_STMT_START{ \ #define g_assert_not_reached() G_STMT_START{ \
g_log (G_LOG_DOMAIN, \ g_assert_warning (G_LOG_DOMAIN, \
G_LOG_LEVEL_ERROR, \
"file %s: line %d (%s): should not be reached", \
__FILE__, \ __FILE__, \
__LINE__, \ __LINE__, \
__PRETTY_FUNCTION__); }G_STMT_END __PRETTY_FUNCTION__, \
NULL); }G_STMT_END
#else /* !__GNUC__ */ #else /* !__GNUC__ */