]> sourceware.org Git - automake.git/commitdiff
Let's make it run ten times faster...
authorAkim Demaille <akim@epita.fr>
Mon, 5 Mar 2001 13:21:33 +0000 (13:21 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 5 Mar 2001 13:21:33 +0000 (13:21 +0000)
* 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
automake.in

index 5185034236a4ed20d5abdd3ef0b1d9cd4bcb2016..3c0e553a145484251df685d66c7caaf3d537490c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2001-03-05  Akim Demaille  <akim@epita.fr>
+
+       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  <tromey@redhat.com>
 
        * automake.in (register_language): Add entry for `-pure'.
index 5cd3909b2befcce815c6d05bec0590c2bdb961ee..f64574ee60978a0798b1f28d808d0c2ade60f502 100755 (executable)
@@ -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;
This page took 0.049334 seconds and 5 git commands to generate.