« /usr/local/lib/perl5/5.44.0/x86_64-linux/IO/Socket/UNIX.pm
↑ Summary
/usr/local/lib/perl5/site_perl/5.44.0/Path/Tiny.pm »
| 1 | # | ||||||||||||||||||||||||||||||||
| 2 | # Copyright (c) 1995-2001, Raphael Manfredi | ||||||||||||||||||||||||||||||||
| 3 | # Copyright (c) 2002-2014 by the Perl 5 Porters | ||||||||||||||||||||||||||||||||
| 4 | # Copyright (c) 2015-2016 cPanel Inc | ||||||||||||||||||||||||||||||||
| 5 | # Copyright (c) 2017 Reini Urban | ||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||
| 7 | # You may redistribute only under the same terms as Perl 5, as specified | ||||||||||||||||||||||||||||||||
| 8 | # in the README file that comes with the distribution. | ||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | package Storable; | ||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use XSLoader (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use Exporter (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 7 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||
| 18 | 7 | our @EXPORT = qw(store retrieve); | |||||||||||||||||||||||||||||||
| 19 | 7 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||
| 20 | nstore store_fd nstore_fd fd_retrieve | ||||||||||||||||||||||||||||||||
| 21 | freeze nfreeze thaw | ||||||||||||||||||||||||||||||||
| 22 | dclone | ||||||||||||||||||||||||||||||||
| 23 | retrieve_fd | ||||||||||||||||||||||||||||||||
| 24 | lock_store lock_nstore lock_retrieve | ||||||||||||||||||||||||||||||||
| 25 | file_magic read_magic | ||||||||||||||||||||||||||||||||
| 26 | BLESS_OK TIE_OK FLAGS_COMPAT | ||||||||||||||||||||||||||||||||
| 27 | stack_depth stack_depth_hash | ||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 7 | our ($canonical, $forgive_me); | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 33 | 7 | our $VERSION = '3.41'; | |||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 7 | our $recursion_limit; | |||||||||||||||||||||||||||||||
| 37 | 7 | our $recursion_limit_hash; | |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 7 | ▶ | $recursion_limit = 512 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 40 | unless defined $recursion_limit; | ||||||||||||||||||||||||||||||||
| 41 | 7 | ▶ | $recursion_limit_hash = 256 | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 42 | unless defined $recursion_limit_hash; | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 45 | 7 | ▶ | use Fcntl qw(LOCK_SH LOCK_EX); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=7 SCAR=23.4
| |||||||||||||||||||||||||||||||||
| 48 | 7 | ▶ | if (eval { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 49 | 7 | local $SIG{__DIE__}; | |||||||||||||||||||||||||||||||
| 50 | 7 | local @INC = @INC; | |||||||||||||||||||||||||||||||
| 51 | 7 | ▶ | pop @INC if $INC[-1] eq '.'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 52 | 7 | require Log::Agent; | |||||||||||||||||||||||||||||||
| 53 | 0 | 1; | |||||||||||||||||||||||||||||||
| 54 | }) { | ||||||||||||||||||||||||||||||||
| 55 | 0 | Log::Agent->import; | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | # | ||||||||||||||||||||||||||||||||
| 58 | # Use of Log::Agent is optional. If it hasn't imported these subs then | ||||||||||||||||||||||||||||||||
| 59 | # provide a fallback implementation. | ||||||||||||||||||||||||||||||||
| 60 | # | ||||||||||||||||||||||||||||||||
| 61 | 7 | ▶ | unless ($Storable::{logcroak} && *{$Storable::{logcroak}}{CODE}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$main::Storable::{"logcroak"} and *{$main::Storable::{"logcroak"};}{"CODE"}
MC/DC0%0/1
$main::Storable::{"logcroak"} and *{$main::Storable::{"logcroak"};}{"CODE"}
$main::Storable::{"logcroak"}
Truth table50%1/2
A
A= $main::Storable::{"logcroak"}
| |||||||||||||||||||||||||||||||||
| 62 | 7 | *logcroak = \&Carp::croak; | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||||||
| 65 | # Log::Agent's logcroak always adds a newline to the error it is | ||||||||||||||||||||||||||||||||
| 66 | # given. This breaks refs getting thrown. We can just discard what | ||||||||||||||||||||||||||||||||
| 67 | # it throws (but keep whatever logging it does) and throw the original | ||||||||||||||||||||||||||||||||
| 68 | # args. | ||||||||||||||||||||||||||||||||
| 69 | 7 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 70 | 0 | my $logcroak = \&logcroak; | |||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | *logcroak = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 72 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||
| 73 | 0 | eval { &$logcroak }; | |||||||||||||||||||||||||||||||
| 74 | 0 | Carp::croak(@args); | |||||||||||||||||||||||||||||||
| 75 | 0 | }; | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | 7 | ▶ | unless ($Storable::{logcarp} && *{$Storable::{logcarp}}{CODE}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$main::Storable::{"logcarp"} and *{$main::Storable::{"logcarp"};}{"CODE"}
MC/DC0%0/1
$main::Storable::{"logcarp"} and *{$main::Storable::{"logcarp"};}{"CODE"}
$main::Storable::{"logcarp"}
Truth table50%1/2
A
A= $main::Storable::{"logcarp"}
| |||||||||||||||||||||||||||||||||
| 78 | 7 | *logcarp = \&Carp::carp; | |||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub CLONE { | ||||||||||||||||||||||||||||||
|
Subroutine
CLONE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 83 | # clone context under threads | ||||||||||||||||||||||||||||||||
| 84 | 0 | Storable::init_perinterp(); | |||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | sub BLESS_OK () { 2 } | ||||||||||||||||||||||||||||||||
| 88 | sub TIE_OK () { 4 } | ||||||||||||||||||||||||||||||||
| 89 | sub FLAGS_COMPAT () { BLESS_OK | TIE_OK } | ||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | # By default restricted hashes are downgraded on earlier perls. | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | 7 | our $flags = FLAGS_COMPAT; | |||||||||||||||||||||||||||||||
| 94 | 7 | our $downgrade_restricted = 1; | |||||||||||||||||||||||||||||||
| 95 | 7 | our $accept_future_minor = 1; | |||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | 7 | ▶ | BEGIN { XSLoader::load('Storable') }; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | # | ||||||||||||||||||||||||||||||||
| 100 | # Determine whether locking is possible, but only when needed. | ||||||||||||||||||||||||||||||||
| 101 | # | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub show_file_magic { | ||||||||||||||||||||||||||||||
|
Subroutine
show_file_magic: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 104 | 0 | print <<EOM; | |||||||||||||||||||||||||||||||
| 105 | # | ||||||||||||||||||||||||||||||||
| 106 | # To recognize the data files of the Perl module Storable, | ||||||||||||||||||||||||||||||||
| 107 | # the following lines need to be added to the local magic(5) file, | ||||||||||||||||||||||||||||||||
| 108 | # usually either /usr/share/misc/magic or /etc/magic. | ||||||||||||||||||||||||||||||||
| 109 | # | ||||||||||||||||||||||||||||||||
| 110 | 0 string perl-store perl Storable(v0.6) data | ||||||||||||||||||||||||||||||||
| 111 | >4 byte >0 (net-order %d) | ||||||||||||||||||||||||||||||||
| 112 | >>4 byte &01 (network-ordered) | ||||||||||||||||||||||||||||||||
| 113 | >>4 byte =3 (major 1) | ||||||||||||||||||||||||||||||||
| 114 | >>4 byte =2 (major 1) | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | 0 string pst0 perl Storable(v0.7) data | ||||||||||||||||||||||||||||||||
| 117 | >4 byte >0 | ||||||||||||||||||||||||||||||||
| 118 | >>4 byte &01 (network-ordered) | ||||||||||||||||||||||||||||||||
| 119 | >>4 byte =5 (major 2) | ||||||||||||||||||||||||||||||||
| 120 | >>4 byte =4 (major 2) | ||||||||||||||||||||||||||||||||
| 121 | >>5 byte >0 (minor %d) | ||||||||||||||||||||||||||||||||
| 122 | EOM | ||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub file_magic { | ||||||||||||||||||||||||||||||
|
Subroutine
file_magic: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 126 | 0 | my $file = shift; | |||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | open(my $fh, "<", $file) || die "Can't open '$file': $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 128 | 0 | binmode($fh); | |||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | defined(sysread($fh, my $buf, 32)) || die "Can't read from '$file': $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 130 | 0 | close($fh); | |||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | $file = "./$file" unless $file; # ensure TRUE value | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | 0 | return read_magic($buf, $file); | |||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub read_magic { | ||||||||||||||||||||||||||||||
|
Subroutine
read_magic: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 138 | 0 | my($buf, $file) = @_; | |||||||||||||||||||||||||||||||
| 139 | 0 | my %info; | |||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | 0 | my $buflen = length($buf); | |||||||||||||||||||||||||||||||
| 142 | 0 | my $magic; | |||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if ($buf =~ s/^(pst0|perl-store)//) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 144 | 0 | $magic = $1; | |||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $info{file} = $file || 1; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$file || 1
MC/DC0%0/1
$file || 1
$file
Truth table0%0/2
A
A= $file
| |||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||
| 147 | else { | ||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | return undef if $file; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 149 | 0 | $magic = ""; | |||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | return undef unless length($buf); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||
| 154 | 0 | my $net_order; | |||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | if ($magic eq "perl-store" && ord(substr($buf, 0, 1)) > 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$magic eq "perl-store" and ord substr($buf, 0, 1) > 1
MC/DC0%0/2
$magic eq "perl-store" and ord substr($buf, 0, 1) > 1
$magic eq "perl-store"
ord substr($buf, 0, 1) > 1
Truth table0%0/3
A and B
A= $magic eq "perl-store"B= ord substr($buf, 0, 1) > 1
| |||||||||||||||||||||||||||||||||
| 156 | 0 | $info{version} = -1; | |||||||||||||||||||||||||||||||
| 157 | 0 | $net_order = 0; | |||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||
| 159 | else { | ||||||||||||||||||||||||||||||||
| 160 | 0 | $buf =~ s/(.)//s; | |||||||||||||||||||||||||||||||
| 161 | 0 | my $major = (ord $1) >> 1; | |||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | return undef if $major > 4; # sanity (assuming we never go that high) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 0 | $info{major} = $major; | |||||||||||||||||||||||||||||||
| 164 | 0 | $net_order = (ord $1) & 0x01; | |||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ($major > 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | return undef unless $buf =~ s/(.)//s; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 167 | 0 | my $minor = ord $1; | |||||||||||||||||||||||||||||||
| 168 | 0 | $info{minor} = $minor; | |||||||||||||||||||||||||||||||
| 169 | 0 | $info{version} = "$major.$minor"; | |||||||||||||||||||||||||||||||
| 170 | 0 | $info{version_nv} = sprintf "%d.%03d", $major, $minor; | |||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||
| 172 | else { | ||||||||||||||||||||||||||||||||
| 173 | 0 | $info{version} = $major; | |||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $info{version_nv} ||= $info{version}; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$info{"version_nv"} ||= $info{"version"}
MC/DC0%0/2
$info{"version_nv"} ||= $info{"version"}
$info{"version_nv"}
$info{"version"}
Truth table0%0/3
A ||= B
A= $info{"version_nv"}B= $info{"version"}
| |||||||||||||||||||||||||||||||||
| 177 | 0 | $info{netorder} = $net_order; | |||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | unless ($net_order) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | return undef unless $buf =~ s/(.)//s; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 181 | 0 | my $len = ord $1; | |||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | return undef unless length($buf) >= $len; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | return undef unless $len == 4 || $len == 8; # sanity | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$len == 4 or $len == 8
MC/DC0%0/2
$len == 4 or $len == 8
$len == 4
$len == 8
Truth table0%0/3
A or B
A= $len == 4B= $len == 8
| |||||||||||||||||||||||||||||||||
| 184 | 0 | @info{qw(byteorder intsize longsize ptrsize)} | |||||||||||||||||||||||||||||||
| 185 | = unpack "a${len}CCC", $buf; | ||||||||||||||||||||||||||||||||
| 186 | 0 | (substr $buf, 0, $len + 3) = ''; | |||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if ($info{version_nv} >= 2.002) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | return undef unless $buf =~ s/(.)//s; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 189 | 0 | $info{nvsize} = ord $1; | |||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||
| 192 | 0 | $info{hdrsize} = $buflen - length($buf); | |||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | 0 | return \%info; | |||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | sub BIN_VERSION_NV { | ||||||||||||||||||||||||||||||
|
Subroutine
BIN_VERSION_NV: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 198 | 0 | sprintf "%d.%03d", BIN_MAJOR(), BIN_MINOR(); | |||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub BIN_WRITE_VERSION_NV { | ||||||||||||||||||||||||||||||
|
Subroutine
BIN_WRITE_VERSION_NV: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 202 | 0 | sprintf "%d.%03d", BIN_MAJOR(), BIN_WRITE_MINOR(); | |||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||
| 205 | # | ||||||||||||||||||||||||||||||||
| 206 | # store | ||||||||||||||||||||||||||||||||
| 207 | # | ||||||||||||||||||||||||||||||||
| 208 | # Store target object hierarchy, identified by a reference to its root. | ||||||||||||||||||||||||||||||||
| 209 | # The stored object tree may later be retrieved to memory via retrieve. | ||||||||||||||||||||||||||||||||
| 210 | # Returns undef if an I/O error occurred, in which case the file is | ||||||||||||||||||||||||||||||||
| 211 | # removed. | ||||||||||||||||||||||||||||||||
| 212 | # | ||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub store { | ||||||||||||||||||||||||||||||
|
Subroutine
store: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 214 | 0 | return _store(\&pstore, @_, 0); | |||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||
| 217 | # | ||||||||||||||||||||||||||||||||
| 218 | # nstore | ||||||||||||||||||||||||||||||||
| 219 | # | ||||||||||||||||||||||||||||||||
| 220 | # Same as store, but in network order. | ||||||||||||||||||||||||||||||||
| 221 | # | ||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub nstore { | ||||||||||||||||||||||||||||||
|
Subroutine
nstore: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 223 | 0 | return _store(\&net_pstore, @_, 0); | |||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||
| 226 | # | ||||||||||||||||||||||||||||||||
| 227 | # lock_store | ||||||||||||||||||||||||||||||||
| 228 | # | ||||||||||||||||||||||||||||||||
| 229 | # Same as store, but flock the file first (advisory locking). | ||||||||||||||||||||||||||||||||
| 230 | # | ||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub lock_store { | ||||||||||||||||||||||||||||||
|
Subroutine
lock_store: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 232 | 0 | return _store(\&pstore, @_, 1); | |||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||
| 235 | # | ||||||||||||||||||||||||||||||||
| 236 | # lock_nstore | ||||||||||||||||||||||||||||||||
| 237 | # | ||||||||||||||||||||||||||||||||
| 238 | # Same as nstore, but flock the file first (advisory locking). | ||||||||||||||||||||||||||||||||
| 239 | # | ||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub lock_nstore { | ||||||||||||||||||||||||||||||
|
Subroutine
lock_nstore: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 241 | 0 | return _store(\&net_pstore, @_, 1); | |||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | # Internal store to file routine | ||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub _store { | ||||||||||||||||||||||||||||||
|
Subroutine
_store: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||
| 246 | 0 | my $xsptr = shift; | |||||||||||||||||||||||||||||||
| 247 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 248 | 0 | my ($file, $use_locking) = @_; | |||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | logcroak "not a reference" unless ref($self); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | logcroak "wrong argument number" unless @_ == 2; # No @foo in arglist | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 251 | 0 | my $FILE; | |||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if ($use_locking) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | open($FILE, ">>", $file) || logcroak "can't write into $file: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 254 | 0 | unless (CAN_FLOCK) { | |||||||||||||||||||||||||||||||
| 255 | logcarp | ||||||||||||||||||||||||||||||||
| 256 | "Storable::lock_store: fcntl/flock emulation broken on $^O"; | ||||||||||||||||||||||||||||||||
| 257 | return undef; | ||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | flock($FILE, LOCK_EX) || | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 260 | logcroak "can't get exclusive lock on $file: $!"; | ||||||||||||||||||||||||||||||||
| 261 | 0 | truncate $FILE, 0; | |||||||||||||||||||||||||||||||
| 262 | # Unlocking will happen when FILE is closed | ||||||||||||||||||||||||||||||||
| 263 | } else { | ||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | open($FILE, ">", $file) || logcroak "can't create $file: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||
| 266 | 0 | binmode $FILE; # Archaic systems... | |||||||||||||||||||||||||||||||
| 267 | 0 | my $da = $@; # Don't mess if called from exception handler | |||||||||||||||||||||||||||||||
| 268 | 0 | my $ret; | |||||||||||||||||||||||||||||||
| 269 | # Call C routine nstore or pstore, depending on network order | ||||||||||||||||||||||||||||||||
| 270 | 0 | eval { $ret = &$xsptr($FILE, $self) }; | |||||||||||||||||||||||||||||||
| 271 | # close will return true on success, so the or short-circuits, the () | ||||||||||||||||||||||||||||||||
| 272 | # expression is true, and for that case the block will only be entered | ||||||||||||||||||||||||||||||||
| 273 | # if $@ is true (ie eval failed) | ||||||||||||||||||||||||||||||||
| 274 | # if close fails, it returns false, $ret is altered, *that* is (also) | ||||||||||||||||||||||||||||||||
| 275 | # false, so the () expression is false, !() is true, and the block is | ||||||||||||||||||||||||||||||||
| 276 | # entered. | ||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if (!(close($FILE) or undef $ret) || $@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
not close $FILE || undef $ret or $@
close $FILE || undef $ret
MC/DC0%0/2
not close $FILE || undef $ret or $@
close $FILE
$@
Truth table0%0/3
not(A) or B
A= close $FILEB= $@
| |||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | unlink($file) or warn "Can't unlink $file: $!\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 282 | 0 | logcroak $@; | |||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||
| 284 | 0 | $@ = $da; | |||||||||||||||||||||||||||||||
| 285 | 0 | return $ret; | |||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | # | ||||||||||||||||||||||||||||||||
| 289 | # store_fd | ||||||||||||||||||||||||||||||||
| 290 | # | ||||||||||||||||||||||||||||||||
| 291 | # Same as store, but perform on an already opened file descriptor instead. | ||||||||||||||||||||||||||||||||
| 292 | # Returns undef if an I/O error occurred. | ||||||||||||||||||||||||||||||||
| 293 | # | ||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub store_fd { | ||||||||||||||||||||||||||||||
|
Subroutine
store_fd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 295 | 0 | return _store_fd(\&pstore, @_); | |||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||
| 298 | # | ||||||||||||||||||||||||||||||||
| 299 | # nstore_fd | ||||||||||||||||||||||||||||||||
| 300 | # | ||||||||||||||||||||||||||||||||
| 301 | # Same as store_fd, but in network order. | ||||||||||||||||||||||||||||||||
| 302 | # | ||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub nstore_fd { | ||||||||||||||||||||||||||||||
|
Subroutine
nstore_fd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 304 | 0 | my ($self, $file) = @_; | |||||||||||||||||||||||||||||||
| 305 | 0 | return _store_fd(\&net_pstore, @_); | |||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||
| 308 | # Internal store routine on opened file descriptor | ||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub _store_fd { | ||||||||||||||||||||||||||||||
|
Subroutine
_store_fd: not called CC=5 SCAR=31.5
| |||||||||||||||||||||||||||||||||
| 310 | 0 | my $xsptr = shift; | |||||||||||||||||||||||||||||||
| 311 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 312 | 0 | my ($file) = @_; | |||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | logcroak "not a reference" unless ref($self); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | logcroak "too many arguments" unless @_ == 1; # No @foo in arglist | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 315 | 0 | my $fd = fileno($file); | |||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | logcroak "not a valid file descriptor" unless defined $fd; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 317 | 0 | $file = do { | |||||||||||||||||||||||||||||||
| 318 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 319 | 0 | \*{ $file }; | |||||||||||||||||||||||||||||||
| 320 | }; | ||||||||||||||||||||||||||||||||
| 321 | 0 | my $da = $@; # Don't mess if called from exception handler | |||||||||||||||||||||||||||||||
| 322 | 0 | my $ret; | |||||||||||||||||||||||||||||||
| 323 | # Call C routine nstore or pstore, depending on network order | ||||||||||||||||||||||||||||||||
| 324 | 0 | eval { $ret = &$xsptr($file, $self) }; | |||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | logcroak $@ if $@ =~ s/\.?\n$/,/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 326 | 0 | local $\; | |||||||||||||||||||||||||||||||
| 327 | 0 | print $file ''; # Autoflush the file if wanted | |||||||||||||||||||||||||||||||
| 328 | 0 | $@ = $da; | |||||||||||||||||||||||||||||||
| 329 | 0 | return $ret; | |||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||
| 332 | # | ||||||||||||||||||||||||||||||||
| 333 | # freeze | ||||||||||||||||||||||||||||||||
| 334 | # | ||||||||||||||||||||||||||||||||
| 335 | # Store object and its hierarchy in memory and return a scalar | ||||||||||||||||||||||||||||||||
| 336 | # containing the result. | ||||||||||||||||||||||||||||||||
| 337 | # | ||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | sub freeze { | ||||||||||||||||||||||||||||||
|
Subroutine
freeze: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 339 | 0 | _freeze(\&mstore, @_); | |||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||
| 342 | # | ||||||||||||||||||||||||||||||||
| 343 | # nfreeze | ||||||||||||||||||||||||||||||||
| 344 | # | ||||||||||||||||||||||||||||||||
| 345 | # Same as freeze but in network order. | ||||||||||||||||||||||||||||||||
| 346 | # | ||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub nfreeze { | ||||||||||||||||||||||||||||||
|
Subroutine
nfreeze: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 348 | 0 | _freeze(\&net_mstore, @_); | |||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||
| 351 | # Internal freeze routine | ||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | sub _freeze { | ||||||||||||||||||||||||||||||
|
Subroutine
_freeze: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 353 | 0 | my $xsptr = shift; | |||||||||||||||||||||||||||||||
| 354 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | logcroak "not a reference" unless ref($self); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | logcroak "too many arguments" unless @_ == 0; # No @foo in arglist | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 357 | 0 | my $da = $@; # Don't mess if called from exception handler | |||||||||||||||||||||||||||||||
| 358 | 0 | my $ret; | |||||||||||||||||||||||||||||||
| 359 | # Call C routine mstore or net_mstore, depending on network order | ||||||||||||||||||||||||||||||||
| 360 | 0 | eval { $ret = &$xsptr($self) }; | |||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 363 | 0 | logcroak $@; | |||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||
| 365 | 0 | $@ = $da; | |||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | return $ret ? $ret : undef; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||
| 369 | # | ||||||||||||||||||||||||||||||||
| 370 | # retrieve | ||||||||||||||||||||||||||||||||
| 371 | # | ||||||||||||||||||||||||||||||||
| 372 | # Retrieve object hierarchy from disk, returning a reference to the root | ||||||||||||||||||||||||||||||||
| 373 | # object of that tree. | ||||||||||||||||||||||||||||||||
| 374 | # | ||||||||||||||||||||||||||||||||
| 375 | # retrieve(file, flags) | ||||||||||||||||||||||||||||||||
| 376 | # flags include by default BLESS_OK=2 | TIE_OK=4 | ||||||||||||||||||||||||||||||||
| 377 | # with flags=0 or the global $Storable::flags set to 0, no resulting object | ||||||||||||||||||||||||||||||||
| 378 | # will be blessed nor tied. | ||||||||||||||||||||||||||||||||
| 379 | # | ||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | sub retrieve { | ||||||||||||||||||||||||||||||
|
Subroutine
retrieve: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 381 | 0 | _retrieve(shift, 0, @_); | |||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||
| 384 | # | ||||||||||||||||||||||||||||||||
| 385 | # lock_retrieve | ||||||||||||||||||||||||||||||||
| 386 | # | ||||||||||||||||||||||||||||||||
| 387 | # Same as retrieve, but with advisory locking. | ||||||||||||||||||||||||||||||||
| 388 | # | ||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | sub lock_retrieve { | ||||||||||||||||||||||||||||||
|
Subroutine
lock_retrieve: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 390 | 0 | _retrieve(shift, 1, @_); | |||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||
| 393 | # Internal retrieve routine | ||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | sub _retrieve { | ||||||||||||||||||||||||||||||
|
Subroutine
_retrieve: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||
| 395 | 0 | my ($file, $use_locking, $flags) = @_; | |||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | $flags = $Storable::flags unless defined $flags; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 397 | 0 | my $FILE; | |||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | open($FILE, "<", $file) || logcroak "can't open $file: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 399 | 0 | binmode $FILE; # Archaic systems... | |||||||||||||||||||||||||||||||
| 400 | 0 | my $self; | |||||||||||||||||||||||||||||||
| 401 | 0 | my $da = $@; # Could be from exception handler | |||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ($use_locking) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 403 | 0 | unless (CAN_FLOCK) { | |||||||||||||||||||||||||||||||
| 404 | logcarp | ||||||||||||||||||||||||||||||||
| 405 | "Storable::lock_store: fcntl/flock emulation broken on $^O"; | ||||||||||||||||||||||||||||||||
| 406 | return undef; | ||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | flock($FILE, LOCK_SH) || logcroak "can't get shared lock on $file: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 409 | # Unlocking will happen when FILE is closed | ||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||
| 411 | 0 | eval { $self = pretrieve($FILE, $flags) }; # Call C routine | |||||||||||||||||||||||||||||||
| 412 | 0 | close($FILE); | |||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 415 | 0 | logcroak $@; | |||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||
| 417 | 0 | $@ = $da; | |||||||||||||||||||||||||||||||
| 418 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||
| 421 | # | ||||||||||||||||||||||||||||||||
| 422 | # fd_retrieve | ||||||||||||||||||||||||||||||||
| 423 | # | ||||||||||||||||||||||||||||||||
| 424 | # Same as retrieve, but perform from an already opened file descriptor instead. | ||||||||||||||||||||||||||||||||
| 425 | # | ||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | sub fd_retrieve { | ||||||||||||||||||||||||||||||
|
Subroutine
fd_retrieve: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 427 | 0 | my ($file, $flags) = @_; | |||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | $flags = $Storable::flags unless defined $flags; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 429 | 0 | my $fd = fileno($file); | |||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | logcroak "not a valid file descriptor" unless defined $fd; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 431 | 0 | my $self; | |||||||||||||||||||||||||||||||
| 432 | 0 | my $da = $@; # Could be from exception handler | |||||||||||||||||||||||||||||||
| 433 | 0 | eval { $self = pretrieve($file, $flags) }; # Call C routine | |||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 436 | 0 | logcroak $@; | |||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||
| 438 | 0 | $@ = $da; | |||||||||||||||||||||||||||||||
| 439 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | sub retrieve_fd { &fd_retrieve } # Backward compatibility | ||||||||||||||||||||||||||||||
|
Subroutine
retrieve_fd: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||
| 444 | # | ||||||||||||||||||||||||||||||||
| 445 | # thaw | ||||||||||||||||||||||||||||||||
| 446 | # | ||||||||||||||||||||||||||||||||
| 447 | # Recreate objects in memory from an existing frozen image created | ||||||||||||||||||||||||||||||||
| 448 | # by freeze. If the frozen image passed is undef, return undef. | ||||||||||||||||||||||||||||||||
| 449 | # | ||||||||||||||||||||||||||||||||
| 450 | # thaw(frozen_obj, flags) | ||||||||||||||||||||||||||||||||
| 451 | # flags include by default BLESS_OK=2 | TIE_OK=4 | ||||||||||||||||||||||||||||||||
| 452 | # with flags=0 or the global $Storable::flags set to 0, no resulting object | ||||||||||||||||||||||||||||||||
| 453 | # will be blessed nor tied. | ||||||||||||||||||||||||||||||||
| 454 | # | ||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | sub thaw { | ||||||||||||||||||||||||||||||
|
Subroutine
thaw: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 456 | 0 | my ($frozen, $flags) = @_; | |||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | $flags = $Storable::flags unless defined $flags; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | return undef unless defined $frozen; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 459 | 0 | my $self; | |||||||||||||||||||||||||||||||
| 460 | 0 | my $da = $@; # Could be from exception handler | |||||||||||||||||||||||||||||||
| 461 | 0 | eval { $self = mretrieve($frozen, $flags) }; # Call C routine | |||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | $@ =~ s/\.?\n$/,/ unless ref $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 464 | 0 | logcroak $@; | |||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||
| 466 | 0 | $@ = $da; | |||||||||||||||||||||||||||||||
| 467 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||
| 470 | # | ||||||||||||||||||||||||||||||||
| 471 | # _make_re($re, $flags) | ||||||||||||||||||||||||||||||||
| 472 | # | ||||||||||||||||||||||||||||||||
| 473 | # Internal function used to thaw a regular expression. | ||||||||||||||||||||||||||||||||
| 474 | # | ||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||
| 476 | 7 | my $re_flags; | |||||||||||||||||||||||||||||||
| 477 | 7 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=18.9
| |||||||||||||||||||||||||||||||||
| 478 | 7 | ▶ | if ($] < 5.010) { | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 479 | 0 | $re_flags = qr/\A[imsx]*\z/; | |||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||
| 481 | elsif ($] < 5.014) { | ||||||||||||||||||||||||||||||||
| 482 | 0 | $re_flags = qr/\A[msixp]*\z/; | |||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||
| 484 | elsif ($] < 5.022) { | ||||||||||||||||||||||||||||||||
| 485 | 0 | $re_flags = qr/\A[msixpdual]*\z/; | |||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||
| 487 | else { | ||||||||||||||||||||||||||||||||
| 488 | 7 | $re_flags = qr/\A[msixpdualn]*\z/; | |||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | sub _make_re { | ||||||||||||||||||||||||||||||
|
Subroutine
_make_re: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 493 | 0 | my ($re, $flags) = @_; | |||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | $flags =~ $re_flags | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 496 | or die "regexp flags invalid"; | ||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||
| 498 | 0 | my $qr = eval "qr/\$re/$flags"; | |||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||
| 501 | 0 | $qr; | |||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||
| 504 | 7 | ▶ | if ($] < 5.012) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 505 | eval <<'EOS' | ||||||||||||||||||||||||||||||||
| 506 | sub _regexp_pattern { | ||||||||||||||||||||||||||||||||
| 507 | my $re = "" . shift; | ||||||||||||||||||||||||||||||||
| 508 | $re =~ /\A\(\?([xism]*)(?:-[xism]*)?:(.*)\)\z/s | ||||||||||||||||||||||||||||||||
| 509 | or die "Cannot parse regexp /$re/"; | ||||||||||||||||||||||||||||||||
| 510 | return ($2, $1); | ||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||
| 512 | 1 | ||||||||||||||||||||||||||||||||
| 513 | EOS | ||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | or die "Cannot define _regexp_pattern: $@"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||
| 517 | 7 | 1; | |||||||||||||||||||||||||||||||
| 518 | __END__ | ||||||||||||||||||||||||||||||||