| 1 | # Copyrights 2011-2020 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.02. | ||||||||||||||||||||||||||||||||||||||||
| 5 | # This code is part of distribution POSIX-1003. Meta-POD processed with | ||||||||||||||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||
| 9 | package POSIX::1003::Module; | ||||||||||||||||||||||||||||||||||||||||
| 10 | 26 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 11 | 26 | $VERSION = '1.02'; | |||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||
| 14 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 15 | 26 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||
| 17 | # The VERSION of the distribution is sourced from this file, because | ||||||||||||||||||||||||||||||||||||||||
| 18 | # this module also loads the XS extension. Therefore, Makefile.PL | ||||||||||||||||||||||||||||||||||||||||
| 19 | # extracts the version from the line below. | ||||||||||||||||||||||||||||||||||||||||
| 20 | 26 | our $VERSION = '1.02'; | |||||||||||||||||||||||||||||||||||||||
| 21 | 26 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||
| 23 | # some other modules used by the program which uses POSIX::1003 may | ||||||||||||||||||||||||||||||||||||||||
| 24 | # need POSIX.xs via POSIX. | ||||||||||||||||||||||||||||||||||||||||
| 25 | 26 | ▶ | use POSIX (); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||
| 27 | 26 | ▶ | use XSLoader; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 28 | 26 | XSLoader::load 'POSIX::1003', $VERSION; | |||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||
| 31 | sub import(@) | ||||||||||||||||||||||||||||||||||||||||
| 32 | 122 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=32 SCAR=38.7
| |||||||||||||||||||||||||||||||||||||||||
| 33 | 122 | ▶ | return if $class eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||
| 35 | 26 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 36 | 26 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||
| 38 | 122 | ▶ | my $tags = \%{"${class}::EXPORT_TAGS"} or die; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||
| 40 | # A hash-lookup is faster than an array lookup, so %EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||
| 41 | 122 | %{"${class}::EXPORT_OK"} = (); | |||||||||||||||||||||||||||||||||||||||
| 42 | 122 | my $ok = \%{"${class}::EXPORT_OK"}; | |||||||||||||||||||||||||||||||||||||||
| 43 | 122 | ▶ | unless(keys %$ok) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 44 | 122 | { @{$ok}{@{$tags->{$_}}} = () for keys %$tags; | |||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||
| 47 | 122 | ▶ | my $level = @_ && $_[0] =~ m/^\+(\d+)$/ ? shift : 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ and $_[0] =~ /^\+(\d+)$/
MC/DC100%2/2
@_ and $_[0] =~ /^\+(\d+)$/
@_
$_[0] =~ /^\+(\d+)$/
Truth table100%3/3
A and B
A= @_B= $_[0] =~ /^\+(\d+)$/
| |||||||||||||||||||||||||||||||||||||||||
| 48 | 122 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||
| 49 | 63 | ▶ | @_ = ':all' if !@_; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||
| 51 | 63 | my %take; | |||||||||||||||||||||||||||||||||||||||
| 52 | 63 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||
| 53 | 109 | ▶ | { if( $_ eq ':all') | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 54 | 12 | { @take{keys %$ok} = (); | |||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||
| 56 | elsif( m/^:(.*)/ ) | ||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | ▶ | { my $tag = $tags->{$1} or croak "$class does not export $_"; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | @take{@$tag} = (); | |||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||
| 60 | else | ||||||||||||||||||||||||||||||||||||||||
| 61 | 94 | ▶ | { is_missing($_) or exists $ok->{$_} | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
&is_missing($_) or exists $ok->{$_}
MC/DC0%0/2
&is_missing($_) or exists $ok->{$_}
&is_missing($_)
exists $ok->{$_}
Truth table33%1/3
A or B
A= &is_missing($_)B= exists $ok->{$_}
| |||||||||||||||||||||||||||||||||||||||||
| 62 | or croak "$class does not export $_"; | ||||||||||||||||||||||||||||||||||||||||
| 63 | 94 | undef $take{$_}; | |||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||
| 67 | 63 | ▶ | 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';}
| |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||
| 69 | 63 | my $pkg = (caller $level)[0]; | |||||||||||||||||||||||||||||||||||||||
| 70 | 63 | foreach my $f (sort keys %take) | |||||||||||||||||||||||||||||||||||||||
| 71 | 788 | { my $export; | |||||||||||||||||||||||||||||||||||||||
| 72 | 788 | ▶ | 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}
| |||||||||||||||||||||||||||||||||||||||||
| 73 | { # reuse the already created function; might also be a function | ||||||||||||||||||||||||||||||||||||||||
| 74 | # which is actually implemented in the $class namespace. | ||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||
| 76 | ▶ | elsif( is_missing($f) | |||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
&is_missing($f) or exists $ok->{$f} and $f =~ /^[A-Z_][A-Za-z0-9_]*$/
exists $ok->{$f} and $f =~ /^[A-Z_][A-Za-z0-9_]*$/
MC/DC33%1/3
&is_missing($f) or exists $ok->{$f} and $f =~ /^[A-Z_][A-Za-z0-9_]*$/
&is_missing($f)
exists $ok->{$f}
$f =~ /^[A-Z_][A-Za-z0-9_]*$/
Truth table50%2/4
A or B and C
A= &is_missing($f)B= exists $ok->{$f}C= $f =~ /^[A-Z_][A-Za-z0-9_]*$/
| |||||||||||||||||||||||||||||||||||||||||
| 77 | || (exists $ok->{$f} && $f =~ /^[A-Z_][A-Za-z0-9_]*$/)) | ||||||||||||||||||||||||||||||||||||||||
| 78 | 530 | { *{$class.'::'.$f} = $export = $class->_create_constant($f); | |||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||
| 80 | elsif( $f !~ m/[^A-Z0-9_]/ ) # faster than: $f =~ m!^[A-Z0-9_]+$! | ||||||||||||||||||||||||||||||||||||||||
| 81 | { # other all-caps names are always from POSIX.xs | ||||||||||||||||||||||||||||||||||||||||
| 82 | #XXX MO: there should be any external names left | ||||||||||||||||||||||||||||||||||||||||
| 83 | #warn "$f from POSIX.pm"; | ||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if(exists $POSIX::{$f} && defined *{"POSIX::$f"}{CODE}) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/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 table0%0/3
A and B
A= exists $main::POSIX::{$f}B= defined *{"POSIX::$f";}{"CODE"}
| |||||||||||||||||||||||||||||||||||||||||
| 85 | { # POSIX.xs croaks on undefined constants, we will return undef | ||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $const = eval "POSIX::$f()"; | |||||||||||||||||||||||||||||||||||||||
| 87 | 0 | *{$class.'::'.$f} = $export | |||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | = defined $const ? sub() {$const} : sub() {undef}; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||
| 90 | else | ||||||||||||||||||||||||||||||||||||||||
| 91 | { # ignore the missing value | ||||||||||||||||||||||||||||||||||||||||
| 92 | # warn "missing constant in POSIX.pm $f" && next; | ||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | *{$class.'::'.$f} = $export = sub() {undef}; | |||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||
| 96 | elsif($f =~ s/^%//) | ||||||||||||||||||||||||||||||||||||||||
| 97 | 22 | { $export = \%{"${class}::$f"}; | |||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||
| 99 | ▶ | elsif($in_core && grep $f eq $_, @$in_core) | |||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$in_core and grep(($f eq $_), @$in_core)
MC/DC50%1/2
$in_core and grep(($f eq $_), @$in_core)
$in_core
grep(($f eq $_), @$in_core)
Truth table66%2/3
A and B
A= $in_coreB= grep(($f eq $_), @$in_core)
| |||||||||||||||||||||||||||||||||||||||||
| 100 | { # function is in core, simply ignore the export | ||||||||||||||||||||||||||||||||||||||||
| 101 | 35 | next; | |||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||
| 103 | 30 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||
| 104 | { # normal functions implemented in POSIX.xs | ||||||||||||||||||||||||||||||||||||||||
| 105 | 30 | *{"${class}::$f"} = $export = *{"POSIX::$f"}{CODE}; | |||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||
| 107 | else | ||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | { croak "unable to load $f from $class"; | |||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||
| 111 | 26 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 112 | 753 | *{"${pkg}::$f"} = $export; | |||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||
| 117 | sub exampleValue($) | ||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | { my ($pkg, $name) = @_; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
exampleValue: not called CC=5 SCAR=29.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 119 | 26 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | my $tags = \%{"$pkg\::EXPORT_TAGS"} or die; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 122 | 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'}
| |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | grep $_ eq $name, @$constants | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 124 | or return undef; | ||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $val = $pkg->_create_constant($name)->(); | |||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | defined $val ? $val : 'undef'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||
| 130 | package POSIX::1003::ReadOnlyTable; | ||||||||||||||||||||||||||||||||||||||||
| 131 | 26 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 132 | 26 | $VERSION = '1.02'; | |||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||
| 134 | 132 | ▶ | sub TIEHASH($) { bless $_[1], $_[0] } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 135 | 633 | ▶ | sub FETCH($) { $_[0]->{$_[1]} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub EXISTS($) { exists $_[0]->{$_[1]} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 137 | 10 | ▶ | sub FIRSTKEY() { scalar %{$_[0]}; scalar each %{$_[0]} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 138 | 56 | ▶ | sub NEXTKEY() { scalar each %{$_[0]} } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||
| 140 | 26 | 1; | |||||||||||||||||||||||||||||||||||||||