From 55d52957872739c897d439ca24a46df3bb0561d6 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 9 Apr 2001 09:46:53 +0000 Subject: [PATCH] * automake.in (&make_paragraphs): Extract from &file_contents. Make it more robust than the previous RE based scheme. (&file_contents): Use it. --- ChangeLog | 12 ++++++ automake.in | 117 +++++++++++++++++++++++++++++++++++----------------- 2 files changed, 91 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 436fddc0..a2677c49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-04-09 Akim Demaille + + * automake.in (&make_paragraphs): Extract from &file_contents. + Make it more robust than the previous RE based scheme. + (&file_contents): Use it. + +2001-04-09 Akim Demaille + + * automake.in (&make_paragraphs): Extract from &file_contents. + Make it more robust than the previous RE based scheme. + (&file_contents): Use it. + 2001-04-09 Akim Demaille * tests/yacc2.test: Don't define several times a variable, as diff --git a/automake.in b/automake.in index f266cdca..27dbbf88 100755 --- a/automake.in +++ b/automake.in @@ -6667,14 +6667,14 @@ sub flatten } -# ($COMMENT, $VARIABLES, $RULES) -# &file_contents_internal ($BASENAME, [%TRANSFORM]) -# ------------------------------------------------- -# Return contents of a file from $am_dir, automatically skipping -# macros or rules which are already known. -sub file_contents_internal ($%) +# @PARAGRAPHS +# &make_paragraphs ($MAKEFILE, [%TRANSFORM]) +# ------------------------------------------ +# Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of +# paragraphs. +sub make_paragraphs ($%) { - my ($basename, %transform) = @_; + my ($file, %transform) = @_; # Complete %transform with global options and make it a Perl # $command. @@ -6705,7 +6705,6 @@ sub file_contents_internal ($%) . 's/\n{3,}/\n\n/g'; # Swallow the file and apply the COMMAND. - my $file = $am_dir . '/' . $basename . '.am'; my $fc_file = new IO::File ("< $file"); if (! $fc_file) { @@ -6714,30 +6713,72 @@ sub file_contents_internal ($%) # Looks stupid? print "$me: reading $file\n" if $verbose; - - # Swallow into $CONTENTS the whole content of the file, after - # having performed the $COMMAND, and removed Automake comments. my $saved_dollar_slash = $/; undef $/; $_ = $fc_file->getline; $/ = $saved_dollar_slash; eval $command; $fc_file->close; - my $contents = $_; - - - # Process each Make `paragraph'. - # - # A Make `paragraph' is delimited by a new line which is not - # escaped, and not followed by a tab or a comment. - # - # Frankly, unless you like fighting with Perl (you're a freak!), - # if I were you I would not try some other implementation, it's - # very easy falling either into extremely low RE matching - # (backtracking...), or worse yet: infloop... For instance, (my) - # perl goes loopy if you try to - # - # $result_rules =~ /^($TARGET_PATTERN *)+: ($TARGET_PATTERN *)+\n\n/sm + my $content = $_; + + # A rule has three parts: a list of targets, a list of dependencies, + # and optionally actions. + my $RULE_PATTERN = + "^($TARGET_PATTERN(?:(?:\\\\\n|\\s)+$TARGET_PATTERN)*) *:([^=].*|)\$"; + + + # Split at unescaped new lines. + my @lines = split (/(?