summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2007-11-04 21:54:00 +0000
committerPaul Smith <psmith@gnu.org>2007-11-04 21:54:00 +0000
commit43d81ff8669c3705ca3c61270af4a5c7218c2fe6 (patch)
treeabaa4fc983ce53dc44d006bb66d76a9e99505329 /variable.c
parentc1f71b0336fbeb105363a389dec27902ff9f280e (diff)
downloadgunmake-43d81ff8669c3705ca3c61270af4a5c7218c2fe6.tar.gz
New special variable: .RECIPEPREFIX
Allows the user to reset the prefix character for introducing recipe lines from the default (tab) to any other single character, and back again. Also, reworked the manual to consistently use the word "recipe" to describe the set of commands we use to update a target, instead of the various phrases used in the past: "commands", "command lines", "command scripts", etc.
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/variable.c b/variable.c
index 7f01988..e3071c2 100644
--- a/variable.c
+++ b/variable.c
@@ -252,7 +252,7 @@ define_variable_in_set (const char *name, unsigned int length,
#define EXPANSION_INCREMENT(_l) ((((_l) / 500) + 1) * 500)
static struct variable *
-handle_special_var (struct variable *var)
+lookup_special_var (struct variable *var)
{
static unsigned long last_var_count = 0;
@@ -352,7 +352,7 @@ lookup_variable (const char *name, unsigned int length)
v = (struct variable *) hash_find_item ((struct hash_table *) &set->table, &var_key);
if (v)
- return v->special ? handle_special_var (v) : v;
+ return v->special ? lookup_special_var (v) : v;
}
#ifdef VMS
@@ -985,6 +985,20 @@ target_environment (struct file *file)
return result_0;
}
+static struct variable *
+set_special_var (struct variable *var)
+{
+ if (streq (var->name, RECIPEPREFIX_NAME))
+ {
+ /* The user is resetting the command introduction prefix. This has to
+ happen immediately, so that subsequent rules are interpreted
+ properly. */
+ cmd_prefix = var->value[0]=='\0' ? RECIPEPREFIX_DEFAULT : var->value[0];
+ }
+
+ return var;
+}
+
/* Given a variable, a value, and a flavor, define the variable.
See the try_variable_definition() function for details on the parameters. */
@@ -1019,7 +1033,7 @@ do_variable_definition (const struct floc *flocp, const char *varname,
The value is set IFF the variable is not defined yet. */
v = lookup_variable (varname, strlen (varname));
if (v)
- return v;
+ return v->special ? set_special_var (v) : v;
conditional = 1;
flavor = f_recursive;
@@ -1227,7 +1241,7 @@ do_variable_definition (const struct floc *flocp, const char *varname,
if (alloc_value)
free (alloc_value);
- return v;
+ return v->special ? set_special_var (v) : v;
}
/* Try to interpret LINE (a null-terminated string) as a variable definition.