env-util: minor modernization

This commit is contained in:
Mike Yuan
2024-02-15 19:23:52 +08:00
parent 52bcc872b5
commit 9128fd553c
3 changed files with 10 additions and 14 deletions
+6 -10
View File
@@ -310,19 +310,17 @@ char **strv_env_delete(char **x, size_t n_lists, ...) {
return TAKE_PTR(t);
}
char **strv_env_unset(char **l, const char *p) {
char **f, **t;
char** strv_env_unset(char **l, const char *p) {
assert(p);
if (!l)
return NULL;
assert(p);
/* Drops every occurrence of the env var setting p in the
* string list. Edits in-place. */
char **f, **t;
for (f = t = l; *f; f++) {
if (env_match(*f, p)) {
free(*f);
continue;
@@ -335,14 +333,13 @@ char **strv_env_unset(char **l, const char *p) {
return l;
}
char **strv_env_unset_many(char **l, ...) {
char **f, **t;
char** strv_env_unset_many_internal(char **l, ...) {
if (!l)
return NULL;
/* Like strv_env_unset() but applies many at once. Edits in-place. */
char **f, **t;
for (f = t = l; *f; f++) {
bool found = false;
const char *p;
@@ -350,12 +347,11 @@ char **strv_env_unset_many(char **l, ...) {
va_start(ap, l);
while ((p = va_arg(ap, const char*))) {
while ((p = va_arg(ap, const char*)))
if (env_match(*f, p)) {
found = true;
break;
}
}
va_end(ap);