mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-08 08:58:03 +02:00
shared: add nm_utils_escaped_tokens_escape_gstr_assert()
(cherry picked from commit 832adf323e)
This commit is contained in:
parent
c0feedbaae
commit
45fad3bb20
1 changed files with 33 additions and 0 deletions
|
|
@ -421,6 +421,39 @@ const char *nm_utils_escaped_tokens_escape (const char *str,
|
||||||
const char *delimiters,
|
const char *delimiters,
|
||||||
char **out_to_free);
|
char **out_to_free);
|
||||||
|
|
||||||
|
static inline GString *
|
||||||
|
nm_utils_escaped_tokens_escape_gstr_assert (const char *str,
|
||||||
|
const char *delimiters,
|
||||||
|
GString *gstring)
|
||||||
|
{
|
||||||
|
#if NM_MORE_ASSERTS > 0
|
||||||
|
|
||||||
|
/* Just appends @str to @gstring, but also assert that
|
||||||
|
* no escaping is necessary.
|
||||||
|
*
|
||||||
|
* Use nm_utils_escaped_tokens_escape_gstr_assert() instead
|
||||||
|
* of nm_utils_escaped_tokens_escape_gstr(), if you *know* that
|
||||||
|
* @str contains no delimiters, no backslashes, and no trailing
|
||||||
|
* whitespace that requires escaping. */
|
||||||
|
|
||||||
|
nm_assert (str);
|
||||||
|
nm_assert (gstring);
|
||||||
|
nm_assert (delimiters);
|
||||||
|
|
||||||
|
{
|
||||||
|
gs_free char *str_to_free = NULL;
|
||||||
|
const char *str0;
|
||||||
|
|
||||||
|
str0 = nm_utils_escaped_tokens_escape (str, delimiters, &str_to_free);
|
||||||
|
nm_assert (str0 == str);
|
||||||
|
nm_assert (!str_to_free);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_string_append (gstring, str);
|
||||||
|
return gstring;
|
||||||
|
}
|
||||||
|
|
||||||
static inline GString *
|
static inline GString *
|
||||||
nm_utils_escaped_tokens_escape_gstr (const char *str,
|
nm_utils_escaped_tokens_escape_gstr (const char *str,
|
||||||
const char *delimiters,
|
const char *delimiters,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue