line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Encode::Newlines; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
12881
|
use 5.007003; |
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
14
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
8
|
|
|
|
|
|
|
our $AllowMixed = 0; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
723
|
use parent qw(Encode::Encoding); |
|
1
|
|
|
|
|
283
|
|
|
1
|
|
|
|
|
6
|
|
11
|
1
|
|
|
1
|
|
60
|
use constant CR => "\015"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
12
|
1
|
|
|
1
|
|
5
|
use constant LF => "\012"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
13
|
1
|
|
|
1
|
|
5
|
use constant CRLF => "\015\012"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
101
|
|
14
|
1
|
50
|
|
|
|
73
|
use constant Native => ( |
|
|
50
|
|
|
|
|
|
15
|
|
|
|
|
|
|
($^O =~ /^(?:MSWin|cygwin|dos|os2)/) ? CRLF : |
16
|
|
|
|
|
|
|
($^O =~ /^MacOS/) ? CR : LF |
17
|
1
|
|
|
1
|
|
5
|
); |
|
1
|
|
|
|
|
1
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
foreach my $in (qw( CR LF CRLF Native )) { |
20
|
|
|
|
|
|
|
foreach my $out (qw( CR LF CRLF Native )) { |
21
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
87
|
|
22
|
|
|
|
|
|
|
my $name = (($in eq $out) ? $in : "$in-$out"); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$Encode::Encoding{$name} = bless { |
25
|
|
|
|
|
|
|
Name => $name, |
26
|
|
|
|
|
|
|
decode => &$in, |
27
|
|
|
|
|
|
|
encode => &$out, |
28
|
|
|
|
|
|
|
} => __PACKAGE__; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
foreach my $func (qw( decode encode )) { |
33
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
304
|
|
34
|
|
|
|
|
|
|
*$func = sub ($$;$) { |
35
|
14
|
|
|
14
|
|
7710
|
my ($obj, $str, $chk) = @_; |
36
|
|
|
|
|
|
|
|
37
|
14
|
100
|
|
|
|
89
|
if ($AllowMixed) { |
|
|
50
|
|
|
|
|
|
38
|
1
|
|
|
|
|
10
|
$str =~ s/(?:\015\012?|\012)/$obj->{$func}/g; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
elsif ($str =~ /((?:\015\012?|\012))/) { |
41
|
13
|
|
|
|
|
27
|
my $eol = $1; |
42
|
|
|
|
|
|
|
|
43
|
13
|
100
|
|
|
|
29
|
if ($eol eq CRLF) { |
44
|
5
|
|
|
|
|
25
|
require Carp; |
45
|
5
|
50
|
|
|
|
29
|
Carp::croak('Mixed newlines') |
46
|
|
|
|
|
|
|
if $str =~ /\015(?!\012)|(?
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
8
|
|
|
|
|
41
|
require Carp; |
50
|
8
|
100
|
|
|
|
329
|
Carp::croak('Mixed newlines') |
|
|
100
|
|
|
|
|
|
51
|
|
|
|
|
|
|
if index($str, (($eol eq CR) ? LF : CR)) >= 0; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
11
|
|
|
|
|
138
|
$str =~ s/$eol/$obj->{$func}/g; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
12
|
50
|
|
|
|
31
|
$_[1] = '' if $chk; |
58
|
12
|
|
|
|
|
40
|
return $str; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
0
|
1
|
|
sub perlio_ok { 0 } |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |