| 1 | # Copyrights 2001-2023 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||||||||||||||||
| 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.03. | ||||||||||||||||||||||||||||
| 5 | # This code is part of distribution Mail-Message. 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 Mail::Box::FastScalar; | ||||||||||||||||||||||||||||
| 10 | 34 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 34 | $VERSION = '3.013'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 34 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 34 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 34 | ▶ | use integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | sub new($) { | ||||||||||||||||||||||||||||
| 20 | 12 | ▶ | my ($class, $ref) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 12 | ▶ | $$ref = '' unless defined $$ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 12 | bless { ref => $ref, pos => 0 }, $class; | |||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | ▶ | sub autoflush() {} | |||||||||||||||||||||||||||
|
Subroutine
autoflush: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | ▶ | sub binmode() {} | |||||||||||||||||||||||||||
|
Subroutine
binmode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub clearerr { return 0; } | ||||||||||||||||||||||||||
|
Subroutine
clearerr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | ▶ | sub flush() {} | |||||||||||||||||||||||||||
|
Subroutine
flush: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub sync() { return 0; } | ||||||||||||||||||||||||||
|
Subroutine
sync: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub opened() { return $_[0]->{ref}; } | ||||||||||||||||||||||||||
|
Subroutine
opened: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub open($) { | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
open: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | ${$_[1]} = '' unless defined(${$_[1]}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | $self->{ref} = $_[1]; | |||||||||||||||||||||||||||
| 42 | 0 | $self->{pos} = 0; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | sub close() { | ||||||||||||||||||||||||||||
| 46 | 12 | ▶ | undef $_[0]->{ref}; | ||||||||||||||||||||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub eof() { | ||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
eof: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | return $self->{pos} >= length(${$self->{ref}}); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | sub getc() { | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
getc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | return substr(${$self->{ref}}, $self->{pos}++, 1); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | sub print { | ||||||||||||||||||||||||||||
| 62 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
print: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | 0 | my $pos = $self->{pos}; | |||||||||||||||||||||||||||
| 64 | 0 | my $ref = $self->{ref}; | |||||||||||||||||||||||||||
| 65 | 0 | my $len = length($$ref); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ($pos >= $len) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 0 | $$ref .= $_ foreach @_; | |||||||||||||||||||||||||||
| 69 | 0 | $self->{pos} = length($$ref); | |||||||||||||||||||||||||||
| 70 | } else { | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | my $buf = $#_ ? join('', @_) : $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | $len = length($buf); | |||||||||||||||||||||||||||
| 74 | 0 | substr($$ref, $pos, $len) = $buf; | |||||||||||||||||||||||||||
| 75 | 0 | $self->{pos} = $pos + $len; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 0 | 1; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | sub read($$;$) { | ||||||||||||||||||||||||||||
| 81 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
read: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 82 | 0 | my $buf = substr(${$self->{ref}}, $self->{pos}, $_[2]); | |||||||||||||||||||||||||||
| 83 | 0 | $self->{pos} += $_[2]; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | ($_[3] ? substr($_[1], $_[3]) : $_[1]) = $buf; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | return length($buf); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | sub sysread($$;$) { | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | return shift()->read(@_); | ||||||||||||||||||||||||||
|
Subroutine
sysread: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | sub seek($$) { | ||||||||||||||||||||||||||||
| 94 | 20 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
seek: called CC=6 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 20 | my $whence = $_[2]; | |||||||||||||||||||||||||||
| 96 | 20 | my $len = length(${$self->{ref}}); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 20 | ▶ | if ($whence == 0) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 99 | 20 | $self->{pos} = $_[1]; | |||||||||||||||||||||||||||
| 100 | } elsif ($whence == 1) { | ||||||||||||||||||||||||||||
| 101 | 0 | $self->{pos} += $_[1]; | |||||||||||||||||||||||||||
| 102 | } elsif ($whence == 2) { | ||||||||||||||||||||||||||||
| 103 | 0 | $self->{pos} = $len + $_[1]; | |||||||||||||||||||||||||||
| 104 | } else { | ||||||||||||||||||||||||||||
| 105 | 0 | return; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 20 | ▶ | if ($self->{pos} > $len) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 108 | 0 | $self->{pos} = $len; | |||||||||||||||||||||||||||
| 109 | } elsif ($self->{pos} < 0) { | ||||||||||||||||||||||||||||
| 110 | 0 | $self->{pos} = 0; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | 20 | return 1; | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | sub sysseek($$) { | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | return $_[0]->seek($_[1], $_[2]); | ||||||||||||||||||||||||||
|
Subroutine
sysseek: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | sub setpos($) { | ||||||||||||||||||||||||||||
| 120 | 20 | ▶ | return $_[0]->seek($_[1], 0); | ||||||||||||||||||||||||||
|
Subroutine
setpos: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | sub sref() { | ||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return $_[0]->{ref}; | ||||||||||||||||||||||||||
|
Subroutine
sref: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | sub getpos() { | ||||||||||||||||||||||||||||
| 128 | 85 | ▶ | return $_[0]->{pos}; | ||||||||||||||||||||||||||
|
Subroutine
getpos: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | sub tell() { | ||||||||||||||||||||||||||||
| 132 | 163 | ▶ | return $_[0]->{pos}; | ||||||||||||||||||||||||||
|
Subroutine
tell: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | sub write($$;$) { | ||||||||||||||||||||||||||||
| 136 | 0 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
write: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 137 | 0 | my $pos = $self->{pos}; | |||||||||||||||||||||||||||
| 138 | 0 | my $ref = $self->{ref}; | |||||||||||||||||||||||||||
| 139 | 0 | my $len = length($$ref); | |||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ($pos >= $len) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | $$ref .= substr($_[1], $_[3] || 0, $_[2]); | ||||||||||||||||||||||||||
|
Condition0%0/2
$_[3] || 0
MC/DC0%0/1
$_[3] || 0
$_[3]
Truth table0%0/2
A
A= $_[3]
| |||||||||||||||||||||||||||||
| 143 | 0 | $self->{pos} = length($$ref); | |||||||||||||||||||||||||||
| 144 | 0 | $len = $self->{pos} - $len; | |||||||||||||||||||||||||||
| 145 | } else { | ||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $buf = substr($_[1], $_[3] || 0, $_[2]); | ||||||||||||||||||||||||||
|
Condition0%0/2
$_[3] || 0
MC/DC0%0/1
$_[3] || 0
$_[3]
Truth table0%0/2
A
A= $_[3]
| |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 0 | $len = length($buf); | |||||||||||||||||||||||||||
| 149 | 0 | substr($$ref, $pos, $len) = $buf; | |||||||||||||||||||||||||||
| 150 | 0 | $self->{pos} = $pos + $len; | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | 0 | return $len; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | sub syswrite($;$$) { | ||||||||||||||||||||||||||||
| 156 | 0 | ▶ | return shift()->write(@_); | ||||||||||||||||||||||||||
|
Subroutine
syswrite: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub getline() { | ||||||||||||||||||||||||||||
| 160 | 200 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
getline: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 161 | 200 | my $ref = $self->{ref}; | |||||||||||||||||||||||||||
| 162 | 200 | my $pos = $self->{pos}; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 200 | ▶ | if (!defined($/) || (my $idx = index($$ref, $/, $pos)) == -1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $/ or (my $idx = index($$ref, $/, $pos)) == -1
MC/DC50%1/2
not defined $/ or (my $idx = index($$ref, $/, $pos)) == -1
not defined $/
(my $idx = index($$ref, $/, $pos)) == -1
Truth table66%2/3
not(A) or B
A= not defined $/B= (my $idx = index($$ref, $/, $pos)) == -1
| |||||||||||||||||||||||||||||
| 165 | 2 | ▶ | return if ($pos >= length($$ref)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 2 | $self->{pos} = length($$ref); | |||||||||||||||||||||||||||
| 167 | 2 | return substr($$ref, $pos); | |||||||||||||||||||||||||||
| 168 | } else { | ||||||||||||||||||||||||||||
| 169 | 198 | return substr($$ref, $pos, ($self->{pos} = $idx + length($/)) - $pos); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | sub getlines() { | ||||||||||||||||||||||||||||
| 174 | 12 | ▶ | my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
getlines: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 175 | 12 | my @lines; | |||||||||||||||||||||||||||
| 176 | 12 | my $ref = $self->{ref}; | |||||||||||||||||||||||||||
| 177 | 12 | my $pos = $self->{pos}; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 12 | ▶ | if (defined($/)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 12 | my $idx; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 12 | ▶ | while (($idx = index($$ref, $/, $pos)) != -1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 14 | push(@lines, substr($$ref, $pos, ($idx + 1) - $pos)); | |||||||||||||||||||||||||||
| 184 | 14 | $pos = $idx + 1; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | 12 | my $r = substr($$ref, $pos); | |||||||||||||||||||||||||||
| 188 | 12 | ▶ | if (length($r) > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 0 | push(@lines, $r); | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | 12 | $self->{pos} = length($$ref); | |||||||||||||||||||||||||||
| 192 | 12 | ▶ | return wantarray() ? @lines : \@lines; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | sub TIEHANDLE { | ||||||||||||||||||||||||||||
| 196 | 0 | ▶ | ((defined($_[1]) && UNIVERSAL::isa($_[1], "Mail::Box::FastScalar")) | ||||||||||||||||||||||||||
|
Subroutine
TIEHANDLE: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/3
defined $_[1] and UNIVERSAL::isa($_[1], "Mail::Box::FastScalar")
MC/DC0%0/2
defined $_[1] and UNIVERSAL::isa($_[1], "Mail::Box::FastScalar")
defined $_[1]
UNIVERSAL::isa($_[1], "Mail::Box::FastScalar")
Truth table0%0/3
A and B
A= defined $_[1]B= UNIVERSAL::isa($_[1], "Mail::Box::FastScalar")
| |||||||||||||||||||||||||||||
| 197 | ? $_[1] : shift->new(@_)); | ||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub GETC { shift()->getc(@_) } | ||||||||||||||||||||||||||
|
Subroutine
GETC: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub PRINT { shift()->print(@_) } | ||||||||||||||||||||||||||
|
Subroutine
PRINT: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 202 | 0 | ▶ | sub PRINTF { shift()->print(sprintf(shift, @_)) } | ||||||||||||||||||||||||||
|
Subroutine
PRINTF: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub READ { shift()->read(@_) } | ||||||||||||||||||||||||||
|
Subroutine
READ: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub READLINE { wantarray ? shift()->getlines(@_) : shift()->getline(@_) } | ||||||||||||||||||||||||||
|
Subroutine
READLINE: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub WRITE { shift()->write(@_); } | ||||||||||||||||||||||||||
|
Subroutine
WRITE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub CLOSE { shift()->close(@_); } | ||||||||||||||||||||||||||
|
Subroutine
CLOSE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 207 | 0 | ▶ | sub SEEK { shift()->seek(@_); } | ||||||||||||||||||||||||||
|
Subroutine
SEEK: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub TELL { shift()->tell(@_); } | ||||||||||||||||||||||||||
|
Subroutine
TELL: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub EOF { shift()->eof(@_); } | ||||||||||||||||||||||||||
|
Subroutine
EOF: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 34 | 1; | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 34 | 1; | |||||||||||||||||||||||||||