diff --git a/glib/gtestutils.c b/glib/gtestutils.c index de70e921a..7730c77c9 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -19,8 +19,27 @@ */ #include "config.h" +#include "gversionmacros.h" + +/** + * g_strcmp0: + * @str1: (nullable): a C string or %NULL + * @str2: (nullable): another C string or %NULL + * + * Compares @str1 and @str2 like strcmp(). Handles %NULL + * gracefully by sorting it before non-%NULL strings. + * Comparing two %NULL pointers returns 0. + * + * Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2. + * + * Since: 2.16 + */ + +GLIB_AVAILABLE_IN_ALL +int g_strcmp0 (const char *str1, const char *str2); #include "gtestutils.h" + #include "gfileutils.h" #include @@ -3397,30 +3416,6 @@ g_assertion_message_error (const char *domain, g_string_free (gstring, TRUE); } -/** - * g_strcmp0: - * @str1: (nullable): a C string or %NULL - * @str2: (nullable): another C string or %NULL - * - * Compares @str1 and @str2 like strcmp(). Handles %NULL - * gracefully by sorting it before non-%NULL strings. - * Comparing two %NULL pointers returns 0. - * - * Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2. - * - * Since: 2.16 - */ -int -g_strcmp0 (const char *str1, - const char *str2) -{ - if (!str1) - return -(str1 != str2); - if (!str2) - return str1 != str2; - return strcmp (str1, str2); -} - static void test_trap_clear (void) { diff --git a/glib/gtestutils.h b/glib/gtestutils.h index 4e38eb414..969c69dda 100644 --- a/glib/gtestutils.h +++ b/glib/gtestutils.h @@ -238,9 +238,20 @@ typedef void (*GTestFixtureFunc) (gpointer fixture, } G_STMT_END #endif /* !G_DISABLE_ASSERT */ -GLIB_AVAILABLE_IN_ALL -int g_strcmp0 (const char *str1, - const char *str2); +#ifndef GLIB_INLINE +#define GLIB_INLINE +#endif + +GLIB_INLINE int +g_strcmp0 (const char *str1, + const char *str2) +{ + if (!str1) + return -(str1 != str2); + if (!str2) + return str1 != str2; + return strcmp (str1, str2); +} /* report performance results */ GLIB_AVAILABLE_IN_ALL