Simplify environ_push so it doesn't need the ARRAY_* functions.

This commit is contained in:
nicm 2015-05-07 07:35:31 +00:00
parent b6be03f01a
commit 73c871ba0a

View File

@ -157,23 +157,16 @@ environ_update(const char *vars, struct environ *srcenv,
void
environ_push(struct environ *env)
{
ARRAY_DECL(, char *) varlist;
struct environ_entry *envent;
char **varp, *var;
u_int i;
struct environ_entry *envent;
char **vp, *v;
ARRAY_INIT(&varlist);
for (varp = environ; *varp != NULL; varp++) {
var = xstrdup(*varp);
var[strcspn(var, "=")] = '\0';
ARRAY_ADD(&varlist, var);
for (vp = environ; *vp != NULL; vp++) {
v = xstrdup(*vp);
v[strcspn(v, "=")] = '\0';
unsetenv(v);
free(v);
}
for (i = 0; i < ARRAY_LENGTH(&varlist); i++) {
var = ARRAY_ITEM(&varlist, i);
unsetenv(var);
free(var);
}
ARRAY_FREE(&varlist);
RB_FOREACH(envent, environ, env) {
if (envent->value != NULL)