diff options
author | Paul Smith <psmith@gnu.org> | 2002-05-10 03:15:07 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2002-05-10 03:15:07 +0000 |
commit | 9052b52dfc69d9567e2e664b0f096bfae535bcad (patch) | |
tree | 39e24d1a4d38996e5ffc42601d98d5b47289ee3f /function.c | |
parent | 5dedf7be638113e65df4bab535386db212a0e812 (diff) | |
download | gunmake-9052b52dfc69d9567e2e664b0f096bfae535bcad.tar.gz |
Fix Debian bug #144306: pass target-specific variables into the environment
properly.
Fix configure: allow cross-compilation; fix getloadavg (still needs _lots_
of work!)
Let $(call ...) functions to be self-referencing. Lets us do transitive
closures, for example.
Diffstat (limited to 'function.c')
-rw-r--r-- | function.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -991,7 +991,7 @@ func_error (o, argv, funcname) for (len=0, argvp=argv; *argvp != 0; ++argvp) len += strlen (*argvp) + 2; - p = msg = alloca (len + 1); + p = msg = (char *) alloca (len + 1); for (argvp=argv; argvp[1] != 0; ++argvp) { @@ -1822,10 +1822,11 @@ func_call (o, argv, funcname) { char *fname; char *cp; - int flen; char *body; + int flen; int i; const struct function_table_entry *entry_p; + struct variable *v; /* There is no way to define a variable with a space in the name, so strip leading and trailing whitespace as a favor to the user. */ @@ -1856,11 +1857,18 @@ func_call (o, argv, funcname) } /* Not a builtin, so the first argument is the name of a variable to be - expanded and interpreted as a function. Create the variable - reference. */ + expanded and interpreted as a function. Find it. */ flen = strlen (fname); - body = alloca (flen + 4); + v = lookup_variable (fname, flen); + + if (v == 0) + warn_undefined (fname, flen); + + if (v == 0 || *v->value == '\0') + return o; + + body = (char *) alloca (flen + 4); body[0] = '$'; body[1] = '('; memcpy (body + 2, fname, flen); @@ -1882,8 +1890,12 @@ func_call (o, argv, funcname) /* Expand the body in the context of the arguments, adding the result to the variable buffer. */ + v->exp_count = EXP_COUNT_MAX; + o = variable_expand_string (o, body, flen+3); + v->exp_count = 0; + pop_variable_scope (); return o + strlen (o); |