summaryrefslogtreecommitdiffstats
path: root/MDK
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-07-31 00:07:30 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-07-31 00:07:30 +0000
commite14829cc6aa3bcb315e330b1bcb5f82676fb26d3 (patch)
treed757593d3190d53a41943ae5da29efd4db19ab35 /MDK
parentbce512bc41bf288fc6f94d3e092f525dd8541345 (diff)
downloadperl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.tar
perl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.tar.gz
perl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.tar.bz2
perl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.tar.xz
perl-MDK-Common-e14829cc6aa3bcb315e330b1bcb5f82676fb26d3.zip
- perl_checker: add *much* stricter syntax rules
- adapt *.pm's to those rules
Diffstat (limited to 'MDK')
-rw-r--r--MDK/Common/DataStructure.pm2
-rw-r--r--MDK/Common/File.pm2
-rw-r--r--MDK/Common/Func.pm2
-rw-r--r--MDK/Common/Math.pm6
-rw-r--r--MDK/Common/System.pm4
5 files changed, 8 insertions, 8 deletions
diff --git a/MDK/Common/DataStructure.pm b/MDK/Common/DataStructure.pm
index 0becc8d..6e6ab12 100644
--- a/MDK/Common/DataStructure.pm
+++ b/MDK/Common/DataStructure.pm
@@ -131,7 +131,7 @@ sub is_empty_hash_ref { my $a = shift; !defined $a || keys(%$a) == 0 }
sub uniq { my %l; $l{$_} = 1 foreach @_; grep { delete $l{$_} } @_ }
sub difference2 { my %l; @l{@{$_[1]}} = (); grep { !exists $l{$_} } @{$_[0]} }
-sub intersection { my (%l, @m); @l{@{shift @_}} = (); foreach (@_) { @m = grep { exists $l{$_} } @$_; %l = (); @l{@m} = (); } keys %l }
+sub intersection { my (%l, @m); @l{@{shift @_}} = (); foreach (@_) { @m = grep { exists $l{$_} } @$_; %l = (); @l{@m} = () } keys %l }
sub next_val_in_array {
diff --git a/MDK/Common/File.pm b/MDK/Common/File.pm
index 3d1238c..2715855 100644
--- a/MDK/Common/File.pm
+++ b/MDK/Common/File.pm
@@ -107,7 +107,7 @@ sub dirname { local $_ = shift; s|[^/]*/*\s*$||; s|(.)/*$|$1|; $_ || '.' }
sub basename { local $_ = shift; s|/*\s*$||; s|.*/||; $_ }
sub cat_ { local *F; open F, $_[0] or return; my @l = <F>; wantarray ? @l : join '', @l }
sub cat__ { my ($f) = @_; my @l = <$f>; wantarray ? @l : join '', @l }
-sub output { my $f = shift; local *F; open F, ">$f" or die "output in file $f failed: $!\n"; print F foreach @_; }
+sub output { my $f = shift; local *F; open F, ">$f" or die "output in file $f failed: $!\n"; print F foreach @_ }
sub output_p { my $f = shift; mkdir_p(dirname($f)); output($f, @_) }
sub linkf { unlink $_[1]; link $_[0], $_[1] }
sub symlinkf { unlink $_[1]; symlink $_[0], $_[1] }
diff --git a/MDK/Common/Func.pm b/MDK/Common/Func.pm
index 3e8285d..8cca560 100644
--- a/MDK/Common/Func.pm
+++ b/MDK/Common/Func.pm
@@ -181,7 +181,7 @@ sub smapn {
my $f = shift;
my $n = shift;
my @r = ();
- for (my $i = 0; $i < $n; $i++) { push @r, &$f(map { $_->[$i] } @_); }
+ for (my $i = 0; $i < $n; $i++) { push @r, &$f(map { $_->[$i] } @_) }
@r
}
sub mapn(&@) {
diff --git a/MDK/Common/Math.pm b/MDK/Common/Math.pm
index 81a12ae..9118449 100644
--- a/MDK/Common/Math.pm
+++ b/MDK/Common/Math.pm
@@ -125,8 +125,8 @@ sub odd { $_[0] % 2 == 1 }
sub sqr { $_[0] * $_[0] }
sub sign { $_[0] <=> 0 }
sub round { int ($_[0] + 0.5) }
-sub round_up { my ($i, $r) = @_; $i = int $i; $i += $r - ($i + $r - 1) % $r - 1; }
-sub round_down { my ($i, $r) = @_; $i = int $i; $i -= $i % $r; }
+sub round_up { my ($i, $r) = @_; $i = int $i; $i += $r - ($i + $r - 1) % $r - 1 }
+sub round_down { my ($i, $r) = @_; $i = int $i; $i -= $i % $r }
sub divide { my $d = int $_[0] / $_[1]; wantarray ? ($d, $_[0] % $_[1]) : $d }
sub min { my $n = shift; $_ < $n and $n = $_ foreach @_; $n }
sub max { my $n = shift; $_ > $n and $n = $_ foreach @_; $n }
@@ -143,7 +143,7 @@ sub factorize {
$n == 1 and return [ 1, 1 ];
for (my $k = 2; sqr($k) <= $n; $k++) {
my $i = 0;
- for ($i = 0; $n % $k == 0; $i++) { $n /= $k; }
+ for ($i = 0; $n % $k == 0; $i++) { $n /= $k }
$i and push @r, [ $k, $i ];
}
$n > 1 and push @r, [ $n, 1 ];
diff --git a/MDK/Common/System.pm b/MDK/Common/System.pm
index 6fca4d6..73ba091 100644
--- a/MDK/Common/System.pm
+++ b/MDK/Common/System.pm
@@ -261,8 +261,8 @@ sub df {
sub sync { syscall_('sync') }
sub psizeof { length pack $_[0] }
-sub availableMemory() { MDK::Common::Math::sum(map { /(\d+)/ } grep { /^(MemTotal|SwapTotal):/ } MDK::Common::File::cat_("/proc/meminfo")); }
-sub availableRamMB() { 4 * MDK::Common::Math::round((-s '/proc/kcore') / 1024 / 1024 / 4); }
+sub availableMemory() { MDK::Common::Math::sum(map { /(\d+)/ } grep { /^(MemTotal|SwapTotal):/ } MDK::Common::File::cat_("/proc/meminfo")) }
+sub availableRamMB() { 4 * MDK::Common::Math::round((-s '/proc/kcore') / 1024 / 1024 / 4) }
sub gettimeofday { my $t = pack "LL"; syscall_('gettimeofday', $t, 0) or die "gettimeofday failed: $!\n"; unpack("LL", $t) }
sub unix2dos { local $_ = $_[0]; s/\015$//mg; s/$/\015/mg; $_ }