line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::FIGlet::Control; |
2
|
5
|
|
|
5
|
|
118
|
use strict; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
156
|
|
3
|
4
|
|
|
4
|
|
20
|
use vars '$VERSION'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
336
|
|
4
|
4
|
|
|
4
|
|
19
|
use Carp 'croak'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
447
|
|
5
|
|
|
|
|
|
|
$VERSION = 2.15; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#'import' core support functions from parent with circular dependency |
8
|
|
|
|
|
|
|
foreach( qw/_canonical _no/){ |
9
|
4
|
|
|
4
|
|
20
|
no strict 'refs'; |
|
4
|
|
|
|
|
21
|
|
|
4
|
|
|
|
|
6686
|
|
10
|
|
|
|
|
|
|
*$_ = *{'Text::FIGlet::'.$_}; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new{ |
14
|
2
|
|
|
2
|
1
|
5
|
my $proto = shift; |
15
|
2
|
|
|
|
|
8
|
my $self = {-C=>[]}; |
16
|
2
|
|
|
|
|
9
|
local($_, *FLC); |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
5
|
my $code = ''; |
19
|
2
|
|
|
|
|
2
|
my(@t_pre, @t_post); |
20
|
2
|
|
|
|
|
8
|
while( @_ ){ |
21
|
3
|
|
|
|
|
6
|
my $s = shift; |
22
|
3
|
100
|
|
|
|
10
|
if( $s eq '-C' ){ |
23
|
2
|
|
|
|
|
3
|
push(@{$self->{-C}}, shift); } |
|
2
|
|
|
|
|
10
|
|
24
|
|
|
|
|
|
|
else{ |
25
|
1
|
|
|
|
|
2
|
$self->{$s} = shift; } |
26
|
|
|
|
|
|
|
} |
27
|
2
|
|
50
|
|
|
15
|
$self->{-d} ||= $ENV{FIGLIB} || '/usr/games/lib/figlet/'; |
|
|
|
66
|
|
|
|
|
28
|
2
|
50
|
|
|
|
24
|
$self->{"_\\"} = 1 if $^O =~ /MSWin32|DOS/i; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# my $no = qr/0x[\da-fA-F]+|\d+/; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
112
|
foreach my $flc ( @{$self->{-C}} ){ |
|
2
|
|
|
|
|
7
|
|
34
|
2
|
|
|
|
|
24
|
$self->{'_file'} = _canonical($self->{-d}, |
35
|
|
|
|
|
|
|
$flc, |
36
|
|
|
|
|
|
|
qr/\.flc/, |
37
|
|
|
|
|
|
|
$self->{"_\\"}); |
38
|
2
|
50
|
|
|
|
190
|
open(FLC, $self->{'_file'}) || croak("$!: $flc [$self->{_file}]"); |
39
|
2
|
|
|
|
|
93
|
while(){ |
40
|
195
|
100
|
|
|
|
1179
|
next if /^flc2a|\s*#|^\s*$/; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#XXX Is this adequate? |
43
|
157
|
100
|
|
|
|
324
|
$code .= 'use utf8;' if /^\s*u/; |
44
|
|
|
|
|
|
|
|
45
|
157
|
100
|
|
|
|
1855
|
if( /^\s*$Text::FIGlet::RE{no}\s+$Text::FIGlet::RE{no}\s*/ ){ |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#Only needed for decimals?! |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
9
|
push @t_pre, sprintf('\\x{%x}', _no($1, $2, $3)); |
49
|
1
|
|
|
|
|
6
|
push @t_post, sprintf('\\x{%x}', _no($4, $5, $6)); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif( /^\s*t\s+\\?$Text::FIGlet::RE{no}(?:-\\$Text::FIGlet::RE{no})?\s+\\?$Text::FIGlet::RE{no}(?:-\\$Text::FIGlet::RE{no})?\s*/ ){ |
52
|
4
|
|
|
|
|
12
|
push @t_pre, sprintf( '\\x{%x}', _no( $1, $2, $3)); |
53
|
4
|
|
|
|
|
8
|
push @t_post, sprintf( '\\x{%x}', _no( $7, $8, $9)); |
54
|
4
|
100
|
|
|
|
17
|
$t_pre[-1] .= sprintf('-\\x{%x}', _no( $4, $5, $6)) if$5; |
55
|
4
|
100
|
|
|
|
24
|
$t_post[-1].= sprintf('-\\x{%x}', _no($10,$11,$12))if$11; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif( /^\s*t\s+([^\s](?:-[^\s])?)\s+([^\s](?:-[^\s])?)\s*/ ){ |
58
|
1
|
|
|
|
|
5
|
push @t_pre, $1; |
59
|
1
|
|
|
|
|
4
|
push @t_post, $2; |
60
|
|
|
|
|
|
|
} |
61
|
157
|
100
|
100
|
|
|
940
|
if( /^\s*f/ || eof(FLC) ){ |
62
|
3
|
|
|
|
|
10
|
@{$_} = map { s%/%\\/%g, $_ } @{$_} for( \@t_pre, \@t_post ); |
|
6
|
|
|
|
|
39
|
|
|
12
|
|
|
|
|
35
|
|
|
6
|
|
|
|
|
16
|
|
63
|
3
|
|
|
|
|
15
|
$code .= 'tr/' . join('', @t_pre) . '/' . join('', @t_post) . '/;'; |
64
|
3
|
|
|
|
|
46
|
@t_pre = @t_post = (); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
2
|
|
|
|
|
74
|
close(FLC); |
68
|
|
|
|
|
|
|
} |
69
|
2
|
|
|
2
|
|
288
|
$self->{_sub} = eval "sub { local \$_ = shift; $code; return \$_ }"; |
|
2
|
|
|
|
|
1050
|
|
|
2
|
|
|
|
|
30
|
|
|
2
|
|
|
|
|
20
|
|
70
|
2
|
|
|
|
|
38
|
bless($self); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub tr($){ |
74
|
2
|
|
|
2
|
1
|
25
|
my $self = shift; |
75
|
2
|
|
33
|
|
|
75
|
$self->{_sub}->( shift || $_ ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
__END__ |