diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-06-04 20:48:24 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-06-04 20:48:24 +0000 |
commit | beb5d4c590353021cb28a7638fd80a1ff86008b8 (patch) | |
tree | d2e31c5e935917c9440a809c54c0718d4f066d89 | |
parent | 6f6ed493d7fd9e98e980e7b0665b3691bb9c06dd (diff) |
convert the remaining regexps, so that $`, $', $& are completely dead.
Should shave a few % off time and space.
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageName.pm | 38 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgSpec.pm | 34 |
2 files changed, 36 insertions, 36 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageName.pm b/usr.sbin/pkg_add/OpenBSD/PackageName.pm index 3cc4fd561f1..51cfde63517 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageName.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageName.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageName.pm,v 1.29 2007/06/04 14:57:33 espie Exp $ +# $OpenBSD: PackageName.pm,v 1.30 2007/06/04 20:48:23 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -32,9 +32,9 @@ sub url2pkgname($) sub splitname { local $_ = shift; - if (/\-(?=\d)/o) { - my $stem = $`; - my $rest = $'; + if (/^(.*?)\-(\d.*)$/o) { + my $stem = $1; + my $rest = $2; my @all = split /\-/o, $rest; return ($stem, @all); } else { @@ -46,9 +46,9 @@ sub from_string { my $class = shift; local $_ = shift; - if (/\-(?=\d)/o) { - my $stem = $`; - my $rest = $'; + if (/^(.*?)\-(\d.*)$/o) { + my $stem = $1; + my $rest = $2; my @all = split /\-/o, $rest; my $version = OpenBSD::PackageName::version->from_string(shift @all); my %flavors = map {($_,1)} @all; @@ -67,8 +67,8 @@ sub from_string sub splitstem { local $_ = shift; - if (/\-(?=\d)/o) { - return $`; + if (/^(.*?)\-\d/o) { + return $1; } else { return $_; } @@ -88,8 +88,8 @@ sub splitp { local $_ = shift; - if (/^(.*\-\d[^-]*)p(\d+)/o) { - return ($1.$', $2); + if (/^(.*\-\d[^-]*)p(\d+)(.*)$/o) { + return ($1.$3, $2); } else { return ($_,-1); } @@ -101,8 +101,8 @@ sub rebuildp if ($p == -1) { return $pkg; } - if ($pkg =~ m/\-\d[^-]*/o) { - return "$`$&p$p$'"; + if ($pkg =~ m/^(.*?)(\-\d[^-]*)(.*)$/o) { + return "$1$2p$p$3"; } else { return $pkg."p".$p; } @@ -201,13 +201,13 @@ sub from_string my ($class, $string) = @_; my $vnum = -1; my $pnum = -1; - if ($string =~ m/v(\d+)$/o) { - $vnum = $1; - $string = $`; + if ($string =~ m/^(.*)v(\d+)$/o) { + $vnum = $2; + $string = $1; } - if ($string =~ m/p(\d+)$/o) { - $pnum = $1; - $string = $`; + if ($string =~ m/^(.*)p(\d+)$/o) { + $pnum = $2; + $string = $1; } my $o = bless { pnum => $pnum, diff --git a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm index 6c5821bcc0f..d8795327e10 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgSpec.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgSpec.pm,v 1.14 2007/06/04 14:57:33 espie Exp $ +# $OpenBSD: PkgSpec.pm,v 1.15 2007/06/04 20:48:23 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -26,13 +26,13 @@ sub compare_pseudo_numbers my ($n1, $m1); - if ($n =~ m/^\d+/o) { - $n1 = $&; - $n = $'; + if ($n =~ m/^(\d+)(.*)$/o) { + $n1 = $1; + $n = $2; } - if ($m =~ m/^\d+/o) { - $m1 = $&; - $m = $'; + if ($m =~ m/^(\d+)(.*)$/o) { + $m1 = $1; + $m = $2; } if ($n1 == $m1) { @@ -95,8 +95,8 @@ sub check_version # Last chance: dewey specs ? my @deweys = grep !/^\d/o, @specs; for (@deweys) { - if (m/^\<\=|\>\=|\<|\>/o) { - my ($op, $dewey) = ($&, $'); + if (m/^(\<\=|\>\=|\<|\>)(.*)$/o) { + my ($op, $dewey) = ($1, $2); my $compare = dewey_compare($v, $dewey); return 0 if $op eq '<' && $compare >= 0; return 0 if $op eq '<=' && $compare > 0; @@ -116,8 +116,8 @@ sub check_1flavor for (split /\-/o, $spec) { # must not be here - if (m/^\!/o) { - return 0 if $f->{$'}; + if (m/^\!(.*)$/o) { + return 0 if $f->{$1}; # must be here } else { return 0 unless $f->{$_}; @@ -160,11 +160,11 @@ sub subpattern_match # the only constraint is that the actual number # - must start with a digit, # - not contain - or , - if ($p =~ m/\-((?:\>|\>\=|\<|\<\=)?\d[^-]*)/o) { - ($stemspec, $vspec, $flavorspec) = ($`, $1, $'); + if ($p =~ m/^(.*?)\-((?:\>|\>\=|\<|\<\=)?\d[^-]*)(.*)$/o) { + ($stemspec, $vspec, $flavorspec) = ($1, $2, $3); # `any version' matcher - } elsif ($p =~ m/\-\*/o) { - ($stemspec, $vspec, $flavorspec) = ($`, '*', $'); + } elsif ($p =~ m/^(.*?)\-\*(.*)$/o) { + ($stemspec, $vspec, $flavorspec) = ($1, '*', $2); # okay, so no version marker. Assume no flavor spec. } else { ($stemspec, $vspec, $flavorspec) = ($p, '', ''); @@ -189,8 +189,8 @@ sub subpattern_match # Now, have to extract the version number, and the flavor... for (@l) { my ($stem, $v, $flavor); - if (m/\-(\d[^-]*)/o) { - ($stem, $v, $flavor) = ($`, $1, $'); + if (m/^(.*?)\-(\d[^-]*)(.*)$/o) { + ($stem, $v, $flavor) = ($1, $2, $3); if ($stem =~ m/^$stemspec$/ && check_version($v, $vspec) && check_flavor($flavor, $flavorspec)) { |