mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Make array options a sparse tree instead of an array of char * and
remove the size limit.
This commit is contained in:
20
environ.c
20
environ.c
@ -174,22 +174,26 @@ environ_unset(struct environ *env, const char *name)
|
||||
void
|
||||
environ_update(struct options *oo, struct environ *src, struct environ *dst)
|
||||
{
|
||||
struct environ_entry *envent;
|
||||
struct options_entry *o;
|
||||
u_int size, idx;
|
||||
const char *value;
|
||||
struct environ_entry *envent;
|
||||
struct options_entry *o;
|
||||
struct options_array_item *a;
|
||||
const char *value;
|
||||
|
||||
o = options_get(oo, "update-environment");
|
||||
if (o == NULL || options_array_size(o, &size) == -1)
|
||||
if (o == NULL)
|
||||
return;
|
||||
for (idx = 0; idx < size; idx++) {
|
||||
value = options_array_get(o, idx);
|
||||
if (value == NULL)
|
||||
a = options_array_first(o);
|
||||
while (a != NULL) {
|
||||
value = options_array_item_value(a);
|
||||
if (value == NULL) {
|
||||
a = options_array_next(a);
|
||||
continue;
|
||||
}
|
||||
if ((envent = environ_find(src, value)) == NULL)
|
||||
environ_clear(dst, value);
|
||||
else
|
||||
environ_set(dst, envent->name, "%s", envent->value);
|
||||
a = options_array_next(a);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user