line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Buffer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright 2001 by Steve McKay. All rights reserved. |
4
|
|
|
|
|
|
|
# This library is free software; you can redistribute it and/or |
5
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1545
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
8
|
1
|
|
|
1
|
|
6
|
use vars qw( @ISA $VERSION ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
399
|
|
9
|
|
|
|
|
|
|
$VERSION = 0.05; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
*append = \&write; |
12
|
|
|
|
|
|
|
*appendln = \&writeln; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new |
15
|
|
|
|
|
|
|
{ |
16
|
0
|
|
|
0
|
1
|
|
my ( $proto, $str ) = @_; |
17
|
0
|
|
0
|
|
|
|
my $class = ref( $proto ) || $proto; |
18
|
0
|
|
|
|
|
|
my $self = { |
19
|
|
|
|
|
|
|
buffer => undef, |
20
|
|
|
|
|
|
|
}; |
21
|
0
|
0
|
|
|
|
|
$self->{buffer} = $str if $str; |
22
|
0
|
|
|
|
|
|
bless( $self, $class ); |
23
|
0
|
|
|
|
|
|
return $self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub write |
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
|
0
|
1
|
|
my( $self, @val ) = @_; |
29
|
0
|
|
|
|
|
|
$self->{buffer} .= join( '', @val ); |
30
|
0
|
|
|
|
|
|
return undef; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub writeln |
34
|
|
|
|
|
|
|
{ |
35
|
0
|
|
|
0
|
1
|
|
my( $self, @val ) = @_; |
36
|
0
|
|
|
|
|
|
return $self->write( @val, "\n" ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub read |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
42
|
0
|
|
|
|
|
|
return $self->{buffer}; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub flush |
46
|
|
|
|
|
|
|
{ |
47
|
0
|
|
|
0
|
1
|
|
my( $self ) = @_; |
48
|
0
|
|
|
|
|
|
my $flushed = $self->read(); |
49
|
0
|
|
|
|
|
|
$self->{buffer} = undef; |
50
|
0
|
|
|
|
|
|
return $flushed; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |