X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fstrv.c;h=d1c7b2c32d89c31b121fc6ef1c0c719a9167c81c;hp=9dbab2937cd3c39c525d042c5056bc237a6a9913;hb=867b3b7d6b88ba4d07ec7c830576d4ac2f7dd226;hpb=fab56fc541cebdbbc4cc273c3f0807eb7807b9fd diff --git a/src/strv.c b/src/strv.c index 9dbab2937..d1c7b2c32 100644 --- a/src/strv.c +++ b/src/strv.c @@ -1,4 +1,4 @@ -/*-*- Mode: C; c-basic-offset: 8 -*-*/ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ /*** This file is part of systemd. @@ -380,7 +380,7 @@ static int env_append(char **r, char ***k, char **a) { /* Add the entries of a to *k unless they already exist in *r * in which case they are overriden instead. This assumes - * there is enough space in the r */ + * there is enough space in the r array. */ for (; *a; a++) { char **j; @@ -556,3 +556,24 @@ char *strv_env_get_with_length(char **l, const char *name, size_t k) { char *strv_env_get(char **l, const char *name) { return strv_env_get_with_length(l, name, strlen(name)); } + +char **strv_env_clean(char **l) { + char **r, **ret; + + for (r = ret = l; *l; l++) { + const char *equal; + + equal = strchr(*l, '='); + + if (equal && equal[1] == 0) { + free(*l); + continue; + } + + *(r++) = *l; + } + + *r = NULL; + + return ret; +}