| 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::Message::Field::Fast;{ | ||||||||||||||||||||
| 13 | 45 | our $VERSION = '4.05'; | |||||||||||||||||||
| 14 | } | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 45 | ▶ | use parent 'Mail::Message::Field'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 45 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 45 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 45 | ▶ | use Log::Report 'mail-message', import => [ qw// ]; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 45 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | #-------------------- | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | # The DATA is stored as: [ NAME, FOLDED-BODY ] | ||||||||||||||||||||
| 28 | # The body is kept in a folded fashion, where each line starts with | ||||||||||||||||||||
| 29 | # a single blank. | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | sub new($;$@) | ||||||||||||||||||||
| 33 | 1959 | ▶ | { my $class = shift; | ||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 1959 | ▶ | my ($name, $body) = $class->consume(@_==1 ? (shift) : (shift, shift)); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 1959 | ▶ | defined $body or return (); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 1959 | my $self = bless +[$name, $body], $class; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | # Attributes | ||||||||||||||||||||
| 41 | 1959 | ▶ | $self->comment(shift) if @_==1; # one attribute line | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 1959 | ▶ | $self->attribute(shift, shift) while @_ > 1; # attribute pairs | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 43 | 1959 | $self; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | sub clone() | ||||||||||||||||||||
| 47 | 1664 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 48 | 1664 | bless +[ @$self ], ref $self; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | sub length() | ||||||||||||||||||||
| 52 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 53 | 0 | length($self->[0]) + 1 + length($self->[1]); | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 5252 | ▶ | sub name() { lc shift->[0] } | ||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 57 | 16 | ▶ | sub Name() { $_[0]->[0] } | ||||||||||||||||||
|
Subroutine
Name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | sub folded() | ||||||||||||||||||||
| 60 | 276 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
folded: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 61 | 276 | ▶ | wantarray or return $self->[0] .':'. $self->[1]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 52 | my @lines = $self->foldedBody; | |||||||||||||||||||
| 64 | 52 | my $first = $self->[0]. ':'. shift @lines; | |||||||||||||||||||
| 65 | 52 | ($first, @lines); | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | sub unfoldedBody($;@) | ||||||||||||||||||||
| 69 | 2858 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
unfoldedBody: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 2858 | ▶ | $self->[1] = $self->fold($self->[0], @_) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | if @_; | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 2858 | $self->unfold($self->[1]); | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | sub foldedBody($) | ||||||||||||||||||||
| 78 | 219 | ▶ | { my ($self, $body) = @_; | ||||||||||||||||||
|
Subroutine
foldedBody: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 79 | 219 | ▶ | if(@_==2) { $self->[1] = $body } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 80 | 215 | else { $body = $self->[1] } | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 219 | ▶ | wantarray ? (split m/^/, $body) : $body; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | # For performance reasons only | ||||||||||||||||||||
| 86 | sub print(;$) | ||||||||||||||||||||
| 87 | 131 | ▶ | { my $self = shift; | ||||||||||||||||||
|
Subroutine
print: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||
| 88 | 131 | ▶ | my $fh = shift || select; | ||||||||||||||||||
|
Condition33%1/3
shift() || select()
MC/DC0%0/2
shift() || select()
shift()
select()
Truth table33%1/3
A || B
A= shift()B= select()
| |||||||||||||||||||||
| 89 | 131 | $fh->print($self->[0].':'.$self->[1]); | |||||||||||||||||||
| 90 | 131 | $self; | |||||||||||||||||||
| 91 | } | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 45 | 1; | |||||||||||||||||||