| 1 | package Text::FIGlet::Control; | ||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | $VERSION = 2.15; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | #'import' core support functions from parent with circular dependency | ||||||||||||||||||||||||||||
| 8 | 4 | foreach( qw/_canonical _no/){ | |||||||||||||||||||||||||||
| 9 | 4 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 8 | *$_ = *{'Text::FIGlet::'.$_}; | |||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | ▶ | sub new{ | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=19 SCAR=29.5
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 2 | my $proto = shift; | |||||||||||||||||||||||||||
| 15 | 2 | my $self = {-C=>[]}; | |||||||||||||||||||||||||||
| 16 | 2 | local($_, *FLC); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | my $code = ''; | |||||||||||||||||||||||||||
| 19 | 2 | my(@t_pre, @t_post); | |||||||||||||||||||||||||||
| 20 | 2 | ▶ | while( @_ ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 3 | my $s = shift; | |||||||||||||||||||||||||||
| 22 | 3 | ▶ | if( $s eq '-C' ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 2 | push(@{$self->{-C}}, shift); } | |||||||||||||||||||||||||||
| 24 | else{ | ||||||||||||||||||||||||||||
| 25 | 1 | $self->{$s} = shift; } | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | 2 | ▶ | $self->{-d} ||= $ENV{FIGLIB} || '/usr/games/lib/figlet/'; | ||||||||||||||||||||||||||
|
Condition60%3/5
$self->{"-d"} ||= $ENV{"FIGLIB"} || "/usr/games/lib/figlet/"
$ENV{'FIGLIB'} || '/usr/games/lib/figlet/'
MC/DC0%0/2
$self->{"-d"} ||= $ENV{"FIGLIB"} || "/usr/games/lib/figlet/"
$self->{"-d"}
$ENV{'FIGLIB'}
Truth table66%2/3
A ||= B
A= $self->{"-d"}B= $ENV{'FIGLIB'}
| |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | $self->{"_\\"} = 1 if $^O =~ /MSWin32|DOS/i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # my $no = qr/0x[\da-fA-F]+|\d+/; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 2 | foreach my $flc ( @{$self->{-C}} ){ | |||||||||||||||||||||||||||
| 34 | $self->{'_file'} = _canonical($self->{-d}, | ||||||||||||||||||||||||||||
| 35 | $flc, | ||||||||||||||||||||||||||||
| 36 | qr/\.flc/, | ||||||||||||||||||||||||||||
| 37 | 2 | $self->{"_\\"}); | |||||||||||||||||||||||||||
| 38 | 2 | ▶ | open(FLC, $self->{'_file'}) || croak("$!: $flc [$self->{_file}]"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 2 | ▶ | while(<FLC>){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 195 | ▶ | next if /^flc2a|\s*#|^\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | #XXX Is this adequate? | ||||||||||||||||||||||||||||
| 43 | 157 | ▶ | $code .= 'use utf8;' if /^\s*u/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 157 | ▶ | if( /^\s*$Text::FIGlet::RE{no}\s+$Text::FIGlet::RE{no}\s*/ ){ | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 46 | #Only needed for decimals?! | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1 | push @t_pre, sprintf('\\x{%x}', _no($1, $2, $3)); | |||||||||||||||||||||||||||
| 49 | 1 | 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 | push @t_pre, sprintf( '\\x{%x}', _no( $1, $2, $3)); | |||||||||||||||||||||||||||
| 53 | 4 | push @t_post, sprintf( '\\x{%x}', _no( $7, $8, $9)); | |||||||||||||||||||||||||||
| 54 | 4 | ▶ | $t_pre[-1] .= sprintf('-\\x{%x}', _no( $4, $5, $6)) if$5; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 4 | ▶ | $t_post[-1].= sprintf('-\\x{%x}', _no($10,$11,$12))if$11; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | elsif( /^\s*t\s+([^\s](?:-[^\s])?)\s+([^\s](?:-[^\s])?)\s*/ ){ | ||||||||||||||||||||||||||||
| 58 | 1 | push @t_pre, $1; | |||||||||||||||||||||||||||
| 59 | 1 | push @t_post, $2; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 157 | ▶ | if( /^\s*f/ || eof(FLC) ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
/^\s*f/ or eof FLC
MC/DC100%2/2
/^\s*f/ or eof FLC
/^\s*f/
eof FLC
Truth table100%3/3
A or B
A= /^\s*f/B= eof FLC
| |||||||||||||||||||||||||||||
| 62 | 3 | @{$_} = map { s%/%\\/%g, $_ } @{$_} for( \@t_pre, \@t_post ); | |||||||||||||||||||||||||||
| 63 | 3 | $code .= 'tr/' . join('', @t_pre) . '/' . join('', @t_post) . '/;'; | |||||||||||||||||||||||||||
| 64 | 3 | @t_pre = @t_post = (); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | 2 | close(FLC); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 2 | ▶ | $self->{_sub} = eval "sub { local \$_ = shift; $code; return \$_ }"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 70 | 2 | bless($self); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 2 | ▶ | sub tr($){ | ||||||||||||||||||||||||||
|
Subroutine
tr: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||
| 74 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 75 | 2 | ▶ | $self->{_sub}->( shift || $_ ); | ||||||||||||||||||||||||||
|
Condition33%1/3
shift() || $_
MC/DC0%0/2
shift() || $_
shift()
$_
Truth table33%1/3
A || B
A= shift()B= $_
| |||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 4 | 1; | |||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||