blib/lib/POSIX/2008.pm

filter: Statementstmt 86.0% 43 / 50 Branchbran 33.3% 2 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 77.7% 7 / 9 Podpod n/a totaltotal 81.4% 57 / 70 CC 4 SCAR 9.6
CC
4
Cov
81%
AUTOLOAD
6.0
__ANON__
4.5
import
2.1
CRAP 2.6
↑ Summary 2008.xs »
1 package POSIX::2008;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use IO::Dir ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use IO::File ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 11 require Exporter;
10 11 require 'POSIX/2008/symbols.pl'; # Defines @_constants and @_functions.
11  
12 11 our @_constants;
13 11 our @_functions;
14  
15 11 our $VERSION = '0.29';
16 11 our $XS_VERSION = $VERSION;
17 11 $VERSION = eval $VERSION; # so "use Module 0.002" won't warn on underscore
18  
19 11 our @ISA = qw(Exporter);
20 11 our @EXPORT = ();
21 11 our @EXPORT_OK = (@_functions, @_constants);
22  
23 11 ▶our %EXPORT_TAGS = (
Condition100%3/3
/at2?$/ && !/^(?:creat|l?stat)$/
!ll&&!rl&&r
271733198
MC/DC100%2/2
/at2?$/ && !/^(?:creat|l?stat)$/
/at2?$/ !/^(?:creat|l?stat)$/
Truth table100%3/3
A && not(B)
A= /at2?$/B= !/^(?:creat|l?stat)$/
ABresult
0X0
100
111
24 # at: Older Perls don't have variable length lookbehind, thus two regexen
25 # for functions.
26 'at' => [
27 grep(/^(?:AT|RENAME|RESOLVE)_/, @_constants),
28 grep(/at2?$/ && !/^(?:creat|l?stat)$/, @_functions),
29 ],
30 'id' => [grep /^[gs]et.+id$/, @_functions],
31 'is' => [grep /^is/, @_functions],
32 'rw' => [qw(read write readv writev)],
33 'prw' => [qw(pread preadv preadv2 pwrite pwritev pwritev2)],
34 'clock' => [
35 grep(/^(?:CLOCK_|TIMER_ABSTIME)/, @_constants),
36 grep(/^clock/, @_functions),
37 ],
38 'errno_h'=> [grep /^E(?!MPTY)[A-Z]+$/, @_constants],
39 'fcntl' => [grep /^(?:[FORWX]|FD|POSIX_FADV|SEEK)_/, @_constants],
40 'fenv_h' => [grep(/^FE_/, @_constants), grep (/^fe/, @_functions)],
41 'fnm' => [grep(/^FNM_/, @_constants), 'fnmatch'],
42 'poll' => ['poll', 'ppoll', grep /^(?:POLL|INFTIM)/, @_constants],
43 'socket_h' => [
44 qw(SCM_RIGHTS SOL_SOCKET SOMAXCONN),
45 grep(/^(?:AF|MSG|SHUT|SO|SOCK)_/, @_constants),
46 ],
47 'stat_h' => [grep /^(?:S_I|UTIME_)/, @_constants],
48 'time_h' => [grep /^(?:CLOCK|TIMER)_/, @_constants],
49 'timer' => [grep(/^TIMER_/, @_constants), grep(/^timer_/, @_functions)],
50 'utmpx_h' => [
51 grep(/_(?:TIME|PROCESS)$/, @_constants),
52 grep(/^(?:ACCOUNTING|EMPTY|RUN_LVL|UT_UNKNOWN)$/, @_constants),
53 grep(/utx/, @_functions),
54 ],
55 'confstr' => ['confstr', grep /^_CS_/, @_constants],
56 'pathconf' => ['pathconf', grep /^_PC_/, @_constants],
57 'sysconf' => ['sysconf', grep /^_SC_/, @_constants],
58 );
59  
60 11 my %deprecated = (
61 atol => 'atoi',
62 atoll => 'atoi',
63 ldiv => 'div',
64 lldiv => 'div',
65 fchdir => 'chdir',
66 fchmod => 'chmod',
67 fchown => 'chown',
68 ftruncate => 'truncate',
69 );
70 11 my %deprecated_warned;
71  
72 11 push @EXPORT_OK, keys %deprecated;
73  
74 11 our $AUTOLOAD;
75 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=2 SCAR=17.9
76 0 my ($func) = ($AUTOLOAD =~ /.*::(.*)/);
77 0 ▶ die "POSIX::2008.xs has failed to load\n" if $func eq 'constant';
Branch: 1 branch
BranchTrueFalseTotal
if $func eq "constant" 0 0 0
78 0 constant($func);
79 }
80  
81 11 ▶sub import {
Subroutine import: called CC=2 SCAR=7.5
82 11 my $this = shift;
83  
84 11 require XSLoader;
85 11 XSLoader::load('POSIX::2008', $XS_VERSION);
86  
87 11 ▶ while (my ($func, $repl) = each %deprecated) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %deprecated) 88 11 99
88 88 my $package_func = __PACKAGE__."::${func}";
89 88 my $package_repl = __PACKAGE__."::${repl}";
90 11 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
91 88 ▶ *{$package_func} = sub {
Subroutine __ANON__: not called CC=2 SCAR=15.1
92 Carp::carp(
93 "${package_func}() is deprecated, use ${package_repl}() instead"
94 0 ▶ ) unless $deprecated_warned{$func}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $deprecated_warned{$func}++ 0 0 0
95 0 &{*{$package_repl}};
96 }
97 88 }
98  
99 11 __PACKAGE__->export_to_level(1, $this, @_);
100 }
101  
102 11 1;
↑ Summary 2008.xs »