| 1 | # Copyrights 2011-2013 by [Mark Overmeer]. | ||||||||||||||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.01. | ||||||||||||||||||||||||||||||||||||||||
| 5 | 22 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | 22 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||
| 8 | package POSIX::1003::Module; | ||||||||||||||||||||||||||||||||||||||||
| 9 | 22 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | $VERSION = '0.98'; | |||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||
| 13 | # The VERSION of the distribution is sourced from this file, because | ||||||||||||||||||||||||||||||||||||||||
| 14 | # this module also loads the XS extension. | ||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | our $VERSION = '0.98'; | |||||||||||||||||||||||||||||||||||||||
| 16 | 22 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||
| 18 | 22 | ▶ | { use XSLoader; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 19 | 22 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | XSLoader::load 'POSIX'; | |||||||||||||||||||||||||||||||||||||||
| 21 | 1 | XSLoader::load 'POSIX::1003', $VERSION; | |||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||
| 24 | # also used in release-test | ||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | our $in_constant_table = qr/ | |||||||||||||||||||||||||||||||||||||||
| 26 | ^_CS_ # confstr | ||||||||||||||||||||||||||||||||||||||||
| 27 | | ^DN_ # fcntl | ||||||||||||||||||||||||||||||||||||||||
| 28 | | ^E(?!CHONL|XIT_) # errno ECHONL in Termios, EXIT_ in Proc | ||||||||||||||||||||||||||||||||||||||||
| 29 | | ^FCNTL # fcntl | ||||||||||||||||||||||||||||||||||||||||
| 30 | | ^F_ # fcntl | ||||||||||||||||||||||||||||||||||||||||
| 31 | | ^FD_ # fcntl | ||||||||||||||||||||||||||||||||||||||||
| 32 | | ^GET_ # rlimit | ||||||||||||||||||||||||||||||||||||||||
| 33 | | ^LOCK_ # fcntl | ||||||||||||||||||||||||||||||||||||||||
| 34 | | ^O_ # fdio | ||||||||||||||||||||||||||||||||||||||||
| 35 | | ^_PC_ # pathconf | ||||||||||||||||||||||||||||||||||||||||
| 36 | | ^POLL # poll | ||||||||||||||||||||||||||||||||||||||||
| 37 | | ^_POSIX # property | ||||||||||||||||||||||||||||||||||||||||
| 38 | | ^RLIM # rlimit | ||||||||||||||||||||||||||||||||||||||||
| 39 | | ^SA_ # sigaction | ||||||||||||||||||||||||||||||||||||||||
| 40 | | ^S_ # stat | ||||||||||||||||||||||||||||||||||||||||
| 41 | | ^_SC_ # sysconf | ||||||||||||||||||||||||||||||||||||||||
| 42 | | ^SEEK_ # fdio | ||||||||||||||||||||||||||||||||||||||||
| 43 | | ^SET_ # rlimit aix | ||||||||||||||||||||||||||||||||||||||||
| 44 | | ^SIG[^_] # signals | ||||||||||||||||||||||||||||||||||||||||
| 45 | | ^UL_ # ulimit | ||||||||||||||||||||||||||||||||||||||||
| 46 | | ^WSAE # errno (windows sockets) | ||||||||||||||||||||||||||||||||||||||||
| 47 | | _OK$ # access | ||||||||||||||||||||||||||||||||||||||||
| 48 | /x; | ||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||
| 51 | sub import(@) | ||||||||||||||||||||||||||||||||||||||||
| 52 | 21 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=30 SCAR=41.4
| |||||||||||||||||||||||||||||||||||||||||
| 53 | 21 | ▶ | return if $class eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||
| 55 | 22 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 56 | 22 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||
| 58 | 21 | ▶ | my $tags = \%{"${class}::EXPORT_TAGS"} or die; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||
| 60 | # A hash-lookup is faster than an array lookup, so %EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||
| 61 | 21 | %{"${class}::EXPORT_OK"} = (); | |||||||||||||||||||||||||||||||||||||||
| 62 | 21 | my $ok = \%{"${class}::EXPORT_OK"}; | |||||||||||||||||||||||||||||||||||||||
| 63 | 21 | ▶ | unless(keys %$ok) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 64 | 21 | { @{$ok}{@{$tags->{$_}}} = () for keys %$tags; | |||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||
| 67 | 21 | ▶ | my $level = @_ && $_[0] =~ m/^\+(\d+)$/ ? shift : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and $_[0] =~ /^\+(\d+)$/
MC/DC0%0/2
@_ and $_[0] =~ /^\+(\d+)$/
@_
$_[0] =~ /^\+(\d+)$/
Truth table33%1/3
A and B
A= @_B= $_[0] =~ /^\+(\d+)$/
| |||||||||||||||||||||||||||||||||||||||||
| 68 | 21 | ▶ | return if @_==1 && $_[0] eq ':none'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ == 1 and $_[0] eq ":none"
MC/DC100%2/2
@_ == 1 and $_[0] eq ":none"
@_ == 1
$_[0] eq ":none"
Truth table100%3/3
A and B
A= @_ == 1B= $_[0] eq ":none"
| |||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | ▶ | @_ = ':all' if !@_; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | my %take; | |||||||||||||||||||||||||||||||||||||||
| 72 | 3 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||
| 73 | 5 | ▶ | { if( $_ eq ':all') | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | { @take{keys %$ok} = (); | |||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||
| 76 | elsif( m/^:(.*)/ ) | ||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | { my $tag = $tags->{$1} or croak "$class does not export $_"; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | @take{@$tag} = (); | |||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||
| 80 | else | ||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | ▶ | { $_ =~ $in_constant_table or exists $ok->{$_} | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_ =~ /$POSIX::1003::Module::in_constant_table/x or exists $ok->{$_}
MC/DC0%0/2
$_ =~ /$POSIX::1003::Module::in_constant_table/x or exists $ok->{$_}
$_ =~ /$POSIX::1003::Module::in_constant_table/x
exists $ok->{$_}
Truth table66%2/3
A or B
A= $_ =~ /$POSIX::1003::Module::in_constant_table/xB= exists $ok->{$_}
| |||||||||||||||||||||||||||||||||||||||||
| 82 | or croak "$class does not export $_"; | ||||||||||||||||||||||||||||||||||||||||
| 83 | 5 | undef $take{$_}; | |||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||
| 87 | 3 | ▶ | my $in_core = \@{$class.'::IN_CORE'} || []; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
\@{$class . '::IN_CORE';} || []
MC/DC0%0/1
\@{$class . '::IN_CORE';} || []
\@{$class . '::IN_CORE';}
Truth table50%1/2
A
A= \@{$class . '::IN_CORE';}
| |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||
| 89 | 3 | my $pkg = (caller $level)[0]; | |||||||||||||||||||||||||||||||||||||||
| 90 | 3 | foreach my $f (sort keys %take) | |||||||||||||||||||||||||||||||||||||||
| 91 | 5 | { my $export; | |||||||||||||||||||||||||||||||||||||||
| 92 | 5 | ▶ | if(exists ${$class.'::'}{$f} && ($export = *{"${class}::$f"}{CODE})) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition100%2/2
exists do {
$class . '::'
}->{$f} and $export = *{"${class}::$f";}{"CODE"}
MC/DC100%1/1
exists do {
$class . '::'
}->{$f} and $export = *{"${class}::$f";}{"CODE"}
exists do {
$class . '::'
}->{$f}
Truth table100%2/2
A
A= exists do {
$class . '::'
}->{$f}
| |||||||||||||||||||||||||||||||||||||||||
| 93 | { # reuse the already created function; might also be a function | ||||||||||||||||||||||||||||||||||||||||
| 94 | # which is actually implemented in the $class namespace. | ||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||
| 96 | elsif($f =~ $in_constant_table) | ||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | { *{$class.'::'.$f} = $export = $class->_create_constant($f); | |||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||
| 99 | elsif( $f !~ m/[^A-Z0-9_]/ ) # faster than: $f =~ m!^[A-Z0-9_]+$! | ||||||||||||||||||||||||||||||||||||||||
| 100 | { # other all-caps names are always from POSIX.xs | ||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | if(exists $POSIX::{$f} && defined *{"POSIX::$f"}{CODE}) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $main::POSIX::{$f} and defined *{"POSIX::$f";}{"CODE"}
MC/DC0%0/2
exists $main::POSIX::{$f} and defined *{"POSIX::$f";}{"CODE"}
exists $main::POSIX::{$f}
defined *{"POSIX::$f";}{"CODE"}
Truth table33%1/3
A and B
A= exists $main::POSIX::{$f}B= defined *{"POSIX::$f";}{"CODE"}
| |||||||||||||||||||||||||||||||||||||||||
| 102 | { # POSIX.xs croaks on undefined constants, we will return undef | ||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | my $const = eval "POSIX::$f()"; | |||||||||||||||||||||||||||||||||||||||
| 104 | 1 | *{$class.'::'.$f} = $export | |||||||||||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | = defined $const ? sub() {$const} : sub() {undef}; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||
| 107 | else | ||||||||||||||||||||||||||||||||||||||||
| 108 | { # ignore the missing value | ||||||||||||||||||||||||||||||||||||||||
| 109 | # warn "missing constant in POSIX.pm $f" && next; | ||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | *{$class.'::'.$f} = $export = sub() {undef}; | |||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | elsif(exists $POSIX::{$f} && defined *{"POSIX::$f"}{CODE}) | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
exists $main::POSIX::{$f} and defined *{"POSIX::$f";}{"CODE"}
MC/DC0%0/2
exists $main::POSIX::{$f} and defined *{"POSIX::$f";}{"CODE"}
exists $main::POSIX::{$f}
defined *{"POSIX::$f";}{"CODE"}
Truth table33%1/3
A and B
A= exists $main::POSIX::{$f}B= defined *{"POSIX::$f";}{"CODE"}
| |||||||||||||||||||||||||||||||||||||||||
| 114 | { # normal functions implemented in POSIX.xs | ||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | *{"${class}::$f"} = $export = *{"POSIX::$f"}{CODE}; | |||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||
| 117 | elsif($f =~ s/^%//) | ||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | { $export = \%{"${class}::$f"}; | |||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||
| 120 | ▶ | elsif($in_core && grep $f eq $_, @$in_core) | |||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$in_core and grep(($f eq $_), @$in_core)
MC/DC0%0/2
$in_core and grep(($f eq $_), @$in_core)
$in_core
grep(($f eq $_), @$in_core)
Truth table0%0/3
A and B
A= $in_coreB= grep(($f eq $_), @$in_core)
| |||||||||||||||||||||||||||||||||||||||||
| 121 | { # function is in core, simply ignore the export | ||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | next; | |||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||
| 124 | else | ||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | { croak "unable to load $f from $class"; | |||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||
| 128 | 22 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 129 | 5 | *{"${pkg}::$f"} = $export; | |||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||
| 134 | sub exampleValue($) | ||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | { my ($pkg, $name) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
exampleValue: not called CC=5 SCAR=29.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 136 | 22 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my $tags = \%{"$pkg\::EXPORT_TAGS"} or die; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | my $constants = $tags->{constants} || []; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$tags->{'constants'} || []
MC/DC0%0/1
$tags->{'constants'} || []
$tags->{'constants'}
Truth table0%0/2
A
A= $tags->{'constants'}
| |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | grep $_ eq $name, @$constants | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 141 | or return undef; | ||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $val = &{"$pkg\::$name"}; | |||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | defined $val ? $val : 'undef'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||
| 147 | package POSIX::1003::ReadOnlyTable; | ||||||||||||||||||||||||||||||||||||||||
| 148 | 22 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | $VERSION = '0.98'; | |||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||
| 151 | 13 | ▶ | sub TIEHASH($) { bless $_[1], $_[0] } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | sub FETCH($) { $_[0]->{$_[1]} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | sub EXISTS($) { exists $_[0]->{$_[1]} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | sub FIRSTKEY() { scalar %{$_[0]}; scalar each %{$_[0]} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | sub NEXTKEY() { scalar each %{$_[0]} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||