]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
fixed more recursivity failures
authorTom Tromey <tromey@redhat.com>
Sun, 19 Jul 1998 06:13:13 +0000 (06:13 +0000)
committerTom Tromey <tromey@redhat.com>
Sun, 19 Jul 1998 06:13:13 +0000 (06:13 +0000)
ChangeLog
automake.in
tests/ChangeLog
tests/Makefile.am
tests/Makefile.in
tests/recurs.test [new file with mode: 0755]

index d9ca14a70cdc2e7e61af31d06afdb121f931e3d8..389f23e4e1def526cbb35ded9aadc0dece7b248a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
+Sun Jul 19 00:04:25 1998  Tom Tromey  <tromey@cygnus.com>
+
+       * automake.in (variable_conditions): Initialize %vars_scanned.
+       (variable_conditions_sub): Check it.  Test cond5.test.
+
 Sat Jul 18 00:24:14 1998  Tom Tromey  <tromey@cygnus.com>
 
+       * automake.in (variable_value_as_list_worker): Renamed from
+       variable_value_as_list.  Set entry in vars_scanned, and give error
+       if variable recursively defined.  Test recurs.test.
+       (value_to_list): Call it instead.
+       (variable_value_as_list): New function.
+
        * automake.in (variable_conditions_sub): If var is not
        conditional, but does have conditional subvariables, then return
        value should be all permutations of subvariable conditions.  Test
index fc16d7a18bca8aa6996effb42dd30dbc396a536b..352a674ecbc1f30b0b0c3c1673521b4b9ed4e344 100755 (executable)
@@ -4708,6 +4708,7 @@ sub variable_conditions
     local (%uniqify);
     local ($cond);
 
+    %vars_scanned = ();
     foreach $cond (&variable_conditions_sub ($var, '', ()))
     {
        $uniqify{$cond} = 1;
@@ -4723,6 +4724,13 @@ sub variable_conditions_sub
     local ($var, $parent, @parent_conds) = @_;
     local (@new_conds) = ();
 
+    if (defined $vars_scanned{$var})
+    {
+       &am_line_error ($parent, "variable \`$var' recursively defined");
+       return ();
+    }
+    $vars_scanned{$var} = 1;
+
     if (! $conditional{$var})
     {
        foreach (split (' ', $contents{$var}))
@@ -4963,7 +4971,9 @@ sub variable_value
 # conditions should be returned; if COND is a particular condition
 # (all conditions are surrounded by @...@) then only the value for
 # that condition should be returned; otherwise, warn if VAR is
-# conditionally defined.
+# conditionally defined.  SCANNED is a global hash listing whose keys
+# are all the variables already scanned; it is an error to rescan a
+# variable.
 sub value_to_list
 {
     local ($var, $val, $cond) = @_;
@@ -4993,7 +5003,7 @@ sub value_to_list
            }
 
            # Find the value.
-           @temp_list = &variable_value_as_list ($1, $cond, $var);
+           @temp_list = &variable_value_as_list_worker ($1, $cond, $var);
 
            # Now rewrite the value if appropriate.
            if ($from)
@@ -5020,7 +5030,7 @@ sub value_to_list
 # that condition should be returned; otherwise, warn if VAR is
 # conditionally defined.  If PARENT is specified, it is the name of
 # the including variable; this is only used for error reports.
-sub variable_value_as_list
+sub variable_value_as_list_worker
 {
     local ($var, $cond, $parent) = @_;
     local (@result);
@@ -5033,8 +5043,15 @@ sub variable_value_as_list
     {
        &am_line_error ($parent, "variable \`$var' not defined");
     }
+    elsif (defined $vars_scanned{$var})
+    {
+       # `vars_scanned' is a global we use to keep track of which
+       # variables we've already examined.
+       &am_line_error ($parent, "variable \`$var' recursively defined");
+    }
     elsif ($cond eq 'all' && $conditional{$var})
     {
+       $vars_scanned{$var} = 1;
        local (@condvals) = split (' ', $conditional{$var});
        while (@condvals)
        {
@@ -5045,6 +5062,7 @@ sub variable_value_as_list
     }
     elsif ($cond && $conditional{$var})
     {
+       $vars_scanned{$var} = 1;
        local (@condvals) = split (' ', $conditional{$var});
        local ($onceflag);
        while (@condvals)
@@ -5064,6 +5082,7 @@ sub variable_value_as_list
     }
     else
     {
+       $vars_scanned{$var} = 1;
        &variable_conditionally_defined ($var, $parent);
        $content_seen{$var} = 1;
        push (@result, &value_to_list ($var, $contents{$var}, $cond));
@@ -5072,6 +5091,16 @@ sub variable_value_as_list
     return @result;
 }
 
+# This is just a wrapper for variable_value_as_list_worker that
+# initializes the global hash `vars_scanned'.  This hash is used to
+# avoid infinite recursion.
+sub variable_value_as_list
+{
+    local ($var, $cond, $parent) = @_;
+    %vars_scanned = ();
+    return &variable_value_as_list_worker ($var, $cond, $parent);
+}
+
 # Define a new variable, but only if not already defined.
 sub define_variable
 {
index 0482b3d193a6ad86ea4b0bceeaccf098f5d2492e..7a8f5364554beaa0f21ca94853ea2526f63a5986 100644 (file)
@@ -1,5 +1,7 @@
 Sat Jul 18 00:27:26 1998  Tom Tromey  <tromey@cygnus.com>
 
+       * recurs.test: New file.
+
        * cond3.test: Changed to match recent fixes.
 
 Fri Jul 17 23:44:49 1998  Tom Tromey  <tromey@cygnus.com>
index f4fe367a6faae3b45b20a75f401fa53e87e56cf8..7e41beb20ef583896d061203e39d4dce2b29ef44 100644 (file)
@@ -31,7 +31,7 @@ aclocal.test alpha.test whoami.test unused.test condman.test \
 texinfo5.test aclocali.test texinfo6.test condman2.test colon4.test \
 java.test sinclude.test javaprim.test javasubst.test aclocalii.test \
 lex2.test libobj8.test version3.test instdata.test exdir2.test \
-colon5.test library.test syntax.test cond4.test cond5.test
+colon5.test library.test syntax.test cond4.test cond5.test recurs.test
 
 EXTRA_DIST = defs $(TESTS)
 
index eddd23a6d141fba2572b4474d6007734b38a9e67..be6af76c34560f5a5bab7b1d3bddf360106509bd 100644 (file)
@@ -94,7 +94,7 @@ aclocal.test alpha.test whoami.test unused.test condman.test \
 texinfo5.test aclocali.test texinfo6.test condman2.test colon4.test \
 java.test sinclude.test javaprim.test javasubst.test aclocalii.test \
 lex2.test libobj8.test version3.test instdata.test exdir2.test \
-colon5.test library.test syntax.test cond4.test cond5.test
+colon5.test library.test syntax.test cond4.test cond5.test recurs.test
 
 EXTRA_DIST = defs $(TESTS)
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
diff --git a/tests/recurs.test b/tests/recurs.test
new file mode 100755 (executable)
index 0000000..9816df1
--- /dev/null
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+# Test to make sure recursive variable definitions die.
+
+. $srcdir/defs || exit 1
+
+cat > configure.in << 'END'
+AM_INIT_AUTOMAKE(nonesuch, nonesuch)
+AC_PROG_CC
+AM_CONDITIONAL(ONE, true)
+AM_CONDITIONAL(TWO, false)
+AC_OUTPUT(Makefile)
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS = $(foo)
+foo = $(bin_PROGRAMS)
+END
+
+$AUTOMAKE && exit 1
+exit 0