shared: backport g_strv_contains()

This commit is contained in:
Lubomir Rintel
2016-05-20 20:44:05 +02:00
committed by Thomas Haller
parent f90abce4d5
commit 45d6baac4d

View File

@@ -394,4 +394,34 @@ g_steal_pointer (gpointer pp)
(0 ? (*(pp)) : (g_steal_pointer) (pp))
#endif
#if !GLIB_CHECK_VERSION(2, 44, 0) || defined (NM_GLIB_COMPAT_H_TEST)
static inline gboolean
_nm_g_strv_contains (const gchar * const *strv,
const gchar *str)
{
g_return_val_if_fail (strv != NULL, FALSE);
g_return_val_if_fail (str != NULL, FALSE);
for (; *strv != NULL; strv++) {
if (g_str_equal (str, *strv))
return TRUE;
}
return FALSE;
}
#endif
#if !GLIB_CHECK_VERSION(2, 44, 0)
#define g_strv_contains(strv, str) \
G_GNUC_EXTENSION ({ \
_nm_g_strv_contains (strv, str); \
})
#else
#define g_strv_contains(strv, str) \
G_GNUC_EXTENSION ({ \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
(g_strv_contains) ((strv), (str)); \
G_GNUC_END_IGNORE_DEPRECATIONS \
})
#endif
#endif /* __NM_GLIB_H__ */