File Coverage

blib/lib/Email/MIME/RFC2047/Parser.pm
Criterion Covered Total %
statement 15 15 100.0
branch 6 8 75.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 24 26 92.3


line stmt bran cond sub pod time code
1             package Email::MIME::RFC2047::Parser;
2             $Email::MIME::RFC2047::Parser::VERSION = '0.95';
3 4     4   26 use strict;
  4         6  
  4         123  
4 4     4   19 use warnings;
  4         7  
  4         759  
5              
6             # ABSTRACT: Base class for parsers
7              
8             sub _parse_error {
9 9     9   14 my ($class, $string_ref, $what) = @_;
10              
11 9         8 my $text;
12 9         14 my $pos = pos($$string_ref);
13 9 100       23 $pos = 0 if !defined($pos);
14              
15 9 100       20 if ($pos < length($$string_ref)) {
16 6         16 my $char = substr($$string_ref, $pos, 1);
17 6 50       32 $text = defined($what) ?
18             "invalid $what at character '$char', pos $pos in string" :
19             "unexpected character '$char' at pos $pos in string";
20             }
21             else {
22 3 50       13 $text = defined($what) ?
23             "incomplete or missing $what at end of string" :
24             "unexpected end of string";
25             }
26              
27 9         66 die("Parse error in MIME header: $text $$string_ref\n");
28             }
29              
30             1;
31              
32             __END__