From 9052b52dfc69d9567e2e664b0f096bfae535bcad Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Fri, 10 May 2002 03:15:07 +0000 Subject: 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. --- function.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'function.c') diff --git a/function.c b/function.c index e263b0f..e314ee4 100644 --- a/function.c +++ b/function.c @@ -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); -- cgit v1.2.3