| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package IO::Mark::Buffer; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
58
|
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
38
|
|
|
5
|
2
|
|
|
2
|
|
9
|
use Carp; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
90
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
934
|
use IO::Mark::Cache; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
43
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1609
|
use version; our $VERSION = qv( '0.0.1' ); |
|
|
2
|
|
|
|
|
4091
|
|
|
|
2
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my %cache; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _cache_key { |
|
14
|
|
|
|
|
|
|
# This is nasty - not all handles have a fileno. I can't find any |
|
15
|
|
|
|
|
|
|
# other way, short of using a localised package var to share a |
|
16
|
|
|
|
|
|
|
# single buffer amongst multiple handles. |
|
17
|
17
|
|
|
17
|
|
43
|
return fileno shift ; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _upgrade_handle { |
|
21
|
6
|
|
|
6
|
|
9
|
my $fh = shift; |
|
22
|
|
|
|
|
|
|
|
|
23
|
6
|
|
|
|
|
16
|
my $key = _cache_key( $fh ); |
|
24
|
6
|
100
|
|
|
|
38
|
unless ( $cache{$key} ) { |
|
25
|
5
|
|
|
1
|
|
149
|
binmode( $fh, ':via(' . __PACKAGE__ . ')' ); |
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _get_cache { |
|
30
|
2411
|
|
|
2411
|
|
2939
|
my $key = shift; |
|
31
|
|
|
|
|
|
|
|
|
32
|
2411
|
0
|
|
|
|
4650
|
return $cache{$key} |
|
33
|
|
|
|
|
|
|
or die "Internal: No cache for handle"; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub PUSHED { |
|
37
|
5
|
|
|
5
|
0
|
1443
|
my ( $class, $mode, $fh ) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
14
|
my $key = _cache_key( $fh ); |
|
40
|
5
|
|
|
|
|
34
|
$cache{$key} = IO::Mark::Cache->_new( $fh ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
5
|
|
|
|
|
41
|
return bless { key => $key }, $class; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub READ { |
|
46
|
1193
|
|
|
1193
|
|
27648
|
my $self = shift; |
|
47
|
|
|
|
|
|
|
|
|
48
|
1193
|
|
|
|
|
2192
|
my $cache = _get_cache($self->{key}); |
|
49
|
|
|
|
|
|
|
|
|
50
|
1193
|
|
|
|
|
2829
|
my $pos = $cache->_get_master_pos; |
|
51
|
1193
|
|
|
|
|
2937
|
my $got = $cache->_read( $_[0], $_[1], $pos ); |
|
52
|
1193
|
|
|
|
|
2633
|
$cache->_inc_master_pos( $got ); |
|
53
|
|
|
|
|
|
|
|
|
54
|
1193
|
|
|
|
|
3360
|
return $got; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub WRITE { |
|
58
|
0
|
|
|
0
|
|
0
|
my ( $self, $buffer, $fh ) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# warn "WRITE $self, $buffer, $fh\n"; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
return $fh->write( $buffer ); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub BINMODE { |
|
66
|
0
|
|
|
0
|
|
0
|
my ( $self, $fh ) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# warn "BINMODE $self, $fh\n"; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# What should we do here? We don't want to be popped. Is that |
|
71
|
|
|
|
|
|
|
# success or failure? |
|
72
|
0
|
|
|
|
|
0
|
return 0; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub CLOSE { |
|
76
|
11
|
|
|
11
|
|
4912
|
my ( $self, $fh ) = @_; |
|
77
|
11
|
|
|
|
|
32
|
my $cache = _get_cache($self->{key}); |
|
78
|
11
|
100
|
|
|
|
40
|
if ( 0 == $cache->_dec_ref_count ) { |
|
79
|
5
|
|
|
|
|
197
|
delete $cache{$self->{key}}; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
IO::Mark::Buffer - Stream buffer for IO::Mark |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 VERSION |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This document describes IO::Mark version 0.0.1 |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Don't use IO::Mark::Buffer directly; it has no usable public interface. |
|
96
|
|
|
|
|
|
|
Use instead L. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
No bugs have been reported. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
103
|
|
|
|
|
|
|
C, or through the web interface at |
|
104
|
|
|
|
|
|
|
L. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Andy Armstrong C<< >> |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 LICENCE AND COPYRIGHT |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Copyright (c) 2007, Andy Armstrong C<< >>. All rights reserved. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or |
|
115
|
|
|
|
|
|
|
modify it under the same terms as Perl itself. See L. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
|
120
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
|
121
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
|
122
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
|
123
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
124
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
|
125
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
|
126
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
|
127
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
130
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
131
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE |
|
132
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
|
133
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
|
134
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
|
135
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
|
136
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
|
137
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
138
|
|
|
|
|
|
|
SUCH DAMAGES. |