automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

88-file-contents-include.patch


From: Akim Demaille
Subject: 88-file-contents-include.patch
Date: Wed, 28 Mar 2001 09:28:14 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * automake.in (@conditional_stack): Rename as...
        (@cond_stack): this.
        (&file_contents_internal): Support inclusion of files.

Index: automake.in
--- automake.in Sun, 25 Mar 2001 18:00:42 +0200 akim (am/f/39_automake.i 1.214 
755)
+++ automake.in Sun, 25 Mar 2001 18:32:55 +0200 akim (am/f/39_automake.i 1.214 
755)
@@ -492,7 +492,7 @@ sub finish ($)
 my %target_conditional;

 # This is the conditional stack.
-my @conditional_stack;
+my @cond_stack;

 # This holds the set of included files.
 my @include_stack;
@@ -633,7 +633,7 @@ sub initialize_per_input ()

     %target_conditional = ();

-    @conditional_stack = ();
+    @cond_stack = ();

     @include_stack = ();

@@ -6299,8 +6299,8 @@ sub read_am_file
     # We save the conditional stack on entry, and then check to make
     # sure it is the same on exit.  This lets us conditonally include
     # other files.
-    my @saved_cond_stack = @conditional_stack;
-    my $cond = conditional_string (@conditional_stack);
+    my @saved_cond_stack = @cond_stack;
+    my $cond = conditional_string (@cond_stack);

     my $saw_bk = 0;
     my $was_rule = 0;
@@ -6341,7 +6341,7 @@ sub read_am_file
        {
            if ($was_rule)
            {
-               $output_trailer .= &make_condition (@conditional_stack);
+               $output_trailer .= &make_condition (@cond_stack);
                $output_trailer .= $_;
            }
            else
@@ -6369,38 +6369,38 @@ sub read_am_file
            my $new_cond = $1;
            &am_line_error ($., "$new_cond does not appear in AM_CONDITIONAL")
                if ! $configure_cond{$new_cond} && $new_cond !~ /^TRUE|FALSE$/;
-           push (@conditional_stack,
+           push (@cond_stack,
                  (($new_cond =~ /^TRUE|FALSE$/)
                   ? "$new_cond" : "${new_cond}_TRUE"));
-           $cond = conditional_string (@conditional_stack);
+           $cond = conditional_string (@cond_stack);
        }
        elsif (/$ELSE_PATTERN/o)
        {
-           if (! @conditional_stack)
+           if (! @cond_stack)
            {
                &am_line_error ($., "else without if");
            }
-           elsif ($conditional_stack[$#conditional_stack] =~ /_FALSE$/)
+           elsif ($cond_stack[$#cond_stack] =~ /_FALSE$/)
            {
                &am_line_error ($., "else after else");
            }
            else
            {
-               $conditional_stack[$#conditional_stack]
-                 = condition_negate ($conditional_stack[$#conditional_stack]);
-               $cond = conditional_string (@conditional_stack);
+               $cond_stack[$#cond_stack]
+                 = condition_negate ($cond_stack[$#cond_stack]);
+               $cond = conditional_string (@cond_stack);
            }
        }
        elsif (/$ENDIF_PATTERN/o)
        {
-           if (! @conditional_stack)
+           if (! @cond_stack)
            {
                &am_line_error ($., "endif without if");
            }
            else
            {
-               pop @conditional_stack;
-               $cond = conditional_string (@conditional_stack);
+               pop @cond_stack;
+               $cond = conditional_string (@cond_stack);
            }
        }
        elsif (/$RULE_PATTERN/o)
@@ -6412,7 +6412,7 @@ sub read_am_file

            $var_line{$1} = $.;
            $output_trailer .= $comment . $spacing;
-            $output_trailer .= &make_condition (@conditional_stack);
+            $output_trailer .= &make_condition (@cond_stack);
             $output_trailer .= $_;
            $comment = $spacing = '';
        }
@@ -6476,7 +6476,7 @@ sub read_am_file
            # In fact, this is what we assume.
            $was_rule = 1;
            $output_trailer .= $comment . $spacing;
-           $output_trailer .= &make_condition  (@conditional_stack);
+           $output_trailer .= &make_condition  (@cond_stack);
            $output_trailer .= $_;
            $comment = $spacing = '';
        }
@@ -6487,11 +6487,11 @@ sub read_am_file

     $output_trailer .= $comment;

-    if (join (' ', @saved_cond_stack) ne join (' ', @conditional_stack))
+    if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
     {
-       if (@conditional_stack)
+       if (@cond_stack)
        {
-           &am_error ("unterminated conditionals: @conditional_stack");
+           &am_error ("unterminated conditionals: @cond_stack");
        }
        else
        {
@@ -6712,8 +6712,12 @@ sub file_contents_internal ($%)
     my $result_rules = '';
     my $comment = '';
     my $spacing = '';
-    my @cond_stack = ();
-    my $cond = '';
+
+    # We save the conditional stack on entry, and then check to make
+    # sure it is the same on exit.  This lets us conditonally include
+    # other files.
+    my @saved_cond_stack = @cond_stack;
+    my $cond = conditional_string (@cond_stack);

     foreach (make_paragraphs ($file, %transform))
     {
@@ -6737,6 +6741,22 @@ sub file_contents_internal ($%)
            $comment = "$_\n";
        }

+       # Handle inclusion of other files.
+        elsif (/$INCLUDE_PATTERN/o)
+        {
+           if ($cond ne 'FALSE')
+             {
+               (my $file = $1) =~ s/\.am$//g;
+
+               # N-ary `.=' fails.
+               my ($com, $vars, $rules)
+                 = file_contents_internal ($file, %transform);
+               $comment .= $com;
+               $result_vars .= $vars;
+               $result_rules .= $rules;
+             }
+        }
+
         # Handling the conditionals.
         elsif (/$IF_PATTERN/o)
        {
@@ -6861,6 +6881,19 @@ sub file_contents_internal ($%)
        }
     }

+    if (join (' ', @saved_cond_stack) ne join (' ', @cond_stack))
+    {
+       if (@cond_stack)
+       {
+           &am_error ("unterminated conditionals: @cond_stack");
+       }
+       else
+       {
+           # FIXME: better error message here.
+           &am_error ("conditionals not nested in include file");
+       }
+    }
+
     return ($comment, $result_vars, $result_rules);
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]