mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 08:20:08 +01:00
shared: add NM_STR_HAS_SUFFIX_WITH_MORE()/NM_STR_HAS_SUFFIX_ASCII_CASE_WITH_MORE() macros
They are like NM_STR_HAS_SUFFIX()/NM_STR_HAS_SUFFIX_ASCII_CASE(), but require that the checked string is not identical to the suffix. They require some non-empty word preceding the suffix.
This commit is contained in:
parent
07264a5dc1
commit
cc8da77637
2 changed files with 29 additions and 3 deletions
|
|
@ -1250,9 +1250,21 @@ _NM_IN_STRSET_ASCII_CASE_op_streq (const char *x, const char *s)
|
|||
\
|
||||
( _str_has_suffix \
|
||||
&& ((_l = strlen (_str_has_suffix)) >= NM_STRLEN (suffix)) \
|
||||
&& (g_ascii_strncasecmp (&_str_has_suffix[_l - NM_STRLEN (suffix)], \
|
||||
""suffix"", \
|
||||
NM_STRLEN (suffix)) == 0)); \
|
||||
&& (g_ascii_strcasecmp (&_str_has_suffix[_l - NM_STRLEN (suffix)], \
|
||||
""suffix"") == 0)); \
|
||||
})
|
||||
|
||||
#define NM_STR_HAS_SUFFIX_ASCII_CASE_WITH_MORE(str, suffix) \
|
||||
({ \
|
||||
const char *const _str_has_suffix = (str); \
|
||||
size_t _l; \
|
||||
\
|
||||
nm_assert (strlen (suffix) == NM_STRLEN (suffix)); \
|
||||
\
|
||||
( _str_has_suffix \
|
||||
&& ((_l = strlen (_str_has_suffix)) > NM_STRLEN (suffix)) \
|
||||
&& (g_ascii_strcasecmp (&_str_has_suffix[_l - NM_STRLEN (suffix)], \
|
||||
""suffix"") == 0)); \
|
||||
})
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -321,6 +321,20 @@ nm_streq0 (const char *s1, const char *s2)
|
|||
&& _str_has_prefix_with_more[NM_STRLEN (prefix)] != '\0'; \
|
||||
})
|
||||
|
||||
#define NM_STR_HAS_SUFFIX_WITH_MORE(str, suffix) \
|
||||
({ \
|
||||
const char *const _str_has_suffix = (str); \
|
||||
size_t _l; \
|
||||
\
|
||||
nm_assert (strlen (suffix) == NM_STRLEN (suffix)); \
|
||||
\
|
||||
( _str_has_suffix \
|
||||
&& ((_l = strlen (_str_has_suffix)) > NM_STRLEN (suffix)) \
|
||||
&& (memcmp (&_str_has_suffix[_l - NM_STRLEN (suffix)], \
|
||||
""suffix"", \
|
||||
NM_STRLEN (suffix)) == 0)); \
|
||||
})
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NM_IN_SET_EVAL_1( op, _x, y) (_x == (y))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue