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