line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::RemoteCommand::LineBuffer; |
2
|
1
|
|
|
1
|
|
12
|
use v5.16; |
|
1
|
|
|
|
|
3
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
388
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
7
|
0
|
|
|
|
|
|
bless { buffer => "" }, $class; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub raw { |
11
|
0
|
|
|
0
|
0
|
|
shift->{buffer}; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub add { |
15
|
0
|
|
|
0
|
0
|
|
my ($self, $buffer) = @_; |
16
|
0
|
|
|
|
|
|
$self->{buffer} .= $buffer; |
17
|
0
|
|
|
|
|
|
$self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get { |
21
|
0
|
|
|
0
|
0
|
|
my ($self, $drain) = @_; |
22
|
0
|
0
|
|
|
|
|
if ($drain) { |
23
|
0
|
0
|
|
|
|
|
if (length $self->{buffer}) { |
24
|
0
|
|
|
|
|
|
my @line = $self->get; |
25
|
0
|
0
|
0
|
|
|
|
if (length $self->{buffer} and $self->{buffer} ne "\x0d") { |
26
|
0
|
|
|
|
|
|
$self->{buffer} =~ s/[\x0d\x0a]+\z//; |
27
|
0
|
|
|
|
|
|
push @line, $self->{buffer}; |
28
|
|
|
|
|
|
|
} |
29
|
0
|
|
|
|
|
|
$self->{buffer} = ""; |
30
|
0
|
|
|
|
|
|
return @line; |
31
|
|
|
|
|
|
|
} else { |
32
|
0
|
|
|
|
|
|
return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
my @line; |
36
|
0
|
|
|
|
|
|
while ($self->{buffer} =~ s/\A(.*?(?:\x0d\x0a|\x0d|\x0a))//sm) { |
37
|
0
|
|
|
|
|
|
my $line = $1; |
38
|
0
|
0
|
|
|
|
|
next if $line eq "\x0d"; |
39
|
0
|
|
|
|
|
|
$line =~ s/[\x0d\x0a]+\z//; |
40
|
0
|
|
|
|
|
|
push @line, $line; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
return @line; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |