[23784] users/pipping/test.pl

source_changes at macosforge.org source_changes at macosforge.org
Mon Apr 9 16:37:44 PDT 2007


Revision: 23784
          http://trac.macosforge.org/projects/macports/changeset/23784
Author:   pipping at macports.org
Date:     2007-04-09 16:37:43 -0700 (Mon, 09 Apr 2007)

Log Message:
-----------
 * build a regex library before entering loops

Modified Paths:
--------------
    users/pipping/test.pl

Modified: users/pipping/test.pl
===================================================================
--- users/pipping/test.pl	2007-04-09 23:07:49 UTC (rev 23783)
+++ users/pipping/test.pl	2007-04-09 23:37:43 UTC (rev 23784)
@@ -3,34 +3,35 @@
 use strict;
 use warnings;
 
+my $port = $ARGV[0];
+
+# prepare freqently used regexes
+my $trailing_comment      = qr{;\s*#.*};
+my $leading_comment       = qr{(?:^|\n)\s*#.*};
+my $connecting_backslash  = qr{\s*\\\n\s*};
+
+my $quick_check = qr{:$port}i;
+
+my $dependency  = qr{depends_(?:build|run|lib)(?:-(?:append|delete))?
+                  .*
+                  (?:port|(?:path|lib|bin):[^:]+):(?i:${port})(?:\s|$)}x;
+
 $/ = ".\n";
 
-my $port = $ARGV[0];
-
 while (defined(my $portfile = <*/*/Portfile>)) { 
   @ARGV = $portfile;
 
   while (<>) {
     # make a quick and dirty check if the port has a remote chance of
     # depending on $port
-    if ($_ =~ m{
-        :$port
-        }ix) {
-      # concatenate lines connected through trailing backslashes
-      s{\s*\\\n\s*}{ }mgi;
+    if ($_ =~ m{$quick_check}i) {
 
-      # remove comments with whitespace in front
-      s{(?:^|\n)\s*#.*}{}g;
+      s{$connecting_backslash}{ }g;     # merge backslash-connected lines
+      s{$leading_comment}{}g;           # remove leading comments
+      s{$trailing_comment}{}g;          # remove trailing comments
 
-      # remove trailing comments
-      s{;\s*#.*}{}g;
-
-      if ($_ =~ m{
-          depends_(?:build|run|lib)(?:-(?:append|delete))?
-          .*
-          (?:port|(?:path|lib|bin):[^:]+):(?i:${port})(?:\s|$)}x) {
-        # remove trailing '/Portfile' in the path
-        $portfile =~ s{\/Portfile$}{};
+      if ($_ =~ m{$dependency}) {
+        $portfile =~ s{\/Portfile$}{};  # remove trailing '/Portfile'
         print "$portfile\n";
       }
     }

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070409/6fb694d0/attachment.html


More information about the macports-changes mailing list