NetworkManager/shared/nm-utils
Thomas Haller c75a1d7e16 shared: add NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP to nm_utils_strsplit_set_full()
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.

(cherry picked from commit 5b2b0dcadf)
2019-04-17 11:27:10 +02:00
..
tests shared: add nm_strstrip_avoid_copy_a() helper 2019-04-04 21:01:15 +02:00
c-list-util.c shared: implement c_list_sort() as non-recursive merge-sort 2018-01-03 16:41:47 +01:00
c-list-util.h shared: add c_list_length_is() helper 2019-03-13 09:03:58 +01:00
nm-c-list.h shared: add nm_c_list_move_*() helpers 2019-02-18 15:00:10 +01:00
nm-compat.c all: avoid g_memdup() 2018-09-07 11:24:17 +02:00
nm-compat.h shared/compat: add compat for nm_setting_vpn_get_data_keys() and nm_setting_vpn_get_secret_keys() 2017-11-23 14:44:25 +01:00
nm-dedup-multi.c all: use nm_c_list_move_*() helpers 2019-02-18 15:00:10 +01:00
nm-dedup-multi.h Fix typos 2018-09-30 21:14:55 +02:00
nm-enum-utils.c all: don't use gchar/gshort/gint/glong but C types 2018-07-11 12:02:06 +02:00
nm-enum-utils.h all: don't use gchar/gshort/gint/glong but C types 2018-07-11 12:02:06 +02:00
nm-errno.c shared: add nm_strerror_native() to replace strerror() and g_strerror() 2019-02-12 08:50:28 +01:00
nm-errno.h shared: fix nm_errno_from_native() for negative input 2019-02-12 09:13:29 +01:00
nm-glib.h shared/nm-glib: add our own g_steal_pointer() macro to shadow the one from glib 2019-02-21 07:22:36 +01:00
nm-hash-utils.c all: fix misspellings 2019-01-24 17:19:44 +01:00
nm-hash-utils.h shared: add nm_hash_obfuscate_ptr() helper 2019-03-13 09:03:58 +01:00
nm-io-utils.c cli/wireguard: add import functionality for WireGuard 2019-03-07 17:54:25 +01:00
nm-io-utils.h shared: move file-get-contents and file-set-contents helper to shared/ 2018-09-04 07:38:30 +02:00
nm-jansson.h shared: add nm_auto_decref_json 2019-02-17 19:39:07 +01:00
nm-logging-fwd.h logging: make nm-logging thread-safe 2019-02-05 08:18:08 +01:00
nm-macros-internal.h shared: add nm_auto_clear_variant_builder 2019-04-12 11:07:25 +02:00
nm-obj.h all: replace "it's" with "its" where needed 2018-04-18 14:14:07 +02:00
nm-random-utils.c Fix typos 2018-09-30 21:14:55 +02:00
nm-random-utils.h shared: split random and hash utils 2017-10-17 20:02:59 +02:00
nm-secret-utils.c shared: better implement compat version of explicit_bzero() 2019-04-02 19:30:33 +02:00
nm-secret-utils.h shared: add nm_utils_memeqzero_secret() 2019-03-07 17:54:25 +01:00
nm-shared-utils.c shared: add NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP to nm_utils_strsplit_set_full() 2019-04-17 11:27:10 +02:00
nm-shared-utils.h shared: add NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP to nm_utils_strsplit_set_full() 2019-04-17 11:27:10 +02:00
nm-test-utils.h Revert "all: goodbye libnm-glib" 2019-04-03 08:52:38 +02:00
nm-time-utils.c shared: thread safe initialization of nm_utils_get_monotonic_timestamp*() 2018-11-28 16:13:04 +01:00
nm-time-utils.h shared: move nm_utils_get_monotonic_timestamp*() to shared/nm-utils. 2018-10-18 12:16:55 +02:00
nm-udev-utils.c udev: remove unneeded NULL checks 2018-12-12 14:18:53 +01:00
nm-udev-utils.h udev: add and use nm_udev_utils_property_decode() function 2017-03-22 12:41:06 +01:00
nm-vpn-editor-plugin-call.h shared: include "gsystem-local-alloc.h" from "nm-glib.h" 2016-06-16 10:45:54 +02:00
nm-vpn-plugin-macros.h shared: add nm_utils_syslog_coerce_from_nm() util 2016-09-19 15:35:33 +02:00
nm-vpn-plugin-utils.c shared/vpn-plugin-utils: load the editor from the same place as plugin 2018-10-24 15:12:43 +02:00
nm-vpn-plugin-utils.h shared: add "nm-utils/nm-vpn-plugin-utils.h" 2016-06-16 10:45:54 +02:00
unaligned.h systemd: update code from upstream (2018-11-23) 2018-11-23 10:53:12 +01:00