mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-25 01:20:07 +01:00
This will essentially call g_strstrip() on each token. There are some specialties: - if the resulting word is empty after stripping, then according to %NM_UTILS_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY, the empty token will be removed. If that results in an empty string array, %NULL will be returned. - if %NM_UTILS_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING is set, then whitespace that is backslash escaped is not removed. Since this is a post-operation that happens after tokeninzing, it could be done as a separate function. And we already have this function: _nm_utils_unescape_plain() and _nm_utils_unescape_spaces(). However, that is ugly for several reasons: - the stripping should be part of the tokenizing, you shouldn't need several steps. - nm_utils_strsplit_set_full() returns a "const char **" which indicates the strings must not be freed. However, it is perfectly valid to modify the string inplace. Hence, the post-op function would need to cast the strings to "char *", which seems ugly (although we do that on many places, and it's guaranteed to work). - _nm_utils_unescape_plain()/_nm_utils_unescape_spaces() is indeed already used together with nm_utils_strsplit_set_full(). However, it requires to initialize the cb_lookup buffer twice. I would expect that initializing the cb_lookup buffer is a large portion of what the function does already (for short strings). This issue will be solved in the next commit by adding yet another flag which allows to unescape. |
||
|---|---|---|
| .. | ||
| c-list | ||
| c-rbtree | ||
| c-siphash | ||
| c-stdaux | ||
| n-acd | ||
| nm-utils | ||
| systemd | ||
| meson.build | ||
| nm-common-macros.h | ||
| nm-dbus-compat.h | ||
| nm-default.h | ||
| nm-dispatcher-api.h | ||
| nm-ethtool-utils.c | ||
| nm-ethtool-utils.h | ||
| nm-libnm-core-utils.c | ||
| nm-libnm-core-utils.h | ||
| nm-meta-setting.c | ||
| nm-meta-setting.h | ||
| nm-test-libnm-utils.h | ||
| nm-test-utils-impl.c | ||
| nm-version-macros.h.in | ||