diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/strv.c | 25 | ||||
-rw-r--r-- | src/shared/strv.h | 1 | ||||
-rw-r--r-- | src/shared/util.c | 18 | ||||
-rw-r--r-- | src/shared/util.h | 2 |
4 files changed, 26 insertions, 20 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c index bb309d9f92..f61680d476 100644 --- a/src/shared/strv.c +++ b/src/shared/strv.c @@ -386,6 +386,31 @@ char **strv_remove(char **l, const char *s) { return l; } +char **strv_remove_prefix(char **l, const char *s) { + char **f, **t; + + if (!l) + return NULL; + + assert(s); + + /* Drops every occurrence of a string prefixed with s in the + * string list, edits in-place. */ + + for (f = t = l; *f; f++) { + + if (startswith(*f, s)) { + free(*f); + continue; + } + + *(t++) = *f; + } + + *t = NULL; + return l; +} + static int env_append(char **r, char ***k, char **a) { assert(r); assert(k); diff --git a/src/shared/strv.h b/src/shared/strv.h index d038c9f3b1..9becf9b575 100644 --- a/src/shared/strv.h +++ b/src/shared/strv.h @@ -39,6 +39,7 @@ char **strv_merge_concat(char **a, char **b, const char *suffix); char **strv_append(char **l, const char *s); char **strv_remove(char **l, const char *s); +char **strv_remove_prefix(char **l, const char *s); char **strv_uniq(char **l); #define strv_contains(l, s) (!!strv_find((l), (s))) diff --git a/src/shared/util.c b/src/shared/util.c index fef58d5f30..73e0a290b8 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -4276,24 +4276,6 @@ char *fstab_node_to_udev_node(const char *p) { return strdup(p); } -void filter_environ(const char *prefix) { - int i, j; - assert(prefix); - - if (!environ) - return; - - for (i = 0, j = 0; environ[i]; i++) { - - if (startswith(environ[i], prefix)) - continue; - - environ[j++] = environ[i]; - } - - environ[j] = NULL; -} - bool tty_is_vc(const char *tty) { assert(tty); diff --git a/src/shared/util.h b/src/shared/util.h index a45f54d661..e0934e59d9 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -409,8 +409,6 @@ void dual_timestamp_deserialize(const char *value, dual_timestamp *t); char *fstab_node_to_udev_node(const char *p); -void filter_environ(const char *prefix); - bool tty_is_vc(const char *tty); bool tty_is_vc_resolve(const char *tty); int vtnr_from_tty(const char *tty); |