summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>2018-07-27 14:55:29 +0200
committerMatthias Paulmier <matthias.paulmier@etu.u-bordeaux.fr>2018-07-27 14:55:29 +0200
commit4c6369f47daf6675dc9c2f48cd45900d0650cd47 (patch)
tree7da6110b597d35dfef679cf949ed88745f726b13
parentfea9e74524fbac25c719aac2bdf1a2e2d99a6873 (diff)
downloadautomake-4c6369f47daf6675dc9c2f48cd45900d0650cd47.tar.gz
lib/Automake/File.pm: Change the way make_paragraphs works
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).
-rwxr-xr-xbin/automake.in2
-rw-r--r--lib/Automake/ConfVars.pm3
-rw-r--r--lib/Automake/File.pm21
3 files changed, 13 insertions, 13 deletions
diff --git a/bin/automake.in b/bin/automake.in
index 6c79d1422..c0cfd1e6f 100755
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -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);
diff --git a/lib/Automake/ConfVars.pm b/lib/Automake/ConfVars.pm
index 73b0e1deb..8d834e217 100644
--- a/lib/Automake/ConfVars.pm
+++ b/lib/Automake/ConfVars.pm
@@ -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,
diff --git a/lib/Automake/File.pm b/lib/Automake/File.pm
index 99d3038db..522d395c1 100644
--- a/lib/Automake/File.pm
+++ b/lib/Automake/File.pm
@@ -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);