| 1 | # This code is part of Perl distribution Mail-Message version 4.05. | ||||||||||||||||||||||||||||
| 2 | # The POD got stripped from this file by OODoc version 3.06. | ||||||||||||||||||||||||||||
| 3 | # For contributors see file ChangeLog. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2001-2026 by Mark Overmeer. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 9 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | package Mail::Box::FastScalar;{ | ||||||||||||||||||||||||||||
| 13 | 37 | our $VERSION = '4.05'; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 37 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 37 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 37 | ▶ | use integer; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 37 | ▶ | use Log::Report 'mail-message', import => [ qw// ]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 37 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | #-------------------- | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub new(;$) | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | { my ($class, $ref) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 0 | (bless +{ }, $class)->open($ref); | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub autoflush() {} | ||||||||||||||||||||||||||
|
Subroutine
autoflush: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub binmode() {} | ||||||||||||||||||||||||||
|
Subroutine
binmode: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub clearerr { 0 } | ||||||||||||||||||||||||||
|
Subroutine
clearerr: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub flush() {} | ||||||||||||||||||||||||||
|
Subroutine
flush: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 36 | sub sync() { 0 } | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | sub opened() { $_[0]->{ref} } | ||||||||||||||||||||||||||
|
Subroutine
opened: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | sub open($) | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | { my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
open: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $ref = $self->{ref} = $_[1] // \(my $tmp); | ||||||||||||||||||||||||||
|
Condition0%0/2
$_[1] // \my $tmp
MC/DC0%0/1
$_[1] // \my $tmp
$_[1]
Truth table0%0/2
A
A= $_[1]
| |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | $$ref //= ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$$ref //= ""
MC/DC0%0/1
$$ref //= ""
$$ref
Truth table0%0/2
A
A= $$ref
| |||||||||||||||||||||||||||||
| 43 | 0 | $self->{pos} = 0; | |||||||||||||||||||||||||||
| 44 | 0 | $self; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub close() { undef $_[0]->{ref} } | ||||||||||||||||||||||||||
|
Subroutine
close: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | sub eof() | ||||||||||||||||||||||||||||
| 50 | 0 | ▶ | { my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
eof: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 0 | $self->{pos} >= length ${$self->{ref}}; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub getc() | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | { my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
getc: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | substr ${$self->{ref}}, $self->{pos}++, 1; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub print | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
print: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 61 | 0 | my $pos = $self->{pos}; | |||||||||||||||||||||||||||
| 62 | 0 | my $ref = $self->{ref}; | |||||||||||||||||||||||||||
| 63 | 0 | my $len = length $$ref; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($pos >= $len) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | { $$ref .= $_ for @_; | |||||||||||||||||||||||||||
| 67 | 0 | $self->{pos} = length $$ref; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | else | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | { my $buf = $#_ ? join('', @_) : $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | $len = length $buf; | |||||||||||||||||||||||||||
| 72 | 0 | substr($$ref, $pos, $len) = $buf; | |||||||||||||||||||||||||||
| 73 | 0 | $self->{pos} = $pos + $len; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | 1; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | sub read($$;$) | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | { my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
read: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 0 | my $buf = substr ${$self->{ref}}, $self->{pos}, $_[2]; | |||||||||||||||||||||||||||
| 82 | 0 | $self->{pos} += $_[2]; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | ($_[3] ? substr($_[1], $_[3]) : $_[1]) = $buf; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | length $buf; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub sysread($$;$) { shift->read(@_) } | ||||||||||||||||||||||||||
|
Subroutine
sysread: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | sub seek($$) | ||||||||||||||||||||||||||||
| 91 | 0 | ▶ | { my ($self, $delta, $whence) = @_; | ||||||||||||||||||||||||||
|
Subroutine
seek: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 92 | 0 | my $len = length ${$self->{ref}}; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ($whence == 0) { $self->{pos} = $delta } | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 95 | 0 | elsif ($whence == 1) { $self->{pos} += $delta } | |||||||||||||||||||||||||||
| 96 | 0 | elsif ($whence == 2) { $self->{pos} = $len + $delta } | |||||||||||||||||||||||||||
| 97 | 0 | else { return } | |||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if($self->{pos} > $len) { $self->{pos} = $len } | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 100 | 0 | elsif($self->{pos} < 0) { $self->{pos} = 0 } | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | 1; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | ▶ | sub sysseek($$) { $_[0]->seek($_[1], $_[2]) } | ||||||||||||||||||||||||||
|
Subroutine
sysseek: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub setpos($) { $_[0]->seek($_[1], 0) } | ||||||||||||||||||||||||||
|
Subroutine
setpos: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub sref() { $_[0]->{ref} } | ||||||||||||||||||||||||||
|
Subroutine
sref: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub getpos() { $_[0]->{pos} } | ||||||||||||||||||||||||||
|
Subroutine
getpos: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub tell() { $_[0]->{pos} } | ||||||||||||||||||||||||||
|
Subroutine
tell: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | sub write($$;$) | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | { my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
write: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 113 | 0 | my $pos = $self->{pos}; | |||||||||||||||||||||||||||
| 114 | 0 | my $ref = $self->{ref}; | |||||||||||||||||||||||||||
| 115 | 0 | my $len = length $$ref; | |||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if($pos >= $len) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 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]
| |||||||||||||||||||||||||||||
| 119 | 0 | $self->{pos} = length $$ref; | |||||||||||||||||||||||||||
| 120 | 0 | $len = $self->{pos} - $len; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | else | ||||||||||||||||||||||||||||
| 123 | 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]
| |||||||||||||||||||||||||||||
| 124 | 0 | $len = length $buf; | |||||||||||||||||||||||||||
| 125 | 0 | substr($$ref, $pos, $len) = $buf; | |||||||||||||||||||||||||||
| 126 | 0 | $self->{pos} = $pos + $len; | |||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | $len; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub syswrite($;$$) { shift->write(@_) } | ||||||||||||||||||||||||||
|
Subroutine
syswrite: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | sub getline() | ||||||||||||||||||||||||||||
| 135 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getline: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 136 | 0 | my $ref = $self->{ref}; | |||||||||||||||||||||||||||
| 137 | 0 | my $pos = $self->{pos}; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | my $idx; | |||||||||||||||||||||||||||
| 140 | 0 | ▶ | if( !defined $/ || ($idx = index($$ref, $/, $pos)) == -1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $/ or ($idx = index($$ref, $/, $pos)) == -1
MC/DC0%0/2
not defined $/ or ($idx = index($$ref, $/, $pos)) == -1
not defined $/
($idx = index($$ref, $/, $pos)) == -1
Truth table0%0/3
not(A) or B
A= not defined $/B= ($idx = index($$ref, $/, $pos)) == -1
| |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | { return if $pos >= length $$ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | $self->{pos} = length $$ref; | |||||||||||||||||||||||||||
| 143 | 0 | return substr $$ref, $pos; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | substr $$ref, $pos, ($self->{pos} = $idx + length $/) - $pos; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | sub getlines() | ||||||||||||||||||||||||||||
| 150 | 0 | ▶ | { my $self = $_[0]; | ||||||||||||||||||||||||||
|
Subroutine
getlines: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 151 | 0 | my $ref = $self->{ref}; | |||||||||||||||||||||||||||
| 152 | 0 | my $pos = $self->{pos}; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | my @lines; | |||||||||||||||||||||||||||
| 155 | 0 | ▶ | if(defined $/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 0 | { my $idx; | |||||||||||||||||||||||||||
| 157 | 0 | my $sep_length = length $/; | |||||||||||||||||||||||||||
| 158 | 0 | ▶ | while(($idx = index($$ref, $/, $pos)) != -1) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 0 | { push @lines, substr($$ref, $pos, $idx + $sep_length - $pos); | |||||||||||||||||||||||||||
| 160 | 0 | $pos = $idx + $sep_length; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | 0 | my $r = substr $$ref, $pos; | |||||||||||||||||||||||||||
| 164 | 0 | ▶ | push @lines, $r if length $r > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | $self->{pos} = length $$ref; | |||||||||||||||||||||||||||
| 167 | 0 | ▶ | wantarray ? @lines : \@lines; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | # Call OO, because this module might be extended | ||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub TIEHANDLE { blessed $_[1] && $_[1]->isa(__PACKAGE__) ? $_[1] : shift->new(@_) } | ||||||||||||||||||||||||||
|
Subroutine
TIEHANDLE: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/3
builtin::blessed($_[1]) and $_[1]->isa(__PACKAGE__)
MC/DC0%0/2
builtin::blessed($_[1]) and $_[1]->isa(__PACKAGE__)
builtin::blessed($_[1])
$_[1]->isa(__PACKAGE__)
Truth table0%0/3
A and B
A= builtin::blessed($_[1])B= $_[1]->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub GETC { shift->getc(@_) } | ||||||||||||||||||||||||||
|
Subroutine
GETC: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | sub PRINT { shift->print(@_) } | ||||||||||||||||||||||||||
|
Subroutine
PRINT: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub PRINTF { shift->print(sprintf shift, @_) } | ||||||||||||||||||||||||||
|
Subroutine
PRINTF: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub READ { shift->read(@_) } | ||||||||||||||||||||||||||
|
Subroutine
READ: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 176 | 0 | ▶ | sub READLINE { wantarray ? shift->getlines(@_) : shift->getline(@_) } | ||||||||||||||||||||||||||
|
Subroutine
READLINE: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub WRITE { shift->write(@_) } | ||||||||||||||||||||||||||
|
Subroutine
WRITE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sub CLOSE { shift->close(@_) } | ||||||||||||||||||||||||||
|
Subroutine
CLOSE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 179 | 0 | ▶ | sub SEEK { shift->seek(@_) } | ||||||||||||||||||||||||||
|
Subroutine
SEEK: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 180 | 0 | ▶ | sub TELL { shift->tell(@_) } | ||||||||||||||||||||||||||
|
Subroutine
TELL: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub EOF { shift->eof(@_) } | ||||||||||||||||||||||||||
|
Subroutine
EOF: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 37 | 1; | |||||||||||||||||||||||||||