From 04b28766f2f892891dc74aa1459798406fedcffd Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 5 Mar 2001 13:21:33 +0000 Subject: [PATCH] Let's make it run ten times faster... * automake.in (&transform): Be sure to remove the `n' with ?FOO? transformations. (&file_contents): Let `$command' remove the Automake commands, and normalize the series of `n'. Slurp the file and apply $command in a single step. No longer apply the `@MAINTAINER_MODE_TRUE@' transformation which is already normalized to be handled by &transform. --- ChangeLog | 12 ++++++++ automake.in | 87 +++++++++++++++++++++++------------------------------ 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index 51850342..3c0e553a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-03-05 Akim Demaille + + Let's make it run ten times faster... + + * automake.in (&transform): Be sure to remove the `\n' with ?FOO? + transformations. + (&file_contents): Let `$command' remove the Automake commands, and + normalize the series of `\n'. + Slurp the file and apply $command in a single step. + No longer apply the `@MAINTAINER_MODE_TRUE@' transformation which + is already normalized to be handled by &transform. + 2001-03-05 Tom Tromey * automake.in (register_language): Add entry for `-pure'. diff --git a/automake.in b/automake.in index 5cd3909b..f64574ee 100755 --- a/automake.in +++ b/automake.in @@ -6590,21 +6590,26 @@ sub file_contents &prog_error ("file_contents: $command") if $command ne '' && substr ($command, -1) ne ';'; $command .= - &transform ('CYGNUS' => $cygnus_mode, - 'MAINTAINER_MODE' => $seen_maint_mode, - - 'SHAR' => $options{'dist-shar'}, - 'BZIP2' => $options{'dist-bzip2'}, - 'ZIP' => $options{'dist-zip'}, - 'COMPRESS' => $options{'dist-tarZ'}, - - 'INSTALL-INFO' => !$options{'no-installinfo'}, - 'INSTALL-MAN' => !$options{'no-installman'}, - 'CK-NEWS' => $options{'check-news'}, - - 'SUBDIRS' => &variable_defined ('SUBDIRS')); - - # Swallow the file and applied the COMMAND. + # We don't use IGNORE_PATTERN because it contains $ which + # prevents us from matching the end of line. + "s/##([^#\n].*)?\\n//gmo;" + . &transform ('CYGNUS' => $cygnus_mode, + 'MAINTAINER_MODE' => $seen_maint_mode, + + 'SHAR' => $options{'dist-shar'}, + 'BZIP2' => $options{'dist-bzip2'}, + 'ZIP' => $options{'dist-zip'}, + 'COMPRESS' => $options{'dist-tarZ'}, + + 'INSTALL-INFO' => !$options{'no-installinfo'}, + 'INSTALL-MAN' => !$options{'no-installman'}, + 'CK-NEWS' => $options{'check-news'}, + + 'SUBDIRS' => &variable_defined ('SUBDIRS')) + # We don't need more than two consecutive new-lines. + . '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) @@ -6616,39 +6621,15 @@ sub file_contents # Swallow into $CONTENTS the whole content of the file, after # having performed the $COMMAND, and removed Automake comments. - my $contents = ''; - - while ($_ = $fc_file->getline) - { - $_ =~ s/\@MAINTAINER_MODE_TRUE\@//g - unless $seen_maint_mode; - - $had_chars = length ($_) && $_ ne "\n"; - eval $command; - # If the transform caused all the characters to go away, then - # ignore the line. Why do this? Because in Perl 4, a "next" - # inside of an eval doesn't affect a loop outside the eval. - # So we can't pass in a "transform" that uses next. We used - # to do this. "Empty" also means consisting of a single - # newline. - next if $had_chars && ($_ eq '' || $_ eq "\n"); - - # Merely delete comments beginning with two hashes. - next if /$IGNORE_PATTERN/o; - - $contents .= $_; - } + my $saved_dollar_slash = $/; + undef $/; + $_ = $fc_file->getline; + $/ = $saved_dollar_slash; + eval $command; + $contents = $_; $fc_file->close; - # We don't need more than two consecutive new-lines. - $contents =~ s/\n{3,}/\n\n/g; - - # 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)*) *:([^=].*|)\$"; - # Process each Make `paragraph'. # @@ -6662,6 +6643,12 @@ sub file_contents # perl goes loopy if you try to # # $result_rules =~ /^($TARGET_PATTERN *)+: ($TARGET_PATTERN *)+\n\n/sm + + # 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)*) *:([^=].*|)\$"; + my $result_vars = ''; my $result_rules = ''; my $comment = ''; @@ -6784,14 +6771,14 @@ sub transform (%) while (my ($token, $val) = each %pairs) { - $result .= "s/\Q%$token%\E/\Q$val\E/g;"; + $result .= "s/\Q%$token%\E/\Q$val\E/gm;"; if ($val) { - $result .= "s/\Q?$token?\E//g;s/^.*\Q?!$token?\E.*\$//g;"; + $result .= "s/\Q?$token?\E//gm;s/^.*\Q?!$token?\E.*\\n//gm;"; } else { - $result .= "s/\Q?!$token?\E//g;s/^.*\Q?$token?\E.*\$//g;"; + $result .= "s/\Q?!$token?\E//gm;s/^.*\Q?$token?\E.*\\n//gm;"; } } @@ -6855,12 +6842,12 @@ sub am_install_var if (defined $configure_vars{'LIBTOOL'}) { # Transform '%LIBTOOL ...%' to '$(LIBTOOL) ...' - $ltxform = 's/%LIBTOOL([^\%]*)%/\$(LIBTOOL) $1/;'; + $ltxform = 's/%LIBTOOL([^\%]*)%/\$(LIBTOOL) $1/g;'; } else { # Delete '%LIBTOOL ...%' - $ltxform = 's/%LIBTOOL([^%]*)%//;'; + $ltxform = 's/%LIBTOOL([^%]*)%//g;'; } my $cygxform; -- 2.43.5