]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
lib/Automake/File.pm: Change the way make_paragraphs works
authorMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>
Fri, 27 Jul 2018 12:55:29 +0000 (14:55 +0200)
committerMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>
Fri, 27 Jul 2018 12:55:29 +0000 (14:55 +0200)
We now call preprocess_file before make_paragraphs.  This is useful to test
the lib as we can now feed a file handle (Automake::XFile) directly to
make_paragraphs (and not simply a filename).

bin/automake.in
lib/Automake/ConfVars.pm
lib/Automake/File.pm

index 6c79d1422d23af4daa953496d58a40c9c8a4baf0..c0cfd1e6fed7c44d6cf9192798c3a9c265f9f722 100755 (executable)
@@ -1787,7 +1787,7 @@ sub handle_compile ()
      'DISTRMS' => join ("\n", @dist_rms)
     );
 
-  my @paragraphs = make_paragraphs ($filename, %transform);
+  my @paragraphs = make_paragraphs (preprocess_file ($filename, %transform));
   my ($coms, $vars, $rules) =
       file_contents_internal (1, $filename, new Automake::Location,
                               \@paragraphs, %transform);
index 73b0e1debcbafdeab58e69ee99c574eb8257c77c..8d834e217a61125d003e26f64eec15bca4ec2e59 100644 (file)
@@ -67,7 +67,8 @@ sub define_standard_variables ()
   my $saved_output_vars = $output_vars;
   my $filename = "$libdir/am/header-vars.am";
 
-  my @paragraphs = make_paragraphs ($filename);
+  my $preprocessed_file = preprocess_file ($filename);
+  my @paragraphs = make_paragraphs ($preprocessed_file);
 
   my ($comments, undef, $rules) =
       file_contents_internal (1, $filename, new Automake::Location,
index 99d3038db78c8358cc0200c272ee053f5f8eb3f1..522d395c1ddbcb627c192b7619ba721e47aac748 100644 (file)
@@ -65,6 +65,9 @@ sub preprocess_file
 {
   my ($file, %transform) = @_;
 
+  $transform{FIRST} = !$transformed_files{$file};
+  $transformed_files{$file} = 1;
+
   # Complete %transform with global options.
   # Note that %transform goes last, so it overrides global options.
   %transform = ( 'MAINTAINER-MODE'
@@ -124,17 +127,13 @@ sub preprocess_file
 
 
 # @PARAGRAPHS
-# make_paragraphs ($MAKEFILE, [%TRANSFORM])
-# -----------------------------------------
-# Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
-# paragraphs.
+# make_paragraphs ($MAKEFILE)
+# ---------------------------
+# Load a preprocessed $MAKEFILE and return it as a list of paragraphs
 sub make_paragraphs
 {
-  my ($file, %transform) = @_;
-  $transform{FIRST} = !$transformed_files{$file};
-  $transformed_files{$file} = 1;
-
-  my @lines = split /(?<!\\)\n/, preprocess_file ($file, %transform);
+  my ($preprocessed_file) = shift;
+  my @lines = split /(?<!\\)\n/, $preprocessed_file;
   my @res;
 
   while (defined ($_ = shift @lines))
@@ -229,7 +228,7 @@ sub file_contents_internal
             {
               my $filename = ($is_am ? "$libdir/am/" : '') . $1;
               $where->push_context ("'$filename' included from here");
-              my @paragraphs = make_paragraphs ($filename, %transform);
+              my @paragraphs = make_paragraphs (preprocess_file ($filename, %transform));
               # N-ary '.=' fails.
               my ($com, $vars, $rules) =
                   file_contents_internal ($is_am, $filename, $where,
@@ -373,7 +372,7 @@ sub file_contents_internal
 sub file_contents
 {
   my ($basename, $where, %transform) = @_;
-  my @paragraphs = make_paragraphs ("$libdir/am/$basename.am", %transform);
+  my @paragraphs = make_paragraphs (preprocess_file ("$libdir/am/$basename.am", %transform));
   my ($comments, $variables, $rules) =
       file_contents_internal (1, $basename, $where,
                               \@paragraphs, %transform);