diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-06-04 18:52:03 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-06-04 18:52:03 +0000 |
commit | 25d82b9da93421ba1710254be1ee6d96ef6a43cc (patch) | |
tree | e3bea7a22d535168f5dc49496ef48fbb8085a8f6 /usr.sbin/pkg_add | |
parent | 4ba67a22ff6df5345311f653ab911fe57b4ea3fc (diff) |
more efficient regexps: anchor stuff at both ends, be more specific in
what matches. Get rid of $`, $', $&, which encur a performance penalty.
(not yet done on PackageName and PkgSpec).
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 30 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm | 10 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 36 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/SharedLibs.pm | 10 | ||||
-rw-r--r-- | usr.sbin/pkg_add/pkg_create | 14 |
5 files changed, 50 insertions, 50 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index 06506a5be69..7e699d3f907 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.40 2007/06/04 14:40:39 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.41 2007/06/04 18:52:02 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -38,22 +38,22 @@ sub _new sub new { my ($class, $baseurl) = @_; - if ($baseurl =~ m/^ftp\:/io) { - return OpenBSD::PackageRepository::FTP->_new($'); - } elsif ($baseurl =~ m/^http\:/io) { - return OpenBSD::PackageRepository::HTTP->_new($'); - } elsif ($baseurl =~ m/^scp\:/io) { + if ($baseurl =~ m/^ftp\:(.*)$/io) { + return OpenBSD::PackageRepository::FTP->_new($1); + } elsif ($baseurl =~ m/^http\:(.*)$/io) { + return OpenBSD::PackageRepository::HTTP->_new($1); + } elsif ($baseurl =~ m/^scp\:(.*)$/io) { require OpenBSD::PackageRepository::SCP; - return OpenBSD::PackageRepository::SCP->_new($'); - } elsif ($baseurl =~ m/^src\:/io) { + return OpenBSD::PackageRepository::SCP->_new($1); + } elsif ($baseurl =~ m/^src\:(.*)$/io) { require OpenBSD::PackageRepository::Source; - return OpenBSD::PackageRepository::Source->_new($'); - } elsif ($baseurl =~ m/^file\:/io) { - return OpenBSD::PackageRepository::Local->_new($'); - } elsif ($baseurl =~ m/^inst\:/io) { - return OpenBSD::PackageRepository::Installed->_new($'); + return OpenBSD::PackageRepository::Source->_new($1); + } elsif ($baseurl =~ m/^file\:(.*)$/io) { + return OpenBSD::PackageRepository::Local->_new($1); + } elsif ($baseurl =~ m/^inst\:(.*)$/io) { + return OpenBSD::PackageRepository::Installed->_new($1); } else { return OpenBSD::PackageRepository::Local->_new($baseurl); } @@ -473,8 +473,8 @@ sub _new { my ($class, $baseurl) = @_; my $distant_host; - if ($baseurl =~ m/^\/\/(.*?)\//io) { - $distant_host = $&; + if ($baseurl =~ m/^(\/\/.*?\/)/io) { + $distant_host = $1; } bless { baseurl => $baseurl, key => $distant_host }, $class; } diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm index aa2190c3464..1a118221eb0 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/SCP.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SCP.pm,v 1.14 2007/06/04 14:40:39 espie Exp $ +# $OpenBSD: SCP.pm,v 1.15 2007/06/04 18:52:02 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org> # @@ -217,8 +217,8 @@ sub abort_batch() local $_; while (<STDIN>) { chomp; - if (m/^LIST\s+/o) { - my $dname = $'; + if (m/^LIST\s+(.*)$/o) { + my $dname = $1; batch(sub { my $d; if (opendir($d, $dname)) { @@ -235,8 +235,8 @@ while (<STDIN>) { print "\n"; closedir($d); }); - } elsif (m/^GET\s+/o) { - my $fname = $'; + } elsif (m/^GET\s+(.*)$/o) { + my $fname = $1; batch(sub { if (open(my $fh, '<', $fname)) { my $size = (stat $fh)[7]; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 01c2a546262..28ab7dcbbc5 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.131 2007/06/04 16:13:30 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.132 2007/06/04 18:52:02 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -205,8 +205,8 @@ sub dirclass() { undef } sub new { my ($class, $args) = @_; - if ($args =~ m|/+$|o and defined $class->dirclass) { - bless { name => $` }, $class->dirclass; + if ($args =~ m/^(.*?)\/+$/o and defined $class->dirclass) { + bless { name => $1 }, $class->dirclass; } else { bless { name => $args }, $class; } @@ -813,28 +813,28 @@ sub check my ($name, $passwd, $uid, $gid, $quota, $class, $gcos, $dir, $shell, $expire) = getpwnam($self->{name}); return unless defined $name; - if ($self->{uid} =~ m/^\!/o) { - return 0 unless $uid == $'; + if ($self->{uid} =~ m/^\!(.*)$/o) { + return 0 unless $uid == $1; } - if ($self->{group} =~ m/^\!/o) { - my $g = $'; - unless ($g =~ m/^\d+/o) { + if ($self->{group} =~ m/^\!(.*)$/o) { + my $g = $1; + unless ($g =~ m/^\d+$/o) { $g = getgrnam($g); return 0 unless defined $g; } return 0 unless $gid eq $g; } - if ($self->{class} =~ m/^\!/o) { - return 0 unless $class eq $'; + if ($self->{class} =~ m/^\!(.*)$/o) { + return 0 unless $class eq $1; } - if ($self->{comment} =~ m/^\!/o) { - return 0 unless $gcos eq $'; + if ($self->{comment} =~ m/^\!(.*)$/o) { + return 0 unless $gcos eq $1; } - if ($self->{home} =~ m/^\!/o) { - return 0 unless $dir eq $'; + if ($self->{home} =~ m/^\!(.*)$/o) { + return 0 unless $dir eq $1; } - if ($self->{shell} =~ m/^\!/o) { - return 0 unless $shell eq $'; + if ($self->{shell} =~ m/^\!(.*)$/o) { + return 0 unless $shell eq $1; } return 1; } @@ -868,8 +868,8 @@ sub check my $self = shift; my ($name, $passwd, $gid, $members) = getgrnam($self->{name}); return unless defined $name; - if ($self->{gid} =~ m/^\!/o) { - return 0 unless $gid == $'; + if ($self->{gid} =~ m/^\!(.*)$/o) { + return 0 unless $gid == $1; } return 1; } diff --git a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm index f8aac9aca77..3d47439b391 100644 --- a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm +++ b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: SharedLibs.pm,v 1.21 2007/06/04 17:00:45 espie Exp $ +# $OpenBSD: SharedLibs.pm,v 1.22 2007/06/04 18:52:02 espie Exp $ # # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> # @@ -163,8 +163,8 @@ sub lookup_libspec { my ($base, $libspec) = @_; - if ($libspec =~ m|(.*)/|o) { - return _lookup_libspec("$base/$1", $'); + if ($libspec =~ m/^(.*)\/([^\/]+)$/o) { + return _lookup_libspec("$base/$1", $2); } else { return _lookup_libspec("$base/lib", $libspec); } @@ -215,8 +215,8 @@ sub report_problem { my ($base, $libspec) = @_; - if ($libspec =~ m|(.*)/|o) { - return _report_problem("$base/$1", $'); + if ($libspec =~ m/^(.*)\/([^\/]+)$/o) { + return _report_problem("$base/$1", $2); } else { return _report_problem("$base/lib", $libspec); } diff --git a/usr.sbin/pkg_add/pkg_create b/usr.sbin/pkg_add/pkg_create index 05cb57b3f1d..e09001228eb 100644 --- a/usr.sbin/pkg_add/pkg_create +++ b/usr.sbin/pkg_add/pkg_create @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: pkg_create,v 1.112 2007/06/04 16:33:22 espie Exp $ +# $OpenBSD: pkg_create,v 1.113 2007/06/04 18:52:01 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -445,14 +445,14 @@ sub add_description if (defined $comment) { print $fh dosubst($comment), "\n"; } else { - if ($opt_c =~ /^\-/o) { - print $fh $', "\n"; + if ($opt_c =~ /^\-(.*)$/o) { + print $fh $1, "\n"; } else { copy_subst_fh($opt_c, $fh); } } - if ($opt_d =~ /^\-/o) { - print $fh $', "\n"; + if ($opt_d =~ /^\-(.*)$/o) { + print $fh $1, "\n"; } else { copy_subst_fh($opt_d, $fh); } @@ -485,8 +485,8 @@ try { {'D' => sub { local $_ = shift; - if (m/\=/o) { - my ($k, $v) = ($`,$'); + if (m/^([^=]+)\=(.*)$/o) { + my ($k, $v) = ($1, $2); $v =~ s/^\'(.*)\'$/$1/; $v =~ s/^\"(.*)\"$/$1/; $defines{$k} = $v; |