line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PerlIO::eol; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
57738
|
use 5.007003; |
|
1
|
|
|
|
|
11
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use XSLoader; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
9
|
1
|
|
|
1
|
|
3
|
use Exporter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
93
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# symbols to export on request |
15
|
|
|
|
|
|
|
our @EXPORT_OK = qw(eol_is_mixed CR LF CRLF NATIVE); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
XSLoader::load __PACKAGE__, $VERSION; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
PerlIO::eol - PerlIO layer for normalizing line endings |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 VERSION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This document describes version 0.15 of PerlIO::eol, released |
28
|
|
|
|
|
|
|
December 18, 2006. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 SYNOPSIS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
binmode STDIN, ":raw:eol(LF)"; |
33
|
|
|
|
|
|
|
binmode STDOUT, ":raw:eol(CRLF)"; |
34
|
|
|
|
|
|
|
open FH, "+<:raw:eol(LF-Native)", "file"; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
binmode STDOUT, ":raw:eol(CRLF?)"; # warns on mixed newlines |
37
|
|
|
|
|
|
|
binmode STDOUT, ":raw:eol(CRLF!)"; # dies on mixed newlines |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use PerlIO::eol qw( eol_is_mixed ); |
40
|
|
|
|
|
|
|
my $pos = eol_is_mixed( "mixed\nstring\r" ); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
This layer normalizes any of C, C, C and C into the |
45
|
|
|
|
|
|
|
designated line ending. It works for both input and output handles. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
If you specify two different line endings joined by a C<->, it will use the |
48
|
|
|
|
|
|
|
first one for reading and the second one for writing. For example, the |
49
|
|
|
|
|
|
|
C encoding means that all input should be normalized to C, and |
50
|
|
|
|
|
|
|
all output should be normalized to C. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
By default, data with mixed newlines are normalized silently. Append a C |
53
|
|
|
|
|
|
|
to the line ending will raise a fatal exception when mixed newlines are |
54
|
|
|
|
|
|
|
spotted. Append a C> will raise a warning instead. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
It is advised to pop any potential C<:crlf> or encoding layers before this |
57
|
|
|
|
|
|
|
layer; this is usually done using a C<:raw> prefix. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This module also optionally exports a C function; it takes a |
60
|
|
|
|
|
|
|
string and returns the position of the first inconsistent line ending found |
61
|
|
|
|
|
|
|
in that string, or C<0> if the line endings are consistent. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
The C, C, C and C constants are also exported at request. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 EXPORTS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 CR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
A carriage return constant. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 CRLF |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
A carriage return/line feed constant. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 LF |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
A line feed constant. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 NATIVE |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The native line ending. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 eol_is_mixed |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This module also optionally exports a C function; it takes a |
86
|
|
|
|
|
|
|
string and returns the position of the first inconsistent line ending found |
87
|
|
|
|
|
|
|
in that string, or C<0> if the line endings are consistent. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHORS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Audrey Tang Eautrijus@autrijus.orgE. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Janitorial help by Gaal Yahas Egaal@forum2.orgE. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Inspired by L by Ben Morrow, EPerlIO-eol@morrow.me.ukE. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Copyright 2004-2006 by Audrey Tang Eaudreyt@audreyt.orgE. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
102
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
See L |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |