On Sun, Mar 16, 2014 at 06:45:31PM -0700, Andrew Fresh wrote: > Lexical $_ (my $_) has been made experimental in perl 5.18 which causes > warnings where used. This makes usr.bin/libtool stop using them. > > http://perldoc.perl.org/perldiag.html#Use-of-my-$_-is-experimental > > Also standardizes on using parenthesis for push in the subs where it was > common. Even though it makes my eyes hurt.
Try this again, just fixing the missed chomp in LaLoFile.pm l8rZ, -- andrew - http://afresh1.com Speed matters. Almost as much as some things, and nowhere near as much as others. -- Nick Holland Index: usr.bin/libtool//libtool =================================================================== RCS file: /cvs/src/usr.bin/libtool/libtool,v retrieving revision 1.41 diff -u -p -u -r1.41 libtool --- usr.bin/libtool//libtool 6 Mar 2014 08:58:43 -0000 1.41 +++ usr.bin/libtool//libtool 18 Mar 2014 00:28:08 -0000 @@ -30,9 +30,9 @@ use LT::Getopt; $SIG{__DIE__} = sub { require Carp; - my $_ = pop @_; - s/(.*)( at .*? line .*?\n$)/$1/s; - push @_, $_; + my $message = pop @_; + $message =~ s/(.*)( at .*? line .*?\n$)/$1/s; + push @_, $message; die &Carp::longmess; }; Index: usr.bin/libtool//LT/Getopt.pm =================================================================== RCS file: /cvs/src/usr.bin/libtool/LT/Getopt.pm,v retrieving revision 1.11 diff -u -p -u -r1.11 Getopt.pm --- usr.bin/libtool//LT/Getopt.pm 12 Jul 2012 12:20:06 -0000 1.11 +++ usr.bin/libtool//LT/Getopt.pm 18 Mar 2014 00:28:08 -0000 @@ -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}}; } Index: usr.bin/libtool//LT/LaLoFile.pm =================================================================== RCS file: /cvs/src/usr.bin/libtool/LT/LaLoFile.pm,v retrieving revision 1.3 diff -u -p -u -r1.3 LaLoFile.pm --- usr.bin/libtool//LT/LaLoFile.pm 6 Jul 2012 11:30:41 -0000 1.3 +++ usr.bin/libtool//LT/LaLoFile.pm 18 Mar 2014 00:28:08 -0000 @@ -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); } } Index: usr.bin/libtool//LT/Library.pm =================================================================== RCS file: /cvs/src/usr.bin/libtool/LT/Library.pm,v retrieving revision 1.8 diff -u -p -u -r1.8 Library.pm --- usr.bin/libtool//LT/Library.pm 13 Jul 2012 11:56:12 -0000 1.8 +++ usr.bin/libtool//LT/Library.pm 18 Mar 2014 00:28:08 -0000 @@ -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); Index: usr.bin/libtool//LT/Mode/Install.pm =================================================================== RCS file: /cvs/src/usr.bin/libtool/LT/Mode/Install.pm,v retrieving revision 1.6 diff -u -p -u -r1.6 Install.pm --- usr.bin/libtool//LT/Mode/Install.pm 6 Mar 2014 08:58:43 -0000 1.6 +++ usr.bin/libtool//LT/Mode/Install.pm 18 Mar 2014 00:28:08 -0000 @@ -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; Index: usr.bin/libtool//LT/Mode/Link.pm =================================================================== RCS file: /cvs/src/usr.bin/libtool/LT/Mode/Link.pm,v retrieving revision 1.24 diff -u -p -u -r1.24 Link.pm --- usr.bin/libtool//LT/Mode/Link.pm 10 Jan 2013 21:34:29 -0000 1.24 +++ usr.bin/libtool//LT/Mode/Link.pm 18 Mar 2014 00:28:08 -0000 @@ -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"};