line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PerlIO::via::Rotate; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION= '0.09'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# be strict and do everything on octets |
6
|
6
|
|
|
6
|
|
1862
|
use strict; |
|
6
|
|
|
|
|
24
|
|
|
6
|
|
|
|
|
100
|
|
7
|
6
|
|
|
6
|
|
2234
|
use bytes; |
|
6
|
|
|
|
|
53
|
|
|
6
|
|
|
|
|
23
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# initialize the base rotational strings |
10
|
|
|
|
|
|
|
my @rotate= ( '', qw( |
11
|
|
|
|
|
|
|
b-za |
12
|
|
|
|
|
|
|
c-zab |
13
|
|
|
|
|
|
|
d-za-c |
14
|
|
|
|
|
|
|
e-za-d |
15
|
|
|
|
|
|
|
f-za-e |
16
|
|
|
|
|
|
|
g-za-f |
17
|
|
|
|
|
|
|
h-za-g |
18
|
|
|
|
|
|
|
i-za-h |
19
|
|
|
|
|
|
|
j-za-i |
20
|
|
|
|
|
|
|
k-za-j |
21
|
|
|
|
|
|
|
l-za-k |
22
|
|
|
|
|
|
|
m-za-l |
23
|
|
|
|
|
|
|
n-za-m |
24
|
|
|
|
|
|
|
o-za-n |
25
|
|
|
|
|
|
|
p-za-o |
26
|
|
|
|
|
|
|
q-za-p |
27
|
|
|
|
|
|
|
r-za-q |
28
|
|
|
|
|
|
|
s-za-r |
29
|
|
|
|
|
|
|
t-za-s |
30
|
|
|
|
|
|
|
u-za-t |
31
|
|
|
|
|
|
|
v-za-u |
32
|
|
|
|
|
|
|
w-za-v |
33
|
|
|
|
|
|
|
x-za-w |
34
|
|
|
|
|
|
|
yza-x |
35
|
|
|
|
|
|
|
za-y |
36
|
|
|
|
|
|
|
), '' ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# satisfy -require- |
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
42
|
|
|
|
|
|
|
# |
43
|
|
|
|
|
|
|
# Standard Perl features |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
46
|
|
|
|
|
|
|
# IN: 1 class to bless with |
47
|
|
|
|
|
|
|
# 2..N parameters passed in -use- |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub import { |
50
|
6
|
|
|
6
|
|
30
|
shift; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# set up defaults |
53
|
6
|
100
|
66
|
|
|
28
|
@_= 0..26 if @_ == 1 and $_[0] eq ':all'; |
54
|
6
|
100
|
|
|
|
29
|
@_= 13 if !@_; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# process all rotations |
57
|
6
|
|
|
|
|
16
|
my @huh; |
58
|
|
|
|
|
|
|
ROTATION: |
59
|
6
|
|
|
|
|
11
|
foreach (@_) { |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# huh? |
62
|
34
|
50
|
33
|
|
|
264
|
push( @huh, "Invalid rotational value: $_" ), next ROTATION |
|
|
|
33
|
|
|
|
|
63
|
|
|
|
|
|
|
if !m#^[0-9]+$# or $_ < 0 or $_ > 26; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# we've already done this one |
66
|
34
|
|
|
|
|
74
|
my $module= "PerlIO/via/rot$_.pm"; |
67
|
34
|
50
|
|
|
|
68
|
next ROTATION if $INC{$module}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# source for the module |
70
|
34
|
|
|
|
|
86
|
my $source= <<"SRC"; |
71
|
|
|
|
|
|
|
package PerlIO::via::rot$_; |
72
|
|
|
|
|
|
|
use bytes; |
73
|
|
|
|
|
|
|
\@PerlIO::via::rot$_\::ISA= 'PerlIO::via::Rotate'; |
74
|
|
|
|
|
|
|
\$PerlIO::via::rot$_\::VERSION= '$PerlIO::via::Rotate::VERSION'; |
75
|
|
|
|
|
|
|
SRC |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# we can do encoding for this |
78
|
34
|
100
|
|
|
|
90
|
if ( my $encode= $rotate[$_] . uc( $rotate[$_] ) ) { |
79
|
32
|
|
|
|
|
42
|
my $other= 26 - $_; |
80
|
32
|
|
|
|
|
49
|
my $decode= $rotate[$other] . uc( $rotate[$other] ); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# add the source code for this rotation (PUSHED is inherited) |
83
|
32
|
|
|
|
|
89
|
$source .= <<"SRC"; |
84
|
|
|
|
|
|
|
sub FILL { |
85
|
|
|
|
|
|
|
local \$_= readline( \$_[1] ); |
86
|
|
|
|
|
|
|
return if !defined \$_; |
87
|
|
|
|
|
|
|
tr/a-zA-Z/$decode/; |
88
|
|
|
|
|
|
|
return \$_; |
89
|
|
|
|
|
|
|
} #FILL |
90
|
|
|
|
|
|
|
sub WRITE { |
91
|
|
|
|
|
|
|
local \$_= \$_[1]; |
92
|
|
|
|
|
|
|
tr/a-zA-Z/$encode/; |
93
|
|
|
|
|
|
|
return ( print { \$_[2] } \$_ ) ? length() : -1; |
94
|
|
|
|
|
|
|
} #WRITE |
95
|
|
|
|
|
|
|
SRC |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# make the module available and mark as loaded |
99
|
6
|
50
|
|
6
|
0
|
35
|
if ( eval "$source; 1" ) { |
|
6
|
100
|
|
19
|
0
|
17
|
|
|
6
|
100
|
|
12
|
0
|
18
|
|
|
34
|
0
|
|
1
|
0
|
2026
|
|
|
19
|
0
|
|
2
|
0
|
92
|
|
|
19
|
50
|
|
1
|
0
|
70
|
|
|
17
|
0
|
|
1
|
0
|
27
|
|
|
17
|
0
|
|
1
|
0
|
83
|
|
|
12
|
0
|
|
1
|
0
|
40
|
|
|
12
|
0
|
|
1
|
0
|
41
|
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go on |
110
|
6
|
50
|
|
|
|
1751
|
die join "\n", "These errors were found:", @huh if @huh; |
111
|
|
|
|
|
|
|
|
112
|
6
|
|
|
|
|
142
|
return; |
113
|
|
|
|
|
|
|
} #import |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
116
|
|
|
|
|
|
|
# IN: 1 class |
117
|
|
|
|
|
|
|
# 2 numeric value to check |
118
|
|
|
|
|
|
|
|
119
|
4
|
|
|
4
|
0
|
26
|
sub VERSION { 1 } #VERSION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
122
|
|
|
|
|
|
|
# IN: 1 class to bless with |
123
|
|
|
|
|
|
|
# 2 mode string (ignored) |
124
|
|
|
|
|
|
|
# 3 file handle of PerlIO layer below (ignored) |
125
|
|
|
|
|
|
|
# OUT: 1 blessed object |
126
|
|
|
|
|
|
|
|
127
|
10
|
|
|
9
|
0
|
4442
|
sub PUSHED { bless \*PUSHED, $_[0] } #PUSHED |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
130
|
|
|
|
|
|
|
# IN: 1 instantiated object (ignored) |
131
|
|
|
|
|
|
|
# 2 handle to read from |
132
|
|
|
|
|
|
|
# OUT: 1 decoded string |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub FILL { |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# huh? |
137
|
2
|
|
|
1
|
0
|
3
|
local( $_ )= ref( $_[0] ); |
138
|
2
|
50
|
|
|
|
16
|
die "Class $_ was not activated" if !m#::rot(?:0|26)$#; |
139
|
|
|
|
|
|
|
|
140
|
1
|
|
|
|
|
5
|
return readline( $_[1] ); |
141
|
|
|
|
|
|
|
} #FILL |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
144
|
|
|
|
|
|
|
# IN: 1 instantiated object (ignored) |
145
|
|
|
|
|
|
|
# 2 buffer to be written |
146
|
|
|
|
|
|
|
# 3 handle to write to |
147
|
|
|
|
|
|
|
# OUT: 1 number of bytes written |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub WRITE { |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# huh? |
152
|
1
|
|
|
1
|
|
2
|
local( $_ ) = ref( $_[0] ); |
153
|
1
|
0
|
|
|
|
3
|
die "Class $_ was not activated" unless m#::rot(?:0|26)$#; |
154
|
|
|
|
|
|
|
|
155
|
1
|
0
|
|
|
|
5
|
return ( print { $_[2] } $_[1] ) ? length( $_[1] ) : -1; |
|
1
|
|
|
|
|
2
|
|
156
|
|
|
|
|
|
|
} #WRITE |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
__END__ |