line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/local/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/) |
5
|
|
|
|
|
|
|
# All rights reserved. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Stream::StringInputStream; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@StringInputStream::ISA = qw(Stream::StringInputStream); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# StringInputStream |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# Inherits from InputStream, redefining all of it's member |
16
|
|
|
|
|
|
|
# functions: |
17
|
|
|
|
|
|
|
# read |
18
|
|
|
|
|
|
|
# skip |
19
|
|
|
|
|
|
|
# readAll |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
23
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
416
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub usage |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
0
|
0
|
0
|
my ($package, $filename, $line, $subr) = caller(1); |
28
|
0
|
|
|
|
|
0
|
$Carp::CarpLevel = 2; |
29
|
0
|
|
|
|
|
0
|
croak "Usage: $subr(@_)"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new |
33
|
|
|
|
|
|
|
{ |
34
|
2
|
50
|
|
2
|
0
|
7
|
usage("string") unless @_ == 2; |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
3
|
my $type = shift; my $self = {}; bless $self, $type; |
|
2
|
|
|
|
|
50
|
|
|
2
|
|
|
|
|
5
|
|
37
|
|
|
|
|
|
|
|
38
|
2
|
|
50
|
|
|
11
|
$self->{'data'} = shift || return "Undefined parameter"; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
5
|
$self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub read |
44
|
|
|
|
|
|
|
{ |
45
|
34
|
50
|
|
34
|
0
|
63
|
usage("count") unless @_ == 2; |
46
|
|
|
|
|
|
|
|
47
|
34
|
|
|
|
|
31
|
my $self = shift; |
48
|
34
|
|
|
|
|
33
|
my $count = shift; |
49
|
|
|
|
|
|
|
|
50
|
34
|
|
|
|
|
43
|
my $retval = substr($self->{'data'}, 0, $count); |
51
|
34
|
|
|
|
|
39
|
substr($self->{'data'}, 0, $count) = ''; |
52
|
34
|
|
|
|
|
90
|
$retval; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub skip |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
0
|
|
0
|
0
|
0
|
usage("count") unless @_ == 2; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
0
|
my $self = shift; |
60
|
0
|
|
|
|
|
0
|
my $count = shift; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
substr($self->{'data'}, 0, $count) = ''; |
63
|
0
|
|
|
|
|
0
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub readAll |
67
|
|
|
|
|
|
|
{ |
68
|
0
|
0
|
|
0
|
0
|
0
|
usage unless @_ == 1; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
my $retval = $self->{'data'}; |
73
|
0
|
|
|
|
|
0
|
$self->{'data'} = ''; |
74
|
0
|
|
|
|
|
0
|
$retval; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub eoi |
78
|
|
|
|
|
|
|
{ |
79
|
1
|
50
|
|
1
|
0
|
4
|
usage("eoi") unless @_ == 1; |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
2
|
my $self = shift; |
82
|
1
|
|
|
|
|
4
|
return (length($self->{'data'}) == 0); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |