line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gentoo::Util; |
2
|
|
|
|
|
|
|
our($VERSION)=q{1.0.6}; |
3
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
4
|
8
|
|
|
8
|
|
99848
|
use strict;$|=1; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
329
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
41
|
use Carp qw(confess croak longmess); |
|
8
|
|
|
|
|
11
|
|
|
8
|
|
|
|
|
678
|
|
7
|
8
|
|
|
8
|
|
7854
|
use IO::Handle; |
|
8
|
|
|
|
|
62427
|
|
|
8
|
|
|
|
|
5757
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
29
|
|
|
29
|
|
6438
|
sub import { goto &Exporter::import; }; |
10
|
|
|
|
|
|
|
our (@EXPORT) = qw( |
11
|
|
|
|
|
|
|
xmkdir croak confess longmess xrmdir assert_defined |
12
|
|
|
|
|
|
|
linedump xchdir xrename file2map |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
sub fail; |
15
|
|
|
|
|
|
|
*fail = \&Carp::confess; |
16
|
|
|
|
|
|
|
sub xloadmod(@) { |
17
|
0
|
|
|
0
|
0
|
|
while(@_) { |
18
|
0
|
|
|
|
|
|
eval "use ".shift; |
19
|
0
|
0
|
|
|
|
|
die "$@" if "$@"; |
20
|
|
|
|
|
|
|
}; |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
sub xrename($$){ |
23
|
0
|
0
|
|
0
|
0
|
|
rename($_[0],$_[1]) and return 1; |
24
|
0
|
|
|
|
|
|
fail join("rename",join(",",@_),$!); |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
sub xchdir($) { |
27
|
0
|
0
|
|
0
|
0
|
|
chdir($_[0]) and return 1; |
28
|
0
|
|
|
|
|
|
fail "chdir:",join(",",@_),":$!\n"; |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
sub xrmdir($) { |
31
|
0
|
0
|
|
0
|
0
|
|
rmdir($_[0]) and return 1; |
32
|
0
|
0
|
|
|
|
|
-d $_[0] or return 0; |
33
|
0
|
|
|
|
|
|
fail "rmdir:", @_, $!; |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
sub xmkdir($;$) { |
36
|
0
|
0
|
0
|
0
|
0
|
|
mkdir($_[0],$_[1]||0755) and return 1; |
37
|
0
|
0
|
|
|
|
|
-d $_[0] and return 0; |
38
|
0
|
|
|
|
|
|
fail "mkdir:", @_, $!; |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
sub chomped(@){ |
41
|
0
|
0
|
|
0
|
0
|
|
grep { chomp || 1 } @_; |
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
sub file2map($) { |
44
|
0
|
|
|
0
|
0
|
|
my (%res,$cnt); |
45
|
0
|
|
|
|
|
|
($cnt,@_) = grep { length } map { split } suck(shift); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$_=1 for ( @res{(@_)} ); |
47
|
0
|
|
|
|
|
|
\%res; |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
sub suck($){ |
50
|
0
|
|
|
0
|
0
|
|
local $_ = shift; |
51
|
0
|
0
|
|
|
|
|
open(my $fh, $_) or fail "open:$_:$!\n"; |
52
|
0
|
|
|
|
|
|
$fh->getlines(); |
53
|
|
|
|
|
|
|
}; |
54
|
|
|
|
|
|
|
sub linedump($){ |
55
|
0
|
|
|
0
|
0
|
|
my $line = eval q( |
56
|
|
|
|
|
|
|
use Data::Dumper; |
57
|
|
|
|
|
|
|
${$Data::Dumper::{$_}}=1 for qw(Terse Useqq Purity Deparse); |
58
|
|
|
|
|
|
|
Dumper($_[0]); |
59
|
|
|
|
|
|
|
); |
60
|
0
|
|
|
|
|
|
return join(" ", split /\s*\n\s*/, $line ); |
61
|
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
sub assert_defined_failed() { |
63
|
0
|
|
|
0
|
0
|
|
croak("assert_defined(".linedump([@_]).")"); |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
sub assert_defined(@){ |
66
|
0
|
|
|
0
|
0
|
|
for ( @_ ) { |
67
|
0
|
0
|
|
|
|
|
goto &assert_defined_failed unless defined; |
68
|
|
|
|
|
|
|
}; |
69
|
0
|
|
|
|
|
|
return; |
70
|
|
|
|
|
|
|
}; |
71
|
|
|
|
|
|
|
1; |