Commit 6a51d393 authored by Beniamino Galvani's avatar Beniamino Galvani

shared: add @allow_escaping argument to @nm_utils_strsplit_set

parent 593f6efe
......@@ -1807,7 +1807,7 @@ parse_preferred_connection_order (const char *order, GError **error)
gboolean inverse, unique;
int i;
strv = nm_utils_strsplit_set (order, ":");
strv = nm_utils_strsplit_set (order, ":", FALSE);
if (!strv) {
g_set_error (error, NMCLI_ERROR, 0,
_("incorrect string '%s' of '--order' option"), order);
......@@ -2573,7 +2573,7 @@ parse_passwords (const char *passwd_file, GError **error)
return NULL;
}
strv = nm_utils_strsplit_set (contents, "\r\n");
strv = nm_utils_strsplit_set (contents, "\r\n", FALSE);
for (iter = strv; *iter; iter++) {
gs_free char *iter_s = g_strdup (*iter);
......
......@@ -318,7 +318,7 @@ _set_fcn_precheck_connection_secondaries (const char *value,
char **iter;
gboolean modified = FALSE;
strv0 = nm_utils_strsplit_set (value, " \t,");
strv0 = nm_utils_strsplit_set (value, " \t,", FALSE);
if (!strv0)
return TRUE;
......
......@@ -509,7 +509,7 @@ nmc_string_to_arg_array (const char *line, const char *delim, gboolean unquote,
gs_free const char **arr0 = NULL;
char **arr;
arr0 = nm_utils_strsplit_set (line ?: "", delim ?: " \t");
arr0 = nm_utils_strsplit_set (line ?: "", delim ?: " \t", FALSE);
if (!arr0)
arr = g_new0 (char *, 1);
else
......
......@@ -137,7 +137,7 @@ _parse_ip_route (int family,
nm_assert (!error || !*error);
str_clean = g_strstrip (g_strdup (str));
routev = nm_utils_strsplit_set (str_clean, " \t");
routev = nm_utils_strsplit_set (str_clean, " \t", FALSE);
if (!routev) {
g_set_error (error, 1, 0,
"'%s' is not valid. %s",
......@@ -313,7 +313,7 @@ _parse_team_link_watcher (const char *str,
nm_assert (!error || !*error);
str_clean = g_strstrip (g_strdup (str));
watcherv = nm_utils_strsplit_set (str_clean, " \t");
watcherv = nm_utils_strsplit_set (str_clean, " \t", FALSE);
if (!watcherv) {
g_set_error (error, 1, 0, "'%s' is not valid", str);
return NULL;
......@@ -322,7 +322,7 @@ _parse_team_link_watcher (const char *str,
for (i = 0; watcherv[i]; i++) {
gs_free const char **pair = NULL;
pair = nm_utils_strsplit_set (watcherv[i], "=");
pair = nm_utils_strsplit_set (watcherv[i], "=", FALSE);
if (!pair) {
g_set_error (error, 1, 0, "'%s' is not valid: %s", watcherv[i],
"properties should be specified as 'key=value'");
......@@ -1589,7 +1589,7 @@ vpn_data_item (const char *key, const char *value, gpointer user_data)
gsize i; \
const char *item; \
nm_assert (!error || !*error); \
strv = nm_utils_strsplit_set (value, " \t,"); \
strv = nm_utils_strsplit_set (value, " \t,", FALSE); \
if (strv) { \
for (i = 0; strv[i]; i++) { \
if (!(item = nmc_string_is_valid (strv[i], valid_strv, error))) { \
......@@ -1613,7 +1613,7 @@ vpn_data_item (const char *key, const char *value, gpointer user_data)
\
nm_assert (!error || !*error); \
\
strv = nm_utils_strsplit_set (value, ","); \
strv = nm_utils_strsplit_set (value, ",", FALSE); \
for (iter = strv; iter && *iter; iter++) { \
gs_free char *left_clone = g_strstrip (g_strdup (*iter)); \
char *left = left_clone; \
......@@ -1700,7 +1700,7 @@ vpn_data_item (const char *key, const char *value, gpointer user_data)
\
nm_assert (!error || !*error); \
\
strv = nm_utils_strsplit_set (value, " \t,"); \
strv = nm_utils_strsplit_set (value, " \t,", FALSE); \
for (iter = strv; strv && *iter; iter++) { \
if (!nm_utils_hwaddr_aton (*iter, buf, ETH_ALEN)) { \
g_set_error (error, 1, 0, _("'%s' is not a valid MAC"), *iter); \
......@@ -1918,7 +1918,7 @@ nmc_property_set_bytes (NMSetting *setting, const char *prop, const char *value,
goto done;
/* Otherwise, consider the following format: AA b 0xCc D */
strv = nm_utils_strsplit_set (val_strip, " \t");
strv = nm_utils_strsplit_set (val_strip, " \t", FALSE);
array = g_byte_array_sized_new (NM_PTRARRAY_LEN (strv));
for (iter = strv; iter && *iter; iter++) {
int v;
......@@ -2138,7 +2138,7 @@ _get_fcn_802_1x_phase2_private_key (ARGS_GET_FCN)
\
nm_assert (error == NULL || *error == NULL); \
\
strv = nm_utils_strsplit_set (value, " \t,"); \
strv = nm_utils_strsplit_set (value, " \t,", FALSE); \
if (strv) { \
for (i = 0; strv[i]; i++) \
set_func (NM_SETTING_802_1X (setting), strv[i++]); \
......@@ -2530,7 +2530,7 @@ _set_fcn_connection_permissions (ARGS_SET_FCN)
nm_assert (!error || !*error);
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
if (!verify_string_list (strv, property_info->property_name, permissions_valid, error))
return FALSE;
......@@ -2655,7 +2655,7 @@ _set_fcn_connection_secondaries (ARGS_SET_FCN)
gs_free const char **strv = NULL;
const char *const*iter;
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
if (strv) {
for (iter = strv; *iter; iter++)
nm_setting_connection_add_secondary (NM_SETTING_CONNECTION (setting), *iter);
......@@ -2861,7 +2861,7 @@ _set_fcn_dcb_flags (ARGS_SET_FCN)
const char *const*iter;
/* Check for individual flag numbers */
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
for (iter = strv; iter && *iter; iter++) {
t = _nm_utils_ascii_str_to_int64 (*iter, 0, 0, DCB_ALL_FLAGS, -1);
......@@ -3264,7 +3264,7 @@ _set_fcn_ip4_config_dns (ARGS_SET_FCN)
nm_assert (!error || !*error);
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
for (iter = strv; iter && *iter; iter++) {
gs_free char *addr = g_strstrip (g_strdup (*iter));
......@@ -3309,7 +3309,7 @@ _set_fcn_ip4_config_dns_search (ARGS_SET_FCN)
nm_assert (!error || !*error);
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
if (!verify_string_list (strv, property_info->property_name, nmc_util_is_domain, error))
return FALSE;
......@@ -3349,7 +3349,7 @@ _set_fcn_ip4_config_dns_options (ARGS_SET_FCN)
nm_assert (!error || !*error);
nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE);
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
if (strv) {
for (i = 0; strv[i]; i++)
nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i]);
......@@ -3384,7 +3384,7 @@ _set_fcn_ip4_config_addresses (ARGS_SET_FCN)
const char *const*iter;
NMIPAddress *ip4addr;
strv = nm_utils_strsplit_set (value, ",");
strv = nm_utils_strsplit_set (value, ",", FALSE);
for (iter = strv; *iter; iter++) {
ip4addr = _parse_ip_address (AF_INET, *iter, error);
if (!ip4addr)
......@@ -3444,7 +3444,7 @@ _set_fcn_ip4_config_routes (ARGS_SET_FCN)
const char *const*iter;
NMIPRoute *ip4route;
strv = nm_utils_strsplit_set (value, ",");
strv = nm_utils_strsplit_set (value, ",", FALSE);
for (iter = strv; *iter; iter++) {
ip4route = _parse_ip_route (AF_INET, *iter, error);
if (!ip4route)
......@@ -3508,7 +3508,7 @@ _set_fcn_ip6_config_dns (ARGS_SET_FCN)
nm_assert (!error || !*error);
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
for (iter = strv; iter && *iter; iter++) {
gs_free char *addr = g_strstrip (g_strdup (*iter));
......@@ -3553,7 +3553,7 @@ _set_fcn_ip6_config_dns_search (ARGS_SET_FCN)
nm_assert (!error || !*error);
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
if (!verify_string_list (strv, property_info->property_name, nmc_util_is_domain, error))
return FALSE;
......@@ -3593,7 +3593,7 @@ _set_fcn_ip6_config_dns_options (ARGS_SET_FCN)
nm_assert (!error || !*error);
nm_setting_ip_config_clear_dns_options (NM_SETTING_IP_CONFIG (setting), TRUE);
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
if (strv) {
for (i = 0; strv[i]; i++)
nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (setting), strv[i]);
......@@ -3635,7 +3635,7 @@ _set_fcn_ip6_config_addresses (ARGS_SET_FCN)
const char *const*iter;
NMIPAddress *ip6addr;
strv = nm_utils_strsplit_set (value, ",");
strv = nm_utils_strsplit_set (value, ",", FALSE);
for (iter = strv; strv && *iter; iter++) {
ip6addr = _parse_ip_address (AF_INET6, *iter, error);
if (!ip6addr)
......@@ -3695,7 +3695,7 @@ _set_fcn_ip6_config_routes (ARGS_SET_FCN)
const char *const*iter;
NMIPRoute *ip6route;
strv = nm_utils_strsplit_set (value, ",");
strv = nm_utils_strsplit_set (value, ",", FALSE);
for (iter = strv; strv && *iter; iter++) {
ip6route = _parse_ip_route (AF_INET6, *iter, error);
if (!ip6route)
......@@ -3844,7 +3844,7 @@ _set_fcn_sriov_vfs (ARGS_SET_FCN)
NMSriovVF *vf;
GError *local = NULL;
strv = nm_utils_strsplit_set (value, ",");
strv = nm_utils_strsplit_set (value, ",", FALSE);
for (iter = strv; strv && *iter; iter++) {
vf = nm_utils_sriov_vf_from_str (*iter, &local);
if (!vf) {
......@@ -3866,7 +3866,7 @@ _set_fcn_tc_config_qdiscs (ARGS_SET_FCN)
NMTCQdisc *tc_qdisc;
GError *local = NULL;
strv = nm_utils_strsplit_set (value, ",");
strv = nm_utils_strsplit_set (value, ",", FALSE);
for (iter = strv; strv && *iter; iter++) {
tc_qdisc = nm_utils_tc_qdisc_from_str (*iter, &local);
if (!tc_qdisc) {
......@@ -3971,7 +3971,7 @@ _set_fcn_tc_config_tfilters (ARGS_SET_FCN)
NMTCTfilter *tc_tfilter;
GError *local = NULL;
strv = nm_utils_strsplit_set (value, ",");
strv = nm_utils_strsplit_set (value, ",", FALSE);
for (iter = strv; strv && *iter; iter++) {
tc_tfilter = nm_utils_tc_tfilter_from_str (*iter, &local);
if (!tc_tfilter) {
......@@ -4044,7 +4044,7 @@ _set_fcn_team_runner_tx_hash (ARGS_SET_FCN)
nm_assert (!error || !*error);
strv = nm_utils_strsplit_set (value, " \t,");
strv = nm_utils_strsplit_set (value, " \t,", FALSE);
for (iter = strv; strv && *iter; iter++) {
if (!_is_valid_team_runner_tx_hash_element (*iter, error))
return FALSE;
......@@ -4116,7 +4116,7 @@ _set_fcn_team_link_watchers (ARGS_SET_FCN)
NMTeamLinkWatcher *watcher;
nm_setting_team_clear_link_watchers (NM_SETTING_TEAM (setting));
strv = nm_utils_strsplit_set (value, ",");
strv = nm_utils_strsplit_set (value, ",", FALSE);
for (iter = strv; strv && *iter; iter++) {
watcher = _parse_team_link_watcher (*iter, error);
if (!watcher)
......@@ -4190,7 +4190,7 @@ _set_fcn_team_port_link_watchers (ARGS_SET_FCN)
NMTeamLinkWatcher *watcher;
nm_setting_team_port_clear_link_watchers (NM_SETTING_TEAM_PORT (setting));
strv = nm_utils_strsplit_set (value, ",");
strv = nm_utils_strsplit_set (value, ",", FALSE);
for (iter = strv; strv && *iter; iter++) {
watcher = _parse_team_link_watcher (*iter, error);
if (!watcher)
......@@ -4470,7 +4470,7 @@ _set_fcn_wired_s390_subchannels (ARGS_SET_FCN)
gs_free const char **strv = NULL;
gsize len;
strv = nm_utils_strsplit_set (value, " ,\t");
strv = nm_utils_strsplit_set (value, " ,\t", FALSE);
len = NM_PTRARRAY_LEN (strv);
if (len != 2 && len != 3) {
g_set_error (error, 1, 0, _("'%s' is not valid; 2 or 3 strings should be provided"),
......
......@@ -2613,7 +2613,7 @@ _nm_sriov_vf_parse_vlans (NMSriovVF *vf, const char *str, GError **error)
gs_free const char **vlans = NULL;
guint i;
vlans = nm_utils_strsplit_set (str, ";");
vlans = nm_utils_strsplit_set (str, ";", FALSE);
if (!vlans) {
g_set_error_literal (error,
NM_CONNECTION_ERROR,
......
......@@ -238,7 +238,7 @@ test_nm_g_slice_free_fcn (void)
/*****************************************************************************/
static void
_do_test_nm_utils_strsplit_set (const char *str, ...)
_do_test_nm_utils_strsplit_set (gboolean escape, const char *str, ...)
{
gs_unref_ptrarray GPtrArray *args_array = g_ptr_array_new ();
const char *const*args;
......@@ -255,7 +255,7 @@ _do_test_nm_utils_strsplit_set (const char *str, ...)
args = (const char *const*) args_array->pdata;
words = nm_utils_strsplit_set (str, " \t\n");
words = nm_utils_strsplit_set (str, " \t\n", escape);
if (!args[0]) {
g_assert (!words);
......@@ -268,7 +268,7 @@ _do_test_nm_utils_strsplit_set (const char *str, ...)
g_assert (args[i]);
g_assert (words[i]);
g_assert (args[i][0]);
g_assert (NM_STRCHAR_ALL (args[i], ch, !NM_IN_SET (ch, ' ', '\t', '\n')));
g_assert (escape || NM_STRCHAR_ALL (args[i], ch, !NM_IN_SET (ch, ' ', '\t', '\n')));
g_assert_cmpstr (args[i], ==, words[i]);
}
}
......@@ -279,21 +279,29 @@ _do_test_nm_utils_strsplit_set (const char *str, ...)
static void
test_nm_utils_strsplit_set (void)
{
do_test_nm_utils_strsplit_set (NULL);
do_test_nm_utils_strsplit_set ("");
do_test_nm_utils_strsplit_set ("\t");
do_test_nm_utils_strsplit_set (" \t\n");
do_test_nm_utils_strsplit_set ("a", "a");
do_test_nm_utils_strsplit_set ("a b", "a", "b");
do_test_nm_utils_strsplit_set ("a\rb", "a\rb");
do_test_nm_utils_strsplit_set (" a\rb ", "a\rb");
do_test_nm_utils_strsplit_set (" a bbbd afds ere", "a", "bbbd", "afds", "ere");
do_test_nm_utils_strsplit_set ("1 2 3 4 5 6 7 8 9 0 "
do_test_nm_utils_strsplit_set (FALSE, NULL);
do_test_nm_utils_strsplit_set (FALSE, "");
do_test_nm_utils_strsplit_set (FALSE, "\t");
do_test_nm_utils_strsplit_set (FALSE, " \t\n");
do_test_nm_utils_strsplit_set (FALSE, "a", "a");
do_test_nm_utils_strsplit_set (FALSE, "a b", "a", "b");
do_test_nm_utils_strsplit_set (FALSE, "a\rb", "a\rb");
do_test_nm_utils_strsplit_set (FALSE, " a\rb ", "a\rb");
do_test_nm_utils_strsplit_set (FALSE, " a bbbd afds ere", "a", "bbbd", "afds", "ere");
do_test_nm_utils_strsplit_set (FALSE,
"1 2 3 4 5 6 7 8 9 0 "
"1 2 3 4 5 6 7 8 9 0 "
"1 2 3 4 5 6 7 8 9 0",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
do_test_nm_utils_strsplit_set (TRUE, "\\", "\\");
do_test_nm_utils_strsplit_set (TRUE, "\\ ", "\\ ");
do_test_nm_utils_strsplit_set (TRUE, "\\\\", "\\\\");
do_test_nm_utils_strsplit_set (TRUE, "\\\t", "\\\t");
do_test_nm_utils_strsplit_set (TRUE, "foo\\", "foo\\");
do_test_nm_utils_strsplit_set (TRUE, "bar foo\\", "bar", "foo\\");
do_test_nm_utils_strsplit_set (TRUE, "\\ a b\\ \\ c", "\\ a", "b\\ \\ ", "c");
}
/*****************************************************************************/
......
......@@ -656,6 +656,7 @@ comp_l:
* @str: the string to split.
* @delimiters: the set of delimiters. If %NULL, defaults to " \t\n",
* like bash's $IFS.
* @allow_escaping: whether delimiters can be escaped by a backslash
*
* This is a replacement for g_strsplit_set() which avoids copying
* each word once (the entire strv array), but instead copies it once
......@@ -664,6 +665,10 @@ comp_l:
* Another difference from g_strsplit_set() is that this never returns
* empty words. Multiple delimiters are combined and treated as one.
*
* If @allow_escaping is %TRUE, delimiters prefixed by a backslash are
* not treated as a separator. Such delimiters and their escape
* character are copied to the current word without unescaping them.
*
* Returns: %NULL if @str is %NULL or contains only delimiters.
* Otherwise, a %NULL terminated strv array containing non-empty
* words, split at the delimiter characters (delimiter characters
......@@ -673,7 +678,7 @@ comp_l:
* but free everything with g_free().
*/
const char **
nm_utils_strsplit_set (const char *str, const char *delimiters)
nm_utils_strsplit_set (const char *str, const char *delimiters, gboolean allow_escaping)
{
const char **ptr, **ptr0;
gsize alloc_size, plen, i;
......@@ -681,6 +686,7 @@ nm_utils_strsplit_set (const char *str, const char *delimiters)
char *s0;
char *s;
guint8 delimiters_table[256];
gboolean escaped = FALSE;
if (!str)
return NULL;
......@@ -692,13 +698,23 @@ nm_utils_strsplit_set (const char *str, const char *delimiters)
for (i = 0; delimiters[i]; i++)
delimiters_table[(guint8) delimiters[i]] = 1;
#define _is_delimiter(ch, delimiters_table) \
((delimiters_table)[(guint8) (ch)] != 0)
#define _is_delimiter(ch, delimiters_table, allow_esc, esc) \
((delimiters_table)[(guint8) (ch)] != 0 && (!allow_esc || !esc))
#define next_char(p, esc) \
G_STMT_START { \
if (esc) \
esc = FALSE; \
else \
esc = p[0] == '\\'; \
p++; \
} G_STMT_END
/* skip initial delimiters, and return of the remaining string is
* empty. */
while (_is_delimiter (str[0], delimiters_table))
str++;
while (_is_delimiter (str[0], delimiters_table, allow_escaping, escaped))
next_char (str, escaped);
if (!str[0])
return NULL;
......@@ -730,20 +746,20 @@ nm_utils_strsplit_set (const char *str, const char *delimiters)
ptr[plen++] = s;
nm_assert (s[0] && !_is_delimiter (s[0], delimiters_table));
nm_assert (s[0] && !_is_delimiter (s[0], delimiters_table, allow_escaping, escaped));
while (TRUE) {
s++;
if (_is_delimiter (s[0], delimiters_table))
next_char (s, escaped);
if (_is_delimiter (s[0], delimiters_table, allow_escaping, escaped))
break;
if (s[0] == '\0')
goto done;
}
s[0] = '\0';
s++;
while (_is_delimiter (s[0], delimiters_table))
s++;
next_char (s, escaped);
while (_is_delimiter (s[0], delimiters_table, allow_escaping, escaped))
next_char (s, escaped);
if (s[0] == '\0')
break;
}
......@@ -1602,7 +1618,7 @@ nm_utils_get_start_time_for_pid (pid_t pid, char *out_state, pid_t *out_ppid)
state = p[0];
tokens = nm_utils_strsplit_set (p, " ");
tokens = nm_utils_strsplit_set (p, " ", FALSE);
if (NM_PTRARRAY_LEN (tokens) < 20)
goto fail;
......
......@@ -208,7 +208,7 @@ int nm_utils_dbus_path_cmp (const char *dbus_path_a, const char *dbus_path_b);
/*****************************************************************************/
const char **nm_utils_strsplit_set (const char *str, const char *delimiters);
const char **nm_utils_strsplit_set (const char *str, const char *delimiters, gboolean allow_escaping);
gssize nm_utils_strv_find_first (char **list, gssize len, const char *needle);
......
......@@ -254,7 +254,7 @@ make_connection_setting (const char *file,
if (v) {
gs_free const char **items = NULL;
items = nm_utils_strsplit_set (v, " ");
items = nm_utils_strsplit_set (v, " ", FALSE);
for (iter = items; iter && *iter; iter++) {
if (!nm_setting_connection_add_permission (s_con, "user", *iter, NULL))
PARSE_WARNING ("invalid USERS item '%s'", *iter);
......@@ -270,7 +270,7 @@ make_connection_setting (const char *file,
if (v) {
gs_free const char **items = NULL;
items = nm_utils_strsplit_set (v, " \t");
items = nm_utils_strsplit_set (v, " \t", FALSE);
for (iter = items; iter && *iter; iter++) {
if (!nm_setting_connection_add_secondary (s_con, *iter))
PARSE_WARNING ("secondary connection UUID '%s' already added", *iter);
......@@ -679,7 +679,7 @@ parse_route_line (const char *line,
* Maybe later we want to support some form of quotation here.
* Which of course, would be incompatible with initscripts.
*/
words_free = nm_utils_strsplit_set (line, " \t\n");
words_free = nm_utils_strsplit_set (line, " \t\n", FALSE);
words = words_free ?: NM_PTRARRAY_EMPTY (const char *);
......@@ -1115,7 +1115,7 @@ parse_dns_options (NMSettingIPConfig *ip_config, const char *value)
if (!nm_setting_ip_config_has_dns_options (ip_config))
nm_setting_ip_config_clear_dns_options (ip_config, TRUE);
options = nm_utils_strsplit_set (value, " ");
options = nm_utils_strsplit_set (value, " ", FALSE);
if (options) {
for (item = options; *item; item++) {
if (!nm_setting_ip_config_add_dns_option (ip_config, *item))
......@@ -1485,7 +1485,7 @@ make_ip4_setting (shvarFile *ifcfg,
if (v) {
gs_free const char **searches = NULL;
searches = nm_utils_strsplit_set (v, " ");
searches = nm_utils_strsplit_set (v, " ", FALSE);
if (searches) {
for (item = searches; *item; item++) {
if (!nm_setting_ip_config_add_dns_search (s_ip4, *item))
......@@ -1546,7 +1546,7 @@ make_ip4_setting (shvarFile *ifcfg,
if (v) {
gs_free const char **searches = NULL;
searches = nm_utils_strsplit_set (v, " ");
searches = nm_utils_strsplit_set (v, " ", FALSE);
if (searches) {
for (item = searches; *item; item++) {
if (!nm_setting_ip_config_add_dns_search (s_ip4, *item))
......@@ -1862,7 +1862,7 @@ make_ip6_setting (shvarFile *ifcfg,
ipv6addr_secondaries ?: "",
NULL);
list = nm_utils_strsplit_set (value, " ");
list = nm_utils_strsplit_set (value, " ", FALSE);
for (iter = list, i = 0; iter && *iter; iter++, i++) {
NMIPAddress *addr = NULL;
......@@ -1955,7 +1955,7 @@ make_ip6_setting (shvarFile *ifcfg,
if (v) {
gs_free const char **searches = NULL;
searches = nm_utils_strsplit_set (v, " ");
searches = nm_utils_strsplit_set (v, " ", FALSE);
if (searches) {
for (iter = searches; *iter; iter++) {
if (!nm_setting_ip_config_add_dns_search (s_ip6, *iter))
......@@ -2305,7 +2305,7 @@ read_dcb_percent_array (shvarFile *ifcfg,
return TRUE;
}
split = nm_utils_strsplit_set (val, ",");
split = nm_utils_strsplit_set (val, ",", FALSE);
if (NM_PTRARRAY_LEN (split) != 8) {
PARSE_WARNING ("invalid %s percentage list value '%s'", prop, val);
g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
......@@ -2741,7 +2741,7 @@ fill_wpa_ciphers (shvarFile *ifcfg,
if (!p)
return TRUE;
list = nm_utils_strsplit_set (p, " ");
list = nm_utils_strsplit_set (p, " ", FALSE);
for (iter = list; iter && *iter; iter++, i++) {
/* Ad-Hoc configurations cannot have pairwise ciphers, and can only
* have one group cipher. Ignore any additional group ciphers and
......@@ -3147,7 +3147,7 @@ eap_peap_reader (const char *eap_method,
}
/* Handle options for the inner auth method */
list = nm_utils_strsplit_set (v, " ");
list = nm_utils_strsplit_set (v, " ", FALSE);
iter = list;
if (iter) {
if (NM_IN_STRSET (*iter, "MSCHAPV2",
......@@ -3225,7 +3225,7 @@ eap_ttls_reader (const char *eap_method,
inner_auth = g_ascii_strdown (v, -1);
/* Handle options for the inner auth method */
list = nm_utils_strsplit_set (inner_auth, " ");
list = nm_utils_strsplit_set (inner_auth, " ", FALSE);
iter = list;
if (iter) {
if (NM_IN_STRSET (*iter, "mschapv2",
......@@ -3286,7 +3286,7 @@ eap_fast_reader (const char *eap_method,
if (fast_provisioning) {
gs_free const char **list1 = NULL;
list1 = nm_utils_strsplit_set (fast_provisioning, " \t");
list1 = nm_utils_strsplit_set (fast_provisioning, " \t", FALSE);
for (iter = list1; iter && *iter; iter++) {
if (strcmp (*iter, "allow-unauth") == 0)
allow_unauth = TRUE;
......@@ -3320,7 +3320,7 @@ eap_fast_reader (const char *eap_method,
}
/* Handle options for the inner auth method */
list = nm_utils_strsplit_set (inner_auth, " ");
list = nm_utils_strsplit_set (inner_auth, " ", FALSE);
iter = list;
if (iter) {
if ( !strcmp (*iter, "MSCHAPV2")
......@@ -3400,7 +3400,7 @@ read_8021x_list_value (shvarFile *ifcfg,
if (!v)
return;
strv = nm_utils_strsplit_set (v, " \t");
strv = nm_utils_strsplit_set (v, " \t", FALSE);
if (strv)
g_object_set (setting, prop_name, strv, NULL);
}
......@@ -3429,7 +3429,7 @@ fill_8021x (shvarFile *ifcfg,
return NULL;
}
list = nm_utils_strsplit_set (v, " ");
list = nm_utils_strsplit_set (v, " ", FALSE);
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
......@@ -3738,7 +3738,7 @@ transform_hwaddr_blacklist (const char *blacklist)
const char **strv;
gsize i, j;
strv = nm_utils_strsplit_set (blacklist, " \t");
strv = nm_utils_strsplit_set (blacklist, " \t", FALSE);
if (!strv)
return NULL;
for (i = 0, j = 0; strv[j]; j++) {
......@@ -4059,7 +4059,7 @@ parse_ethtool_option (const char *value,
gs_free const char **words = NULL;
guint i;
words = nm_utils_strsplit_set (value, NULL);
words = nm_utils_strsplit_set (value, NULL, FALSE);
if (!words)
return;
......@@ -4252,7 +4252,7 @@ parse_ethtool_options (shvarFile *ifcfg, NMConnection *connection)
gs_free const char **opts = NULL;
const char *const *iter;
opts = nm_utils_strsplit_set (ethtool_opts, ";");
opts = nm_utils_strsplit_set (ethtool_opts, ";", FALSE);
for (iter = opts; iter && iter[0]; iter++) {
/* in case of repeated wol_passwords, parse_ethtool_option()
* will do the right thing and clear wol_password before resetting. */
......@@ -4348,7 +4348,7 @@ make_wired_setting (shvarFile *ifcfg,
gs_free const char **chans = NULL;
guint32 num_chans;
chans = nm_utils_strsplit_set (value, ",");
chans = nm_utils_strsplit_set (value, ",", FALSE);
num_chans = NM_PTRARRAY_LEN (chans);
if (num_chans < 2 || num_chans > 3) {
PARSE_WARNING ("invalid SUBCHANNELS '%s' (%u channels, 2 or 3 expected)",
......@@ -4671,7 +4671,7 @@ make_bond_setting (shvarFile *ifcfg,
gs_free const char **items = NULL;
const char *const *iter;
items = nm_utils_strsplit_set (v, " ");
items = nm_utils_strsplit_set (v, " ", FALSE);
for (iter = items; iter && *iter; iter++) {
gs_strfreev char **keys = NULL;
const char *key, *val;
......@@ -4949,7 +4949,7 @@ handle_bridging_opts (NMSetting *setting,
gs_free const char **items = NULL;
const char *const *iter;
items = nm_utils_strsplit_set (value, " ");
items = nm_utils_strsplit_set (value, " ", FALSE);
for (iter = items; iter && *iter; iter++) {
gs_strfreev char **keys = NULL;
const char *key, *val;
......@@ -5169,7 +5169,7 @@ parse_prio_map_list (NMSettingVlan *s_vlan,
v = svGetValueStr (ifcfg, key, &value);
if (!v)
return;
list = nm_utils_strsplit_set (v, ",");
list = nm_utils_strsplit_set (v, ",", FALSE);
for (iter = list; iter && *iter; iter++) {
if (!strchr (*iter, ':'))
......@@ -5274,7 +5274,7 @@ make_vlan_setting (shvarFile *ifcfg,
gs_free const char **strv = NULL;
const char *const *ptr;
strv = nm_utils_strsplit_set (v, ", ");
strv = nm_utils_strsplit_set (v, ", ", FALSE);
for (ptr = strv; ptr && *ptr; ptr++) {
if (nm_streq (*ptr, "GVRP") && gvrp == -1)
vlan_flags |= NM_VLAN_FLAG_GVRP;
......@@ -5416,7 +5416,7 @@ check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6)
gs_free const char **searches = NULL;
const char *const *item;
searches = nm_utils_strsplit_set (v, " ");
searches = nm_utils_strsplit_set (v, " ", FALSE);
if (searches) {
for (item = searches; *item; item++) {
if (!nm_setting_ip_config_add_dns_search (NM_SETTING_IP_CONFIG (s_ip6), *item))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment