summaryrefslogtreecommitdiff
path: root/usr.bin/libtool/LT
diff options
context:
space:
mode:
authorafresh1 <afresh1@cvs.openbsd.org>2014-03-19 02:16:23 +0000
committerafresh1 <afresh1@cvs.openbsd.org>2014-03-19 02:16:23 +0000
commited658646e3da3340c91c30eba4db1d2ea7feb85e (patch)
treef42733eb9f0ffd443ecff1c06ec3870102e365be /usr.bin/libtool/LT
parent58dbdb80c90c24a6f8cda6950f3a3bfc49a24b01 (diff)
Remove lexical $_ from libtool in preparation for perl 5.18
OK and additional changes from espie@
Diffstat (limited to 'usr.bin/libtool/LT')
-rw-r--r--usr.bin/libtool/LT/Getopt.pm74
-rw-r--r--usr.bin/libtool/LT/LaLoFile.pm15
-rw-r--r--usr.bin/libtool/LT/Library.pm8
-rw-r--r--usr.bin/libtool/LT/Mode/Install.pm10
-rw-r--r--usr.bin/libtool/LT/Mode/Link.pm110
5 files changed, 108 insertions, 109 deletions
diff --git a/usr.bin/libtool/LT/Getopt.pm b/usr.bin/libtool/LT/Getopt.pm
index a2a8a7d602c..77810ecf2dc 100644
--- a/usr.bin/libtool/LT/Getopt.pm
+++ b/usr.bin/libtool/LT/Getopt.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Getopt.pm,v 1.11 2012/07/12 12:20:06 espie Exp $
+# $OpenBSD: Getopt.pm,v 1.12 2014/03/19 02:16:22 afresh1 Exp $
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
#
@@ -21,20 +21,20 @@ use warnings;
package Option;
sub factory
{
- my ($class, $_) = @_;
- if (m/^(.)$/) {
+ my ($class, $o) = @_;
+ if ($o =~ m/^(.)$/) {
return Option::Short->new($1);
- } elsif (m/^(.)\:$/) {
+ } elsif ($o =~ m/^(.)\:$/) {
return Option::ShortArg->new($1);
- } elsif (m/^(\-?.)(?:\:\!|\!\:)$/) {
+ } elsif ($o =~ m/^(\-?.)(?:\:\!|\!\:)$/) {
return Option::LongArg0->new($1);
- } elsif (m/^(\-?.)\!$/) {
+ } elsif ($o =~ m/^(\-?.)\!$/) {
return Option::Long->new($1);
- } elsif (m/^(\-?.*)\=$/) {
+ } elsif ($o =~ m/^(\-?.*)\=$/) {
return Option::LongArg->new($1);
- } elsif (m/^(\-?.*)\:$/) {
+ } elsif ($o =~ m/^(\-?.*)\:$/) {
return Option::LongArg0->new($1);
- } elsif (m/^(\-?.*)$/) {
+ } elsif ($o =~ m/^(\-?.*)$/) {
return Option::Long->new($1);
}
}
@@ -57,12 +57,12 @@ our @ISA = qw(Option);
sub match
{
- my ($self, $_, $opts, $canonical, $code) = @_;
- if (m/^\-\Q$$self\E$/) {
- &$code($opts, $canonical, 1, $_);
+ my ($self, $arg, $opts, $canonical, $code) = @_;
+ if ($arg =~ m/^\-\Q$$self\E$/) {
+ &$code($opts, $canonical, 1, $arg);
return 1;
}
- if (m/^(\-\Q$$self\E)(.*)$/) {
+ if ($arg =~ m/^(\-\Q$$self\E)(.*)$/) {
unshift(@main::ARGV, "-$2");
&$code($opts, $canonical, 1, $1);
return 1;
@@ -75,12 +75,12 @@ our @ISA = qw(Option::Short);
sub match
{
- my ($self, $_, $opts, $canonical, $code) = @_;
- if (m/^\-\Q$$self\E$/) {
- &$code($opts, $canonical, (shift @main::ARGV), $_);
+ my ($self, $arg, $opts, $canonical, $code) = @_;
+ if ($arg =~ m/^\-\Q$$self\E$/) {
+ &$code($opts, $canonical, (shift @main::ARGV), $arg);
return 1;
}
- if (m/^(\-\Q$$self\E)(.*)$/) {
+ if ($arg =~ m/^(\-\Q$$self\E)(.*)$/) {
&$code($opts, $canonical, $2, $1);
return 1;
}
@@ -92,9 +92,9 @@ our @ISA = qw(Option);
sub match
{
- my ($self, $_, $opts, $canonical, $code) = @_;
- if (m/^\-\Q$$self\E$/) {
- &$code($opts, $canonical, 1, $_);
+ my ($self, $arg, $opts, $canonical, $code) = @_;
+ if ($arg =~ m/^\-\Q$$self\E$/) {
+ &$code($opts, $canonical, 1, $arg);
return 1;
}
return 0;
@@ -104,10 +104,10 @@ package Option::LongArg0;
our @ISA = qw(Option::Long);
sub match
{
- my ($self, $_, $opts, $canonical, $code) = @_;
- if (m/^\-\Q$$self\E$/) {
+ my ($self, $arg, $opts, $canonical, $code) = @_;
+ if ($arg =~ m/^\-\Q$$self\E$/) {
if (@main::ARGV > 0) {
- &$code($opts, $canonical, (shift @main::ARGV), $_);
+ &$code($opts, $canonical, (shift @main::ARGV), $arg);
return 1;
} else {
die "Missing argument for option -$$self\n";
@@ -121,11 +121,11 @@ our @ISA = qw(Option::LongArg0);
sub match
{
- my ($self, $_, $opts, $canonical, $code) = @_;
- if ($self->SUPER::match($_, $opts, $canonical, $code)) {
+ my ($self, $arg, $opts, $canonical, $code) = @_;
+ if ($self->SUPER::match($arg, $opts, $canonical, $code)) {
return 1;
}
- if (m/^(-\Q$$self\E)\=(.*)$/) {
+ if ($arg =~ m/^(-\Q$$self\E)\=(.*)$/) {
&$code($opts, $canonical, $2, $1);
return 1;
}
@@ -260,19 +260,19 @@ sub handle_options
MAINLOOP:
while (@main::ARGV > 0) {
- my $_ = shift @main::ARGV;
- if (m/^\-\-$/) {
+ my $arg = shift @main::ARGV;
+ if ($arg =~ m/^\-\-$/) {
last;
}
- if (m/^\-/) {
+ if ($arg =~ m/^\-/) {
for my $opt (@options) {
- if ($opt->match($_, $self)) {
+ if ($opt->match($arg, $self)) {
next MAINLOOP;
}
}
- shortdie "Unknown option $_\n";
+ shortdie "Unknown option $arg\n";
} else {
- unshift(@main::ARGV, $_);
+ unshift(@main::ARGV, $arg);
last;
}
}
@@ -288,18 +288,18 @@ sub handle_permuted_options
MAINLOOP2:
while (@main::ARGV > 0) {
- my $_ = shift @main::ARGV;
- if (m/^\-\-$/) {
+ my $arg = shift @main::ARGV;
+ if ($arg =~ m/^\-\-$/) {
next; # XXX ?
}
- if (m/^\-/) {
+ if ($arg =~ m/^\-/) {
for my $opt (@options) {
- if ($opt->match($_, $self)) {
+ if ($opt->match($arg, $self)) {
next MAINLOOP2;
}
}
}
- $self->keep_for_later($_);
+ $self->keep_for_later($arg);
}
@main::ARGV = @{$self->{kept}};
}
diff --git a/usr.bin/libtool/LT/LaLoFile.pm b/usr.bin/libtool/LT/LaLoFile.pm
index 5a41b00595a..493ec67ed39 100644
--- a/usr.bin/libtool/LT/LaLoFile.pm
+++ b/usr.bin/libtool/LT/LaLoFile.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: LaLoFile.pm,v 1.3 2012/07/06 11:30:41 espie Exp $
+# $OpenBSD: LaLoFile.pm,v 1.4 2014/03/19 02:16:22 afresh1 Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -48,14 +48,13 @@ sub read
my ($class, $filename) = @_;
my $info = $class->new;
open(my $fh, '<', $filename) or die "Cannot read $filename: $!\n";
- my $_;
- while (<$fh>) {
- chomp;
- next if /^\#/;
- next if /^\s*$/;
- if (m/^(\S+)\=\'(.*)\'$/) {
+ while (my $line = <$fh>) {
+ chomp($line);
+ next if $line =~ /^\#/;
+ next if $line =~ /^\s*$/;
+ if ($line =~ m/^(\S+)\=\'(.*)\'$/) {
$info->set($1, $2);
- } elsif (m/^(\S+)\=(\S+)$/) {
+ } elsif ($line =~ m/^(\S+)\=(\S+)$/) {
$info->set($1, $2);
}
}
diff --git a/usr.bin/libtool/LT/Library.pm b/usr.bin/libtool/LT/Library.pm
index 40661426d69..18f4bf9409b 100644
--- a/usr.bin/libtool/LT/Library.pm
+++ b/usr.bin/libtool/LT/Library.pm
@@ -1,4 +1,4 @@
-# $OpenBSD: Library.pm,v 1.8 2012/07/13 11:56:12 espie Exp $
+# $OpenBSD: Library.pm,v 1.9 2014/03/19 02:16:22 afresh1 Exp $
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -154,11 +154,11 @@ sub findbest
my $best = undef;
if (opendir(my $dir, $sd)) {
my ($major, $minor) = (-1, -1);
- while (my $_ = readdir($dir)) {
- next unless m/^lib\Q$name\E\.so\.(\d+)\.(\d+)$/;
+ while (my $e = readdir($dir)) {
+ next unless $e =~ m/^lib\Q$name\E\.so\.(\d+)\.(\d+)$/;
if ($1 > $major || ($1 == $major && $2 > $minor)) {
($major, $minor) = ($1, $2);
- $best = "$sd/$_";
+ $best = "$sd/$e";
}
}
closedir($dir);
diff --git a/usr.bin/libtool/LT/Mode/Install.pm b/usr.bin/libtool/LT/Mode/Install.pm
index 685846f84be..215d30379a1 100644
--- a/usr.bin/libtool/LT/Mode/Install.pm
+++ b/usr.bin/libtool/LT/Mode/Install.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Install.pm,v 1.6 2014/03/06 08:58:43 ajacoutot Exp $
+# $OpenBSD: Install.pm,v 1.7 2014/03/19 02:16:22 afresh1 Exp $
#
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -101,12 +101,12 @@ sub is_wrapper
my $program = shift;
open(my $pw, '<', $program) or die "Cannot open $program: $!\n";
- my $_ = <$pw>;
+ my $line = <$pw>;
# if the first line isn't a shell, don't even bother
- return 0 unless m/^\#\!/;
+ return 0 unless $line =~ m/^\#\!/;
my $i = 0;
- while (<$pw>) {
- return 1 if m/wrapper\sfor/;
+ while (my $line = <$pw>) {
+ return 1 if $line =~ m/wrapper\sfor/;
last if $i++ > 10;
}
return 0;
diff --git a/usr.bin/libtool/LT/Mode/Link.pm b/usr.bin/libtool/LT/Mode/Link.pm
index e6d889c6410..e999faa2890 100644
--- a/usr.bin/libtool/LT/Mode/Link.pm
+++ b/usr.bin/libtool/LT/Mode/Link.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Link.pm,v 1.24 2013/01/10 21:34:29 millert Exp $
+# $OpenBSD: Link.pm,v 1.25 2014/03/19 02:16:22 afresh1 Exp $
#
# Copyright (c) 2007-2010 Steven Mestdagh <steven@openbsd.org>
# Copyright (c) 2012 Marc Espie <espie@openbsd.org>
@@ -472,15 +472,15 @@ sub internal_resolve_la
$level //= 0;
tsay {"resolve level: $level"};
$o->{pthread} = 0;
- foreach my $_ (@$args) {
- if ($_ eq '-pthread') {
+ foreach my $arg (@$args) {
+ if ($arg eq '-pthread') {
$o->{pthread}++;
next;
}
- push(@{$o->{result}}, $_);
- next unless m/\.la$/;
+ push(@{$o->{result}}, $arg);
+ next unless $arg =~ m/\.la$/;
require LT::LaFile;
- my $lainfo = LT::LaFile->parse($_);
+ my $lainfo = LT::LaFile->parse($arg);
if (!exists $lainfo->{cached}) {
$self->build_cache($lainfo, $level+1);
}
@@ -537,33 +537,33 @@ sub internal_parse_linkargs1
my $result = $self->{result};
# first read all directories where we can search libraries
- foreach my $_ (@$args) {
- if (m/^-L(.*)/) {
+ foreach my $arg (@$args) {
+ if ($arg =~ m/^-L(.*)/) {
if (!exists $dirs->{$1}) {
$dirs->{$1} = 1;
- tsay {" adding $_ to deplibs"}
+ tsay {" adding $arg to deplibs"}
if $level == 0;
- push @$deplibs, $_;
+ push(@$deplibs, $arg);
}
}
}
- foreach my $_ (@$args) {
- tsay {" processing $_"};
- if (!$_ || $_ eq '' || m/^\s+$/) {
+ foreach my $arg (@$args) {
+ tsay {" processing $arg"};
+ if (!$arg || $arg eq '' || $arg =~ m/^\s+$/) {
# skip empty arguments
- } elsif (m/^-Wc,(.*)/) {
+ } elsif ($arg =~ m/^-Wc,(.*)/) {
push(@$result, $1);
- } elsif ($_ eq '-Xcompiler') {
+ } elsif ($arg eq '-Xcompiler') {
next;
- } elsif ($_ eq '-pthread') {
+ } elsif ($arg eq '-pthread') {
$self->{pthread} = 1;
- } elsif (m/^-L(.*)/) {
+ } elsif ($arg =~ m/^-L(.*)/) {
# already read earlier, do nothing
- } elsif (m/^-R(.*)/) {
+ } elsif ($arg =~ m/^-R(.*)/) {
# -R options originating from .la resolution
# those from @ARGV are in @Ropts
$gp->add_R($1);
- } elsif (m/^-l(\S+)/) {
+ } elsif ($arg =~ m/^-l(\S+)/) {
my @largs = ();
my $key = $1;
if (!exists $libs->{$key}) {
@@ -575,8 +575,8 @@ sub internal_parse_linkargs1
my $absla = abs_path($lafile);
tsay {" adding $absla to deplibs"}
if $level == 0;
- push @$deplibs, $absla;
- push @$result, $lafile;
+ push(@$deplibs, $absla);
+ push(@$result, $lafile);
next;
} else {
$libs->{$key}->resolve_library($dirs, 1, 0, 'notyet', $gp);
@@ -589,21 +589,21 @@ sub internal_parse_linkargs1
}
}
}
- tsay {" adding $_ to deplibs"} if $level == 0;
- push @$deplibs, $_;
- push(@$result, $_);
+ tsay {" adding $arg to deplibs"} if $level == 0;
+ push(@$deplibs, $arg);
+ push(@$result, $arg);
my $dummy = []; # no need to add deplibs recursively
$self->internal_parse_linkargs1($dummy, $gp, $dirs,
$libs, \@largs, $level+1) if @largs;
- } elsif (m/(\S+\/)*(\S+)\.a$/) {
+ } elsif ($arg =~ m/(\S+\/)*(\S+)\.a$/) {
(my $key = $2) =~ s/^lib//;
- $dirs->{abs_dir($_)} = 1;
- $libs->create($key)->{fullpath} = $_;
- push(@$result, $_);
- } elsif (m/(\S+\/)*(\S+)\.la$/) {
+ $dirs->{abs_dir($arg)} = 1;
+ $libs->create($key)->{fullpath} = $arg;
+ push(@$result, $arg);
+ } elsif ($arg =~ m/(\S+\/)*(\S+)\.la$/) {
(my $key = $2) =~ s/^lib//;
- $dirs->{abs_dir($_)} = 1;
- my $fulla = abs_path($_);
+ $dirs->{abs_dir($arg)} = 1;
+ my $fulla = abs_path($arg);
require LT::LaFile;
my $lainfo = LT::LaFile->parse($fulla);
my $dlname = $lainfo->{dlname};
@@ -614,17 +614,17 @@ sub internal_parse_linkargs1
$libs->create($key)->{lafile} = $fulla;
}
}
- push(@$result, $_);
+ push(@$result, $arg);
push(@$deplibs, $fulla) if $libdir ne '';
- } elsif (m/(\S+\/)*(\S+)\.so(\.\d+){2}/) {
+ } elsif ($arg =~ m/(\S+\/)*(\S+)\.so(\.\d+){2}/) {
(my $key = $2) =~ s/^lib//;
- $dirs->{abs_dir($_)} = 1;
+ $dirs->{abs_dir($arg)} = 1;
$libs->create($key);
# not really normal argument
# -lfoo should be used instead, so convert it
push(@$result, "-l$key");
} else {
- push(@$result, $_);
+ push(@$result, $arg);
}
}
}
@@ -658,54 +658,54 @@ sub parse_linkargs2
tsay {" args: @{$self->{args}}"};
my $result = [];
- foreach my $_ (@{$self->{args}}) {
- tsay {" processing $_"};
- if (!$_ || $_ eq '' || m/^\s+$/) {
+ foreach my $arg (@{$self->{args}}) {
+ tsay {" processing $arg"};
+ if (!$arg || $arg eq '' || $arg =~ m/^\s+$/) {
# skip empty arguments
- } elsif ($_ eq '-lc') {
+ } elsif ($arg eq '-lc') {
# don't link explicitly with libc (just remove -lc)
- } elsif ($_ eq '-pthread') {
+ } elsif ($arg eq '-pthread') {
$self->{pthread} = 1;
- } elsif (m/^-L(.*)/) {
+ } elsif ($arg =~ m/^-L(.*)/) {
if (!exists $dirs->{$1}) {
$dirs->{$1} = 1;
}
- } elsif (m/^-R(.*)/) {
+ } elsif ($arg =~ m/^-R(.*)/) {
# -R options originating from .la resolution
# those from @ARGV are in @Ropts
$gp->add_R($1);
- } elsif (m/^-l(.*)/) {
+ } elsif ($arg =~ m/^-l(.*)/) {
my @largs = ();
my $key = $1;
$libs->create($key);
- push @$orderedlibs, $key;
- } elsif (m/(\S+\/)*(\S+)\.a$/) {
+ push(@$orderedlibs, $key);
+ } elsif ($arg =~ m/(\S+\/)*(\S+)\.a$/) {
(my $key = $2) =~ s/^lib//;
- $libs->create($key)->{fullpath} = $_;
- push(@$staticlibs, $_);
- } elsif (m/(\S+\/)*(\S+)\.la$/) {
+ $libs->create($key)->{fullpath} = $arg;
+ push(@$staticlibs, $arg);
+ } elsif ($arg =~ m/(\S+\/)*(\S+)\.la$/) {
(my $key = $2) =~ s/^lib//;
- my $d = abs_dir($_);
+ my $d = abs_dir($arg);
$dirs->{$d} = 1;
- my $fulla = abs_path($_);
+ my $fulla = abs_path($arg);
require LT::LaFile;
my $lainfo = LT::LaFile->parse($fulla);
my $dlname = $lainfo->stringize('dlname');
my $oldlib = $lainfo->stringize('old_library');
my $installed = $lainfo->stringize('installed');
if ($dlname ne '' && $installed eq 'no') {
- tsay {"seen uninstalled la shared in $_"};
+ tsay {"seen uninstalled la shared in $arg"};
$self->{seen_la_shared} = 1;
}
if ($dlname eq '' && -f "$d/$ltdir/$oldlib") {
- push @$staticlibs, "$d/$ltdir/$oldlib";
+ push(@$staticlibs, "$d/$ltdir/$oldlib");
} else {
if (!exists $libs->{$key}) {
$libs->create($key)->{lafile} = $fulla;
}
- push @$orderedlibs, $key;
+ push(@$orderedlibs, $key);
}
- } elsif (m/^-Wl,(\S+)$/) {
+ } elsif ($arg =~ m/^-Wl,(\S+)$/) {
# libtool accepts a list of -Wl options separated
# by commas, and possibly with a trailing comma
# which is not accepted by the linker
@@ -714,7 +714,7 @@ sub parse_linkargs2
push(@$result, "-Wl,$f");
}
} else {
- push(@$result, $_);
+ push(@$result, $arg);
}
}
tsay {"end parse_linkargs2"};