diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2014-03-21 10:59:32 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2014-03-21 10:59:32 +0000 |
commit | 802e810578a35c3d8c825f50b0713532a985c6a9 (patch) | |
tree | 2a838a5735163c0a06858a8f4361a52389580e46 /libexec | |
parent | bcea688c4d8cf05ab06c792694112c2f48d85143 (diff) |
fix "my $_" issues in preparation for perl 5.18
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis.pm | 35 | ||||
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis/Check.pm | 8 | ||||
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis/Find.pm | 16 | ||||
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm | 20 | ||||
-rw-r--r-- | libexec/makewhatis/OpenBSD/Makewhatis/Unformated.pm | 62 |
5 files changed, 72 insertions, 69 deletions
diff --git a/libexec/makewhatis/OpenBSD/Makewhatis.pm b/libexec/makewhatis/OpenBSD/Makewhatis.pm index 2fd026b9c7b..82ed463f3c1 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Makewhatis.pm,v 1.13 2014/03/21 10:58:46 espie Exp $ +# $OpenBSD: Makewhatis.pm,v 1.14 2014/03/21 10:59:31 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -51,11 +51,11 @@ sub f if (@_ == 0) { return ''; } - my ($_, @l) = @_; + my ($fmt, @l) = @_; # make it so that #0 is # unshift(@l, '#'); - s/\#(\d+)/$l[$1]/ge; - return $_; + $fmt =~ s/\#(\d+)/$l[$1]/ge; + return $fmt; } sub picky @@ -94,31 +94,32 @@ sub scan_manpages require OpenBSD::Makewhatis::Subject; my $h = OpenBSD::Makewhatis::SubjectHandler->new($p); - for my $_ (@$list) { + for my $filename (@$list) { my $file; - if (m/\.(?:Z|gz)$/) { - unless (open $file, '-|', "gzip", "-fdc", $_) { + if ($filename =~ m/\.(?:Z|gz)$/) { + unless (open $file, '-|', "gzip", "-fdc", $filename) { $p->errsay("#1: can't decompress #2: #3", - $0, $_, $!); + $0, $filename, $!); next; } - $_ = $`; + $filename = $`; } else { - if (-z $_) { - $p->errsay("Empty file #1", $_); + if (-z $filename) { + $p->errsay("Empty file #1", $filename); next; } - unless (open $file, '<', $_) { - $p->errsay("#1: can't read #2: #3", $0, $_, $!); + unless (open $file, '<', $filename) { + $p->errsay("#1: can't read #2: #3", $0, + $filename, $!); next; } } - $h->set_filename($_); - if (m/\.(?:[1-9ln][^.]*|tbl)$/) { + $h->set_filename($filename); + if ($filename =~ m/\.(?:[1-9ln][^.]*|tbl)$/) { require OpenBSD::Makewhatis::Unformated; OpenBSD::Makewhatis::Unformated::handle($file, $h); - } elsif (m/\.0$/) { + } elsif ($filename =~ m/\.0$/) { require OpenBSD::Makewhatis::Formated; OpenBSD::Makewhatis::Formated::handle($file, $h); @@ -134,7 +135,7 @@ sub scan_manpages $h); } } else { - $p->errsay("Can't find type of #1", $_); + $p->errsay("Can't find type of #1", $filename); next; } } diff --git a/libexec/makewhatis/OpenBSD/Makewhatis/Check.pm b/libexec/makewhatis/OpenBSD/Makewhatis/Check.pm index 7bdaefca6c9..15ed522d754 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis/Check.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis/Check.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Check.pm,v 1.3 2010/07/09 08:12:49 espie Exp $ +# $OpenBSD: Check.pm,v 1.4 2014/03/21 10:59:31 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -48,8 +48,8 @@ sub found # sense, e.g., is there a man page around. sub verify_subject { - my ($_, $filename, $p) = @_; - if (m/\s*(.*?)\s*\((.*?)\)\s-\s/) { + my ($s, $filename, $p) = @_; + if ($s =~ m/\s*(.*?)\s*\((.*?)\)\s-\s/) { my $man = $1; my $section = $2; my @mans = split(/\s*,\s*|\s+/, $man); @@ -75,7 +75,7 @@ sub verify_subject } if (@notfound > 0) { $p->errsay("Couldn't find #1 in #2:\n#3", - join(', ', @notfound), $filename, $_); + join(', ', @notfound), $filename, $s); } } } diff --git a/libexec/makewhatis/OpenBSD/Makewhatis/Find.pm b/libexec/makewhatis/OpenBSD/Makewhatis/Find.pm index 4b268d62f86..0e9e2febd34 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis/Find.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis/Find.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Find.pm,v 1.3 2011/07/02 12:47:49 espie Exp $ +# $OpenBSD: Find.pm,v 1.4 2014/03/21 10:59:31 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -24,14 +24,14 @@ use File::Find; sub equivalents { - my $_ = shift; + my $f = shift; my @l = (); - s/(?:\.Z|\.gz)$//; - push(@l, $_, "$_.Z", "$_.gz"); - if (s,/cat([\dln]\w*?)/(.*)\.0$,/man$1/$2.$1,) { - push(@l, $_, "$_.Z", "$_.gz"); - } elsif (s,/man([\dln]\w*?)/(.*)\.\1$,/cat$1/$2.0,) { - push(@l, $_, "$_.Z", "$_.gz"); + $f =~ s/(?:\.Z|\.gz)$//; + push(@l, $f, "$f.Z", "$f.gz"); + if ($f =~ s,/cat([\dln]\w*?)/(.*)\.0$,/man$1/$2.$1,) { + push(@l, $f, "$f.Z", "$f.gz"); + } elsif ($f =~ s,/man([\dln]\w*?)/(.*)\.\1$,/cat$1/$2.0,) { + push(@l, $f, "$f.Z", "$f.gz"); } return @l; } diff --git a/libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm b/libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm index bc626ca3e3a..ce34d44b46b 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis/Formated.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Formated.pm,v 1.8 2013/06/17 20:04:21 schwarze Exp $ +# $OpenBSD: Formated.pm,v 1.9 2014/03/21 10:59:31 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -23,13 +23,13 @@ package OpenBSD::Makewhatis::Formated; # sub add_formated_subject { - my ($_, $section, $h) = @_; + my ($s, $section, $h) = @_; - if (m/\-/) { - s/([-+.\w\d,])\s+/$1 /g; - s/([a-z][A-z])-\s+/$1/g; + if ($s =~ m/\-/) { + $s =~ s/([-+.\w\d,])\s+/$1 /g; + $s =~ s/([a-z][A-z])-\s+/$1/g; # some twits use: func -- description - if (m/^[^-+.\w\d]*(.*?) -(?:-?)\s+(.*)/) { + if ($s =~ m/^[^-+.\w\d]*(.*?) -(?:-?)\s+(.*)/) { my ($func, $descr) = ($1, $2); $func =~ s/,\s*$//; # nroff will tend to cut function names at the weirdest places @@ -41,10 +41,10 @@ sub add_formated_subject } } - $h->weird_subject($_) if $h->p->picky; + $h->weird_subject($s) if $h->p->picky; # try to find subject in line anyway - if (m/^\s*(.*\S)(?:\s{3,}|\(\)\s+)(.*?)\s*$/) { + if ($s =~ m/^\s*(.*\S)(?:\s{3,}|\(\)\s+)(.*?)\s*$/) { my ($func, $descr) = ($1, $2); $func =~ s/\s+/ /g; $descr =~ s/\s+/ /g; @@ -52,7 +52,7 @@ sub add_formated_subject return; } - $h->weird_subject($_) unless $h->p->picky; + $h->weird_subject($s) unless $h->p->picky; } # handle($file, $h) @@ -64,7 +64,7 @@ sub add_formated_subject sub handle { my ($file, $h) = @_; - my $_; + # my $_; my ($section, $subject); my $foundname = 0; while (<$file>) { diff --git a/libexec/makewhatis/OpenBSD/Makewhatis/Unformated.pm b/libexec/makewhatis/OpenBSD/Makewhatis/Unformated.pm index 21ecacbdbeb..51db8ba3bd9 100644 --- a/libexec/makewhatis/OpenBSD/Makewhatis/Unformated.pm +++ b/libexec/makewhatis/OpenBSD/Makewhatis/Unformated.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Unformated.pm,v 1.9 2013/01/29 11:08:56 espie Exp $ +# $OpenBSD: Unformated.pm,v 1.10 2014/03/21 10:59:31 espie Exp $ # Copyright (c) 2000-2004 Marc Espie <espie@openbsd.org> # # Permission to use, copy, modify, and distribute this software for any @@ -36,55 +36,57 @@ sub add_unformated_subject } }; - my $_ = join(' ', @$toadd); + my $s = join(' ', @$toadd); # do interpolations - s/\\\*\((..)/&$exp($1)/ge; - s/\\\*\[(.*?)\]/&$exp($1)/ge; + $s =~ s/\\\*\((..)/&$exp($1)/ge; + $s =~ s/\\\*\[(.*?)\]/&$exp($1)/ge; # horizontal space adjustments - while (s/\\s[-+]?\d+//g) + while ($s =~ s/\\s[-+]?\d+//g) {} # unbreakable spaces - s/\\\s+/ /g; + $s =~ s/\\\s+/ /g; # unbreakable em dashes - s/\\\|\\\(em\\\|/-/g; + $s =~ s/\\\|\\\(em\\\|/-/g; # em dashes - s/\\\(em\s+/- /g; + $s =~ s/\\\(em\s+/- /g; # single quotes - s/\\\(aq/\'/g; + $s =~ s/\\\(aq/\'/g; # em dashes in the middle of lines - s/\\\(em/-/g; - s/\\\*[LO]//g; - s/\\\(tm/(tm)/g; + $s =~ s/\\\(em/-/g; + $s =~ s/\\\*[LO]//g; + $s =~ s/\\\(tm/(tm)/g; # font changes - s/\\f[BIRP]//g; - s/\\f\(..//g; + $s =~ s/\\f[BIRP]//g; + $s =~ s/\\f\(..//g; # fine space adjustments - while (s/\\[vh]\'.*?\'//g) + while ($s =~ s/\\[vh]\'.*?\'//g) {} - unless (s/\s+\\-\s+/ ($section) - / || s/\s?\\\-/ ($section) -/ || - s/\s-\s/ ($section) - /) { - $h->weird_subject($_) if $h->p->picky; + unless ($s =~ s/\s+\\-\s+/ ($section) - / || + $s =~ s/\s?\\\-/ ($section) -/ || + $s =~ s/\s-\s/ ($section) - /) { + $h->weird_subject($s) if $h->p->picky; # Try guessing where the separation falls... - s/\s+\:\s+/ ($section) - / || s/\S+\s/$& ($section) - / || s/$/ ($section) - (empty subject)/; + $s =~ s/\s+\:\s+/ ($section) - / || $s =~ s/\S+\s/$& ($section) - / || + $s =~ s/$/ ($section) - (empty subject)/; } # other dashes - s/\\-/-/g; + $s =~ s/\\-/-/g; # escaped characters - s/\\\&(.)/$1/g; - s/\\\|/|/g; + $s =~ s/\\\&(.)/$1/g; + $s =~ s/\\\|/|/g; # gremlins... - s/\\c//g; + $s =~ s/\\c//g; # sequence of spaces - s/\s+$//; - s/^\s+//; - s/\s+/ /g; + $s =~ s/\s+$//; + $s =~ s/^\s+//; + $s =~ s/\s+/ /g; # some damage control - if (m/^\Q($section) - \E/) { - $h->weird_subject($_) if $h->p->picky; + if ($s =~ m/^\Q($section) - \E/) { + $h->weird_subject($s) if $h->p->picky; return; } - $h->add($_); + $h->add($s); } # handle($file, $h) @@ -106,10 +108,10 @@ sub handle my @subject = (); my @keep = (); my $nd_seen = 0; - my $_; # retrieve basename of file my ($name, $section) = $h->filename =~ m|(?:.*/)?(.*)\.([\w\d]+)|; # scan until macro + local $_; while (<$f>) { next unless m/^\./ || $found_old || $found_new; next if m/^\.\\\"/; |