summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2010-11-06 21:56:23 +0000
committerPaul Smith <psmith@gnu.org>2010-11-06 21:56:23 +0000
commit391456aad790172c3cbbceb5544dd785c0e60a99 (patch)
treefaf87797baba5fae47c98029e5d2c1ec741fb7d1 /variable.c
parenta86d1693bac05e04f90a2ee3c4fa3547c788377c (diff)
downloadgunmake-391456aad790172c3cbbceb5544dd785c0e60a99.tar.gz
Improve backslash/newline handling to adhere to POSIX requirements.
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/variable.c b/variable.c
index 0d85546..b699088 100644
--- a/variable.c
+++ b/variable.c
@@ -1553,6 +1553,9 @@ print_variable (const void *item, void *arg)
switch (v->origin)
{
+ case o_automatic:
+ origin = _("automatic");
+ break;
case o_default:
origin = _("default");
break;
@@ -1571,9 +1574,6 @@ print_variable (const void *item, void *arg)
case o_override:
origin = _("`override' directive");
break;
- case o_automatic:
- origin = _("automatic");
- break;
case o_invalid:
default:
abort ();
@@ -1617,13 +1617,34 @@ print_variable (const void *item, void *arg)
}
+static void
+print_auto_variable (const void *item, void *arg)
+{
+ const struct variable *v = item;
+
+ if (v->origin == o_automatic)
+ print_variable (item, arg);
+}
+
+
+static void
+print_noauto_variable (const void *item, void *arg)
+{
+ const struct variable *v = item;
+
+ if (v->origin != o_automatic)
+ print_variable (item, arg);
+}
+
+
/* Print all the variables in SET. PREFIX is printed before
the actual variable definitions (everything else is comments). */
void
-print_variable_set (struct variable_set *set, char *prefix)
+print_variable_set (struct variable_set *set, char *prefix, int pauto)
{
- hash_map_arg (&set->table, print_variable, prefix);
+ hash_map_arg (&set->table, (pauto ? print_auto_variable : print_variable),
+ prefix);
fputs (_("# variable set hash-table stats:\n"), stdout);
fputs ("# ", stdout);
@@ -1638,7 +1659,7 @@ print_variable_data_base (void)
{
puts (_("\n# Variables\n"));
- print_variable_set (&global_variable_set, "");
+ print_variable_set (&global_variable_set, "", 0);
puts (_("\n# Pattern-specific Variable Values"));
@@ -1667,7 +1688,24 @@ void
print_file_variables (const struct file *file)
{
if (file->variables != 0)
- print_variable_set (file->variables->set, "# ");
+ print_variable_set (file->variables->set, "# ", 1);
+}
+
+void
+print_target_variables (const struct file *file)
+{
+ if (file->variables != 0)
+ {
+ int l = strlen (file->name);
+ char *t = alloca (l + 3);
+
+ strcpy (t, file->name);
+ t[l] = ':';
+ t[l+1] = ' ';
+ t[l+2] = '\0';
+
+ hash_map_arg (&file->variables->set->table, print_noauto_variable, t);
+ }
}
#ifdef WINDOWS32