From 8572d6adf04d397505770b0b0d5cfd91cf6a92a8 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Mon, 8 Jul 2002 02:26:47 +0000 Subject: Major updates in preparation for 3.80. New version of the manual, put into the doc subdir. Enhancements: $(eval ...) and $(value ...) functions, various bug fixes, etc. See the ChangeLog. More to come. --- function.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'function.c') diff --git a/function.c b/function.c index e314ee4..889caa8 100644 --- a/function.c +++ b/function.c @@ -1140,6 +1140,42 @@ func_wildcard (o, argv, funcname) return o; } +/* + $(eval ) + + Always resolves to the empty string. + + Treat the arguments as a segment of makefile, and parse them. +*/ + +static char * +func_eval (o, argv, funcname) + char *o; + char **argv; + const char *funcname; +{ + eval_buffer (argv[0]); + + return o; +} + + +static char * +func_value (o, argv, funcname) + char *o; + char **argv; + const char *funcname; +{ + /* Look up the variable. */ + struct variable *v = lookup_variable (argv[0], strlen (argv[0])); + + /* Copy its value into the output buffer without expanding it. */ + if (v) + o = variable_buffer_output (o, v->value, strlen(v->value)); + + return o; +} + /* \r is replaced on UNIX as well. Is this desirable? */ @@ -1618,8 +1654,6 @@ func_not (char* o, char **argv, char *funcname) #endif -#define STRING_SIZE_TUPLE(_s) (_s), (sizeof (_s)-1) - /* Lookup table for builtin functions. This doesn't have to be sorted; we use a straight lookup. We might gain @@ -1664,6 +1698,8 @@ static struct function_table_entry function_table[] = { STRING_SIZE_TUPLE("error"), 0, 1, 1, func_error}, { STRING_SIZE_TUPLE("warning"), 0, 1, 1, func_error}, { STRING_SIZE_TUPLE("if"), 2, 3, 0, func_if}, + { STRING_SIZE_TUPLE("value"), 0, 1, 1, func_value}, + { STRING_SIZE_TUPLE("eval"), 0, 1, 1, func_eval}, #ifdef EXPERIMENTAL { STRING_SIZE_TUPLE("eq"), 2, 2, 1, func_eq}, { STRING_SIZE_TUPLE("not"), 0, 1, 1, func_not}, -- cgit v1.2.3