line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::VisualPrintf; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = "3.10"; |
4
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
110446
|
use v5.10; |
|
12
|
|
|
|
|
92
|
|
6
|
12
|
|
|
12
|
|
66
|
use strict; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
282
|
|
7
|
12
|
|
|
12
|
|
65
|
use warnings; |
|
12
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
314
|
|
8
|
12
|
|
|
12
|
|
60
|
use Carp; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
1009
|
|
9
|
|
|
|
|
|
|
|
10
|
12
|
|
|
12
|
|
83
|
use Exporter 'import'; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
796
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw(&vprintf &vsprintf); |
12
|
|
|
|
|
|
|
|
13
|
12
|
|
|
12
|
|
6062
|
use Data::Dumper; |
|
12
|
|
|
|
|
58212
|
|
|
12
|
|
|
|
|
704
|
|
14
|
12
|
|
|
12
|
|
10974
|
use Text::VisualPrintf::Transform; |
|
12
|
|
|
|
|
38
|
|
|
12
|
|
|
|
|
1043
|
|
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
1
|
0
|
sub vprintf { &printf (@_) } |
17
|
3
|
|
|
3
|
1
|
150937
|
sub vsprintf { &sprintf(@_) } |
18
|
|
|
|
|
|
|
|
19
|
12
|
|
|
12
|
|
106
|
use Text::VisualWidth::PP; |
|
12
|
|
|
|
|
26
|
|
|
12
|
|
|
|
|
675
|
|
20
|
|
|
|
|
|
|
our $IS_TARGET = qr/[\e\P{ASCII}]/; |
21
|
|
|
|
|
|
|
our $VISUAL_WIDTH = \&Text::VisualWidth::PP::width; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub sprintf { |
24
|
576
|
|
|
576
|
1
|
395398
|
my($format, @args) = @_; |
25
|
576
|
|
|
|
|
3041
|
my $xform = Text::VisualPrintf::Transform |
26
|
|
|
|
|
|
|
->new(except => $format, |
27
|
|
|
|
|
|
|
test => $IS_TARGET, |
28
|
|
|
|
|
|
|
length => $VISUAL_WIDTH, |
29
|
|
|
|
|
|
|
max => int @args, |
30
|
|
|
|
|
|
|
); |
31
|
576
|
50
|
|
|
|
2314
|
$xform->encode(@args) if $xform; |
32
|
576
|
|
|
|
|
4182
|
my $s = CORE::sprintf $format, @args; |
33
|
576
|
50
|
|
|
|
2973
|
$xform->decode($s) if $xform; |
34
|
576
|
|
|
|
|
6287
|
$s; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub printf { |
38
|
22
|
50
|
|
22
|
1
|
1088892
|
my $fh = ref($_[0]) =~ /^(?:GLOB|IO::)/ ? shift : select; |
39
|
22
|
|
|
|
|
107
|
$fh->print(&sprintf(@_)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |