mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 08:10:17 +01:00
all: add and utilize nm_utils_is_separator()
It is meant to be rather similar in nature to isblank() or g_ascii_isspace(). Sadly, isblank() is locale dependent while g_ascii_isspace() also considers vertical whitespace as a space. That's no good for configuration files that are strucutured into lines, which happens to be a pretty common case.
This commit is contained in:
parent
1829126f3a
commit
f0c1efbf42
4 changed files with 10 additions and 4 deletions
|
|
@ -5884,7 +5884,7 @@ _split_cmd (const char *cmd, char **out_arg0, const char **out_argr)
|
|||
|
||||
if (!cmd)
|
||||
return;
|
||||
while (NM_IN_SET (cmd[0], ' ', '\t'))
|
||||
while (nm_utils_is_separator (cmd[0]))
|
||||
cmd++;
|
||||
if (!cmd[0])
|
||||
return;
|
||||
|
|
@ -5893,7 +5893,7 @@ _split_cmd (const char *cmd, char **out_arg0, const char **out_argr)
|
|||
arg0 = g_strndup (cmd, l);
|
||||
cmd += l;
|
||||
if (cmd[0]) {
|
||||
while (NM_IN_SET (cmd[0], ' ', '\t'))
|
||||
while (nm_utils_is_separator (cmd[0]))
|
||||
cmd++;
|
||||
if (cmd[0])
|
||||
argr = cmd;
|
||||
|
|
|
|||
|
|
@ -2157,7 +2157,7 @@ _get_fcn_802_1x_phase2_private_key (ARGS_GET_FCN)
|
|||
password = path + strcspn (path, " \t"); \
|
||||
if (password[0] != '\0') { \
|
||||
password[0] = '\0'; \
|
||||
while (NM_IN_SET (password[0], ' ', '\t')) \
|
||||
while (nm_utils_is_separator (password[0])) \
|
||||
password++; \
|
||||
} else \
|
||||
password = password_free = g_strdup (pwd_func (NM_SETTING_802_1X (setting))); \
|
||||
|
|
|
|||
|
|
@ -191,6 +191,12 @@ void nm_utils_strbuf_append_str (char **buf, gsize *len, const char *str);
|
|||
|
||||
const char *nm_strquote (char *buf, gsize buf_len, const char *str);
|
||||
|
||||
static inline gboolean
|
||||
nm_utils_is_separator (const char c)
|
||||
{
|
||||
return NM_IN_SET (c, ' ', '\t');
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
const char **nm_utils_strsplit_set (const char *str, const char *delimiters);
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ parse_route_line_is_comment (const char *line)
|
|||
*
|
||||
* initscripts compares: "$line" =~ '^[[:space:]]*(\#.*)?$'
|
||||
*/
|
||||
while (NM_IN_SET (line[0], ' ', '\t'))
|
||||
while (nm_utils_is_separator (line[0]))
|
||||
line++;
|
||||
if (NM_IN_SET (line[0], '\0', '#'))
|
||||
return TRUE;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue