mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Simplify environ_push so it doesn't need the ARRAY_* functions.
This commit is contained in:
parent
b6be03f01a
commit
73c871ba0a
23
environ.c
23
environ.c
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user