pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Replaced all instances of "=~ q...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5f3bdc1e8d11
branches:  trunk
changeset: 548657:5f3bdc1e8d11
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Oct 20 10:10:28 2008 +0000

description:
Replaced all instances of "=~ qr" with "=~ m", and all instances of
"!~ qr" with "!~ m", to work around a memory leak in Perl 5.10.0.
(See Perl bug #59994 or just run perl -e 'while(1){qr""}'.)

This change also speeds up pkglint by around 15 percent, although I
noticed that updating from Perl 5.8.8. to 5.10.0 slowed down pkglint by
about 2 percent.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  636 +++++++++++++++++++-------------------
 1 files changed, 318 insertions(+), 318 deletions(-)

diffs (truncated from 2164 to 300 lines):

diff -r 71ca522f3d7b -r 5f3bdc1e8d11 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Mon Oct 20 09:33:36 2008 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Mon Oct 20 10:10:28 2008 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.776 2008/10/18 16:35:59 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.777 2008/10/20 10:10:28 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -907,7 +907,7 @@
        $physlines = [];
 
        for (; $lineno <= $#{$lines}; $lineno++) {
-               if ($lines->[$lineno]->[1] =~ qr"^([ \t]*)(.*?)([ \t]*)(\\?)\n?$") {
+               if ($lines->[$lineno]->[1] =~ m"^([ \t]*)(.*?)([ \t]*)(\\?)\n?$") {
                        my ($indent, $text, $outdent, $cont) = ($1, $2, $3, $4);
 
                        if ($first) {
@@ -966,7 +966,7 @@
                }
        }
 
-       if (0 <= $#{$physlines} && $physlines->[-1]->[1] !~ qr"\n$") {
+       if (0 <= $#{$physlines} && $physlines->[-1]->[1] !~ m"\n$") {
                log_error($fname, $physlines->[-1]->[0], "File must end with a newline.");
        }
 
@@ -991,7 +991,7 @@
        $physline = 0;
 
        for (; $lineno <= $#{$lines}; $lineno++) {
-               if ($lines->[$lineno]->[1] =~ qr"^([ \t]*)(.*?)([ \t]*)(\\?)\n?$") {
+               if ($lines->[$lineno]->[1] =~ m"^([ \t]*)(.*?)([ \t]*)(\\?)\n?$") {
                        my ($indent, $text, $outdent, $cont) = ($1, $2, $3, $4);
                        my (@start) = (@-);
                        my (@end) = (@+);
@@ -1060,7 +1060,7 @@
                }
        }
 
-       if (0 <= $#{$physlines} && $physlines->[-1]->[1] !~ qr"\n$") {
+       if (0 <= $#{$physlines} && $physlines->[-1]->[1] !~ m"\n$") {
                log_error($fname, $physlines->[-1]->[0], "File must end with a newline.");
        }
 
@@ -1357,7 +1357,7 @@
 
        if ($varname eq "SUBST_CLASSES") {
 
-               if ($value =~ qr"^(\S+)\s") {
+               if ($value =~ m"^(\S+)\s") {
                        $line->log_warning("Please add only one class at a time to SUBST_CLASSES.");
                        $self->[SUBST_CLASS] = $1;
                        $self->[SUBST_ID] = $1;
@@ -1374,7 +1374,7 @@
 
        $id = $self->subst_id;
 
-       if ($varname =~ qr"^(SUBST_(?:STAGE|MESSAGE|FILES|SED|VARS|FILTER_CMD))\.([\-\w_]+)$") {
+       if ($varname =~ m"^(SUBST_(?:STAGE|MESSAGE|FILES|SED|VARS|FILTER_CMD))\.([\-\w_]+)$") {
                ($varbase, $varparam) = ($1, $2);
 
                if (!defined($id)) {
@@ -2122,7 +2122,7 @@
 
        if ((my $lines = load_lines($fname, true))) {
                foreach my $line (@{$lines}) {
-                       if ($line->text =~ qr"^(?:#.*|\s*)$") {
+                       if ($line->text =~ m"^(?:#.*|\s*)$") {
                                # ignore empty and comment lines
 
                        } elsif ($line->text =~ re_acl_def) {
@@ -2163,7 +2163,7 @@
        $fname = "${cwd_pkgsrcdir}/mk/defaults/mk.conf";
        if ((my $lines = load_file($fname))) {
                foreach my $line (@{$lines}) {
-                       if ($line->text =~ qr"^#?([\w_]+)\?=") {
+                       if ($line->text =~ m"^#?([\w_]+)\?=") {
                                my ($varname) = ($1);
                                $opt_debug_misc and $line->log_debug("Found user-definable variable ${varname}.");
                                $vartypes->{$varname} = "Userdefined"; # FIXME: type error
@@ -2192,10 +2192,10 @@
 
        $vars = {};
        foreach my $line (@{$lines}) {
-               if ($line->text =~ qr"^#" || $line->text =~ qr"^\s*$") {
+               if ($line->text =~ m"^#" || $line->text =~ m"^\s*$") {
                        # Ignore empty and comment lines.
 
-               } elsif ($line->text =~ qr"^(\S+)\s+(.*)$") {
+               } elsif ($line->text =~ m"^(\S+)\s+(.*)$") {
                        $vars->{$1} = $2;
 
                } else {
@@ -2224,7 +2224,7 @@
        foreach my $line (@{$lines}) {
                my $text = $line->text;
 
-               if ($text =~ qr"^(MASTER_SITE_\w+)\+=\s*\\$"o) {
+               if ($text =~ m"^(MASTER_SITE_\w+)\+=\s*\\$"o) {
                        $varname = $1;
                        $names->{$varname} = true;
                        $ignoring = false;
@@ -2232,7 +2232,7 @@
                } elsif ($text eq "MASTER_SITE_BACKUP?=\t\\") {
                        $ignoring = true;
 
-               } elsif ($text =~ qr"^\t((?:http://|ftp://)\S+/)(?:|\s*\\)$"o) {
+               } elsif ($text =~ m"^\t((?:http://|ftp://)\S+/)(?:|\s*\\)$"o) {
                        if (!$ignoring) {
                                if (defined($varname)) {
                                        $url2name->{$1} = $varname;
@@ -2241,10 +2241,10 @@
                                }
                        }
 
-               } elsif ($text =~ qr"^(?:#.*|\s*)$") {
+               } elsif ($text =~ m"^(?:#.*|\s*)$") {
                        # ignore empty and comment lines
 
-               } elsif ($text =~ qr"BSD_SITES_MK") {
+               } elsif ($text =~ m"BSD_SITES_MK") {
                        # ignore multiple inclusion guards
 
                } else {
@@ -2291,7 +2291,7 @@
 
        $options = {};
        foreach my $line (@{$lines}) {
-               if ($line->text =~ qr"^([-0-9a-z_]+)(?:\s+(.*))?$") {
+               if ($line->text =~ m"^([-0-9a-z_]+)(?:\s+(.*))?$") {
                        my ($optname, $optdescr) = ($1, $2);
 
                        $options->{$optname} = defined($optdescr)
@@ -2329,7 +2329,7 @@
                foreach my $line (@{$lines}) {
                        if ($line->text =~ regex_mk_include) {
                                my (undef, $includefile) = ($1, $2);
-                               if ($includefile =~ qr"^(?:\$\{PKGSRCDIR\}/mk/tools/)?([^/]+)$") {
+                               if ($includefile =~ m"^(?:\$\{PKGSRCDIR\}/mk/tools/)?([^/]+)$") {
                                        push(@tool_files, $1);
                                }
                        }
@@ -2357,18 +2357,18 @@
                foreach my $line (@{$lines}) {
                        if ($line->text =~ regex_varassign) {
                                my ($varname, undef, $value, undef) = ($1, $2, $3, $4);
-                               if ($varname eq "TOOLS_CREATE" && $value =~ qr"^([-\w.]+|\[)$") {
+                               if ($varname eq "TOOLS_CREATE" && $value =~ m"^([-\w.]+|\[)$") {
                                        $tools->{$value} = true;
 
-                               } elsif ($varname =~ qr"^(?:_TOOLS_VARNAME)\.([-\w.]+|\[)$") {
+                               } elsif ($varname =~ m"^(?:_TOOLS_VARNAME)\.([-\w.]+|\[)$") {
                                        $tools->{$1} = true;
                                        $vartools->{$1} = $value;
                                        $varname_to_toolname->{$value} = $1;
 
-                               } elsif ($varname =~ qr"^(?:TOOLS_PATH|_TOOLS_DEPMETHOD)\.([-\w.]+|\[)$") {
+                               } elsif ($varname =~ m"^(?:TOOLS_PATH|_TOOLS_DEPMETHOD)\.([-\w.]+|\[)$") {
                                        $tools->{$1} = true;
 
-                               } elsif ($varname =~ qr"^_TOOLS\.(.*)") {
+                               } elsif ($varname =~ m"^_TOOLS\.(.*)") {
                                        $tools->{$1} = true;
                                        foreach my $tool (split(qr"\s+", $value)) {
                                                $tools->{$tool} = true;
@@ -2413,9 +2413,9 @@
                        } elsif ($text =~ regex_mk_cond) {
                                my ($indent, $cond, $args, $comment) = ($1, $2, $3, $4);
 
-                               if ($cond =~ qr"^(?:if|ifdef|ifndef|for)$") {
+                               if ($cond =~ m"^(?:if|ifdef|ifndef|for)$") {
                                        $cond_depth++;
-                               } elsif ($cond =~ qr"^(?:endif|endfor)$") {
+                               } elsif ($cond =~ m"^(?:endif|endfor)$") {
                                        $cond_depth--;
                                }
                        }
@@ -2531,7 +2531,7 @@
                }
 
                if ($state == 3) {
-                       if ($text =~ qr"^\to\s(\S+)(?:\s*(.+))?$") {
+                       if ($text =~ m"^\to\s(\S+)(?:\s*(.+))?$") {
                                my ($spuname, $comment) = ($1, $2);
                                if ($spuname =~ regex_pkgname) {
                                        push(@{$updates}, [$line, $1, $2, $comment]);
@@ -2635,7 +2635,7 @@
                                my $varname = $line->get("varname");
                                my $value = $line->get("value");
 
-                               if ($varname =~ qr"^[A-Z]\w*_DIRS$" && $value ne "") {
+                               if ($varname =~ m"^[A-Z]\w*_DIRS$" && $value ne "") {
                                        if (exists($dir_to_varname->{$value})) {
                                                # FIXME: misc/xdg-x11-dirs and misc/xdg-dirs conflict.
                                                #$line->log_warning("Duplicate directory, also appears in " . $dir_to_varname->{$value} . ".");
@@ -2659,7 +2659,7 @@
 
                        parseline_mk($line);
                        if ($line->has("is_varassign") && $line->get("varname") eq "DISTNAME") {
-                               if ($line->get("value") =~ qr"^(.*)-dirs-(.*)$") {
+                               if ($line->get("value") =~ m"^(.*)-dirs-(.*)$") {
                                        $dir_to_id->{$pkg} = "$1-$2";
                                } else {
                                        assert(false, "$pkg/Makefile does not define a proper DISTNAME.");
@@ -2735,7 +2735,7 @@
                return false;
        }
        foreach my $entry (@{$entries}) {
-               if ($entry->text =~ qr"^/\Q${basename}\E/") {
+               if ($entry->text =~ m"^/\Q${basename}\E/") {
                        return true;
                }
        }
@@ -2783,31 +2783,31 @@
 
        # Let's assume that everything else that looks like a Makefile
        # is indeed a Makefile.
-       if ($basename =~ qr"^I?[Mm]akefile(?:\..*|)?|.*\.ma?k$") {
+       if ($basename =~ m"^I?[Mm]akefile(?:\..*|)?|.*\.ma?k$") {
                return "make";
        }
 
        # Too many false positives for shell scripts, so configure
        # scripts get their own category.
-       if ($basename =~ qr"^configure(?:|\.ac)$") {
+       if ($basename =~ m"^configure(?:|\.ac)$") {
                $opt_debug_unchecked and $line->log_debug("Skipped check for absolute pathnames.");
                return "configure";
        }
 
-       if ($basename =~ qr"\.(?:sh|m4)$"i) {
+       if ($basename =~ m"\.(?:sh|m4)$"i) {
                return "shell";
        }
 
-       if ($basename =~ qr"\.(?:cc?|cpp|cxx|el|hh?|hpp|l|pl|pm|py|s|t|y)$"i) {
+       if ($basename =~ m"\.(?:cc?|cpp|cxx|el|hh?|hpp|l|pl|pm|py|s|t|y)$"i) {
                return "source";
        }
 
-       if ($basename =~ qr"^.+\.(?:\d+|conf|html|info|man|po|tex|texi|texinfo|txt|xml)$"i) {
+       if ($basename =~ m"^.+\.(?:\d+|conf|html|info|man|po|tex|texi|texinfo|txt|xml)$"i) {
                return "text";
        }
 
        # Filenames without extension are hard to guess right. :(
-       if ($basename !~ qr"\.") {
+       if ($basename !~ m"\.") {
                return "unknown";
        }
 
@@ -2855,7 +2855,7 @@
        $relpath =~ s,\$\{PHPPKGSRCDIR\},../../lang/php5,;
        $relpath =~ s,\$\{SUSE_DIR_PREFIX\},suse91,;
        $relpath =~ s,\$\{PYPKGSRCDIR\},../../lang/python23,;
-       if ($adjust_depth && $relpath =~ qr"^\.\./\.\./([^.].*)$") {
+       if ($adjust_depth && $relpath =~ m"^\.\./\.\./([^.].*)$") {
                $relpath = "${cur_pkgsrcdir}/$1";
        }
        if (defined($pkgdir)) {
@@ -2873,7 +2873,7 @@
 
        my $abs_from = Cwd::abs_path($from);
        my $abs_to = Cwd::abs_path($to);
-       if ($abs_to =~ qr"^\Q$abs_from/\E(.*)$") {
+       if ($abs_to =~ m"^\Q$abs_from/\E(.*)$") {
                return $1;
        } elsif ($abs_to eq $abs_from) {
                return ".";
@@ -2995,25 +2995,25 @@
        while ($text =~ s/^$regex_shellword//) {
                push(@{$words}, $1);
        }
-       return (($text =~ qr"^\s*$") ? $words : false);
+       return (($text =~ m"^\s*$") ? $words : false);
 }
 
 sub varname_base($) {
        my ($varname) = @_;
 
-       return ($varname =~ qr"^(.*?)\..*$") ? $1 : $varname;
+       return ($varname =~ m"^(.*?)\..*$") ? $1 : $varname;
 }
 
 sub varname_canon($) {
        my ($varname) = @_;
 
-       return ($varname =~ qr"^(.*?)\..*$") ? "$1.*" : $varname;
+       return ($varname =~ m"^(.*?)\..*$") ? "$1.*" : $varname;
 }
 
 sub varname_param($) {
        my ($varname) = @_;
 
-       return ($varname =~ qr"^.*?\.(.*)$") ? $2 : undef;
+       return ($varname =~ m"^.*?\.(.*)$") ? $2 : undef;
 }
 



Home | Main Index | Thread Index | Old Index