summaryrefslogtreecommitdiff
path: root/read.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2002-09-10 07:27:28 +0000
committerPaul Smith <psmith@gnu.org>2002-09-10 07:27:28 +0000
commit7ea029a07c02b9401cb3d88566eac41959b84c11 (patch)
tree0a26e865bee26f79c718258415b5389023076942 /read.c
parent9b41488ad15e4ffc63b8094379c17f567b094c1b (diff)
downloadgunmake-7ea029a07c02b9401cb3d88566eac41959b84c11.tar.gz
Add support for broken SA_RESTART on PTX.
Fix bug #103: allow ifdef, export, and unexport to expand their arguments.
Diffstat (limited to 'read.c')
-rw-r--r--read.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/read.c b/read.c
index 7dee3e3..dd930f7 100644
--- a/read.c
+++ b/read.c
@@ -593,7 +593,7 @@ eval (ebuf, set_default)
|| word1eq ("ifeq") || word1eq ("ifneq")
|| word1eq ("else") || word1eq ("endif")))
{
- int i = conditional_line (p, fstart);
+ int i = conditional_line (p, fstart);
if (i < 0)
fatal (fstart, _("invalid syntax in conditional"));
@@ -686,11 +686,21 @@ eval (ebuf, set_default)
for (p = find_next_token (&p2, &len); p != 0;
p = find_next_token (&p2, &len))
{
- v = lookup_variable (p, len);
+ char *var;
+ int l;
+
+ /* Expand the thing we're looking up, so we can use
+ indirect and constructed variable names. */
+ p[len] = '\0';
+ var = allocated_variable_expand (p);
+ l = strlen (var);
+
+ v = lookup_variable (var, l);
if (v == 0)
- v = define_variable_loc (p, len, "", o_file, 0,
+ v = define_variable_loc (var, l, "", o_file, 0,
fstart);
v->export = v_export;
+ free (var);
}
}
}
@@ -708,10 +718,22 @@ eval (ebuf, set_default)
for (p = find_next_token (&p2, &len); p != 0;
p = find_next_token (&p2, &len))
{
- v = lookup_variable (p, len);
+ char *var;
+ int l;
+
+ /* Expand the thing we're looking up, so we can use
+ indirect and constructed variable names. */
+ p[len] = '\0';
+ var = allocated_variable_expand (p);
+ l = strlen (var);
+
+ v = lookup_variable (var, l);
if (v == 0)
- v = define_variable_loc (p, len, "", o_file, 0, fstart);
+ v = define_variable_loc (var, l, "", o_file, 0, fstart);
+
v->export = v_noexport;
+
+ free (var);
}
}
goto rule_complete;
@@ -1410,15 +1432,24 @@ conditional_line (line, flocp)
if (cmdname[notdef ? 3 : 2] == 'd')
{
/* "Ifdef" or "ifndef". */
+ char *var;
struct variable *v;
register char *p = end_of_token (line);
i = p - line;
p = next_token (p);
if (*p != '\0')
return -1;
- v = lookup_variable (line, i);
+
+ /* Expand the thing we're looking up, so we can use indirect and
+ constructed variable names. */
+ line[i] = '\0';
+ var = allocated_variable_expand (line);
+
+ v = lookup_variable (var, strlen (var));
conditionals->ignoring[conditionals->if_cmds - 1]
= (v != 0 && *v->value != '\0') == notdef;
+
+ free (var);
}
else
{