diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2016-05-20 20:44:05 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-06-17 12:22:37 +0200 |
commit | 45d6baac4d371d4ed709babcdd2d43438c438bb7 (patch) | |
tree | 371cbe5c6d1cac6240cf9f954b15b82c5d2ca017 | |
parent | f90abce4d55c37955dcef8b50867bbfec33ad06b (diff) | |
download | NetworkManager-45d6baac4d371d4ed709babcdd2d43438c438bb7.tar.gz |
shared: backport g_strv_contains()
-rw-r--r-- | shared/nm-utils/nm-glib.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-glib.h b/shared/nm-utils/nm-glib.h index 46a8bb2d9a..a014e26066 100644 --- a/shared/nm-utils/nm-glib.h +++ b/shared/nm-utils/nm-glib.h @@ -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__ */ |