mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
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:
parent
208a69d450
commit
0455122b1a
@ -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.
|
||||||
|
@ -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.
|
||||||
|
@ -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.
|
||||||
|
@ -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.
|
||||||
|
@ -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.
|
||||||
|
@ -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
|
||||||
|
@ -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)))
|
||||||
|
@ -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__, \
|
||||||
"file %s: line %d (%s): assertion failed: (%s)", \
|
__LINE__, \
|
||||||
__FILE__, \
|
__PRETTY_FUNCTION__, \
|
||||||
__LINE__, \
|
#expr); }G_STMT_END
|
||||||
__PRETTY_FUNCTION__, \
|
|
||||||
#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__, \
|
||||||
"file %s: line %d (%s): should not be reached", \
|
__LINE__, \
|
||||||
__FILE__, \
|
__PRETTY_FUNCTION__, \
|
||||||
__LINE__, \
|
NULL); }G_STMT_END
|
||||||
__PRETTY_FUNCTION__); }G_STMT_END
|
|
||||||
|
|
||||||
#else /* !__GNUC__ */
|
#else /* !__GNUC__ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user