Add g_assert_warning.
authorMatthias Clasen <mclasen@redhat.com>
Thu, 30 Sep 2004 02:02:00 +0000 (02:02 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 30 Sep 2004 02:02:00 +0000 (02:02 +0000)
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.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/glib.symbols
glib/gmessages.c
glib/gmessages.h

index d20b201..daad4fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 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 
        g_return_if_fail_warning() out of the ifdefs, so that
        building with G_DISABLE_ASSERT works.
index d20b201..daad4fb 100644 (file)
@@ -1,5 +1,13 @@
 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 
        g_return_if_fail_warning() out of the ifdefs, so that
        building with G_DISABLE_ASSERT works.
index d20b201..daad4fb 100644 (file)
@@ -1,5 +1,13 @@
 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 
        g_return_if_fail_warning() out of the ifdefs, so that
        building with G_DISABLE_ASSERT works.
index d20b201..daad4fb 100644 (file)
@@ -1,5 +1,13 @@
 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 
        g_return_if_fail_warning() out of the ifdefs, so that
        building with G_DISABLE_ASSERT works.
index d20b201..daad4fb 100644 (file)
@@ -1,5 +1,13 @@
 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 
        g_return_if_fail_warning() out of the ifdefs, so that
        building with G_DISABLE_ASSERT works.
index dc10b54..e3ddcb4 100644 (file)
@@ -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
index 938712b..7457899 100644 (file)
@@ -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)))
index c38fd0e..381e785 100644 (file)
@@ -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__ */