pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc/files lintpkgsrc: cleanup: moderni...
details: https://anonhg.NetBSD.org/pkgsrc/rev/13c4e7dc8d56
branches: trunk
changeset: 382979:13c4e7dc8d56
user: rillig <rillig%pkgsrc.org@localhost>
date: Wed Aug 10 06:08:15 2022 +0000
description:
lintpkgsrc: cleanup: modernize subroutine signatures
diffstat:
pkgtools/lintpkgsrc/files/lintpkgsrc.pl | 193 +++++++++----------------------
1 files changed, 55 insertions(+), 138 deletions(-)
diffs (truncated from 531 to 300 lines):
diff -r 76ff0972f5a1 -r 13c4e7dc8d56 pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Wed Aug 10 05:19:57 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Wed Aug 10 06:08:15 2022 +0000
@@ -1,6 +1,6 @@
#!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.67 2022/08/09 21:01:49 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.68 2022/08/10 06:08:15 rillig Exp $
# Written by David Brownlee <abs%netbsd.org@localhost>.
#
@@ -13,6 +13,7 @@
# TODO: Handle fun DEPENDS like avifile-devel with
# {qt2-designer>=2.2.4,qt2-designer-kde>=2.3.1nb1}
+use v5.34;
use locale;
use strict;
use warnings;
@@ -21,14 +22,14 @@
use File::Basename;
use IPC::Open3;
use Cwd 'realpath', 'getcwd';
+use feature 'signatures'; # only for < v5.36
+no warnings 'experimental::signatures'; # only for < v5.36
# PkgVer is a PKGBASE + PKGVERSION, including some of the variables that
# have been extracted from the package Makefile.
package PkgVer;
-sub new($$$) {
- my ($class, $pkgbase, $pkgversion) = @_;
-
+sub new($class, $pkgbase, $pkgversion) {
my $self = {
pkgbase => $pkgbase,
pkgversion => $pkgversion,
@@ -38,35 +39,25 @@
return $self;
}
-sub pkgbase($) {
- my ($self) = @_;
-
+sub pkgbase($self) {
$self->{pkgbase};
}
-sub pkgversion($) {
- my ($self) = @_;
-
+sub pkgversion($self) {
$self->{pkgversion};
}
-sub pkgname($) {
- my ($self) = @_;
-
+sub pkgname($self) {
$self->pkgbase . '-' . $self->pkgversion;
}
-sub var($$$) {
- my ($self, $key, $val) = @_;
-
+sub var($self, $key, $val = undef) {
(defined $val)
? ($self->{vars}->{$key} = $val)
: $self->{vars}->{$key};
}
-sub vars($) {
- my ($self) = @_;
-
+sub vars($self) {
keys %{$self->{vars}};
}
@@ -75,9 +66,7 @@
#
package Pkgs;
-sub new($$) {
- my ($class, $pkgbase) = @_;
-
+sub new($class, $pkgbase) {
my $self = {
pkgbase => $pkgbase,
pkgvers => {},
@@ -86,23 +75,17 @@
return $self;
}
-sub pkgbase($) {
- my ($self) = @_;
-
+sub pkgbase($self) {
$self->{pkgbase};
}
# Returns all available versions of the package, in decreasing
# alphabetical(!) order.
-sub versions($) {
- my ($self) = @_;
-
+sub versions($self) {
return sort { $b cmp $a } keys %{$self->{pkgvers}};
}
-sub add($$$) {
- my ($self, $pkgbase, $pkgversion) = @_;
-
+sub add($self, $pkgbase, $pkgversion) {
$self->{pkgvers}->{$pkgversion} = PkgVer->new($pkgbase, $pkgversion);
}
@@ -110,9 +93,7 @@
# version order.
#
# pkgver($pkgversion) returns the PkgVer, or undef.
-sub pkgver($@) {
- my ($self, $pkgversion) = @_;
-
+sub pkgver($self, $pkgversion = undef) {
my $pkgvers = $self->{pkgvers};
if (@_ > 1) {
return $pkgvers->{$pkgversion};
@@ -121,35 +102,27 @@
}
# XXX: Returns the alphabetically(!) highest PkgVer.
-sub latestver($) {
- my ($self) = @_;
-
+sub latestver($self) {
($self->pkgver)[0];
}
# PkgDb is a small database of all packages in pkgsrc.
package PkgDb;
-sub new($) {
- my ($class) = @_;
-
+sub new($class) {
my $self = {}; # pkgbase => Pkgs
bless $self, $class;
return $self;
}
-sub add($$$) {
- my ($self, $pkgbase, $pkgversion) = @_;
-
+sub add($self, $pkgbase, $pkgversion) {
if (!$self->{$pkgbase}) {
$self->{$pkgbase} = Pkgs->new($pkgbase);
}
$self->{$pkgbase}->add($pkgbase, $pkgversion);
}
-sub numpkgver($) {
- my ($self) = @_;
-
+sub numpkgver($self) {
scalar($self->pkgver);
}
@@ -160,9 +133,7 @@
# version in decreasing alphabetical(!) order.
#
# pkgver($pkgbase, $pkgversion) returns the package, or undef.
-sub pkgver($$$) {
- my ($self, $pkgbase, $pkgversion) = @_;
-
+sub pkgver($self, $pkgbase = undef, $pkgversion = undef) {
if (!defined $pkgbase) {
my (@pkgvers);
foreach my $pkg ($self->pkgs) {
@@ -183,9 +154,7 @@
# pkgs() returns all Pkgs, sorted by pkgbase.
#
# pkgs($pkgbase) returns the Pkgs, or undef.
-sub pkgs($$) {
- my ($self, $pkgbase) = @_;
-
+sub pkgs($self, $pkgbase = undef) {
if (defined $pkgbase) {
return $self->{$pkgbase};
} else {
@@ -216,20 +185,17 @@
my $magic_undefined = 'M_a_G_i_C_uNdEfInEd';
sub debug(@) {
-
($opt{D}) && print STDERR 'DEBUG: ', @_;
}
sub verbose(@) {
-
if (-t STDERR) {
print STDERR @_;
}
}
-sub fail($) {
-
- print STDERR shift(), "\n";
+sub fail($msg) {
+ print STDERR $msg, "\n";
exit(3);
}
@@ -237,9 +203,7 @@
#
#TODO this entire sub should be replaced with direct calls to
# File::Find
-sub listdir($$);
-sub listdir($$) {
- my ($base, $dir) = @_;
+sub listdir($base, $dir = undef) {
my ($thisdir);
my (@list, @thislist);
@@ -264,18 +228,14 @@
@list;
}
-sub canonicalize_pkgname($) {
- my ($pkgname) = @_;
-
+sub canonicalize_pkgname($pkgname) {
$pkgname =~ s,^py\d+(?:pth|)-,py-,;
$pkgname =~ s,^ruby\d+-,ruby-,;
$pkgname =~ s,^php\d+-,php-,;
return $pkgname;
}
-sub split_pkgversion($) {
- my ($pkgversion) = @_;
-
+sub split_pkgversion($pkgversion) {
$pkgversion = lc($pkgversion);
# See pkgtools/pkg_install/files/lib/dewey.c.
@@ -300,9 +260,7 @@
@temp;
}
-sub pkgversioncmp($$$) {
- my ($va, $op, $vb) = @_;
-
+sub pkgversioncmp($va, $op, $vb) {
my ($nb_a, @a) = split_pkgversion($va);
my ($nb_b, @b) = split_pkgversion($vb);
@@ -325,9 +283,7 @@
# Return a copy of $value in which trivial variable expressions are replaced
# with their variable values.
-sub expand_var($$) {
- my ($value, $vars) = @_;
-
+sub expand_var($value, $vars) {
while ($value =~ /\$\{([-\w.]+)\}/) {
if (defined($vars->{$1})) {
$value = $` . $vars->{$1} . $';
@@ -338,12 +294,9 @@
$value;
}
-sub parse_eval_make_false($$) {
- my ($line, $vars) = @_;
- my ($false, $test);
-
- $false = 0;
- $test = expand_var($line, $vars);
+sub parse_eval_make_false($line, $vars) {
+ my $false = 0;
+ my $test = expand_var($line, $vars);
# XXX This is _so_ wrong - need to parse this correctly
$test =~ s/""/\r/g;
@@ -423,8 +376,8 @@
$false;
}
-sub parse_makefile_line_include($$$$$$) {
- my ($file, $incfile, $incdirs, $included, $lines, $vars) = @_;
+sub parse_makefile_line_include($file, $incfile,
+ $incdirs, $included, $lines, $vars) {
# At this point just skip any includes which we were
# not able to fully expand.
@@ -483,9 +436,7 @@
close(FILE);
}
-sub parse_makefile_line_var($$$$) {
- my ($varname, $op, $value, $vars) = @_;
-
Home |
Main Index |
Thread Index |
Old Index