[PATCH] Fix add env in multiple sections
Michael Neuling
mikey at neuling.org
Thu Sep 14 08:14:33 EST 2006
If you have 'add env = BLAH=123' in multiple sections, you should get the
first one not the last one.
---
# HG changeset patch
# User Michael Neuling <mikey at neuling.org>
# Node ID b872bbb320f644269d2e6864f9ba543f7a4b0a10
# Parent 39733b03a753d31e8b9aace5a5ad2fa0e5bae4d1
Fixed order of add env statements in multiple sections
diff -r 39733b03a753 -r b872bbb320f6 ccontrol.c
--- a/ccontrol.c Wed Apr 19 05:48:40 2006
+++ b/ccontrol.c Wed Sep 13 22:03:46 2006
@@ -70,12 +70,26 @@
return false;
}
+/* This list is backwards. setenv it forwards. */
+static void setenv_add(struct add *add)
+{
+ if (!add)
+ return;
+ setenv_add(add->next);
+
+ char *eq = strchr(add->arg, '=');
+ if (!eq)
+ fatal("Environment variable needs '=': ", 0, add->arg,
+ NULL);
+ *eq = '\0';
+ setenv(add->arg, eq+1, 1);
+}
+
/* Earlier arg parsing might have revealed distcc is useless. */
static void adjust_args_and_environment(struct section sec,
enum type type,
char *argv[], unsigned argc)
{
- struct add *add;
argv[0] = sec.names[type];
switch (type) {
@@ -115,14 +129,7 @@
}
- for (add = sec.env_add; add; add = add->next) {
- char *eq = strchr(add->arg, '=');
- if (!eq)
- fatal("Environment variable needs '=': ", 0, add->arg,
- NULL);
- *eq = '\0';
- setenv(add->arg, eq+1, 1);
- }
+ setenv_add(sec.env_add);
}
#ifndef TESTING
More information about the ccontrol
mailing list