line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
20
|
|
|
20
|
|
2725
|
use strict; use warnings; |
|
20
|
|
|
20
|
|
55
|
|
|
20
|
|
|
|
|
595
|
|
|
20
|
|
|
|
|
118
|
|
|
20
|
|
|
|
|
39
|
|
|
20
|
|
|
|
|
1083
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Text::Tabs; |
4
|
|
|
|
|
|
|
|
5
|
20
|
|
|
20
|
|
175
|
BEGIN { require Exporter; *import = \&Exporter::import } |
|
20
|
|
|
|
|
3657
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw( expand unexpand $tabstop ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2023.0509'; |
10
|
|
|
|
|
|
|
our $SUBVERSION = 'modern'; # back-compat vestige |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $tabstop = 8; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub expand { |
15
|
955
|
|
|
955
|
1
|
3756
|
my @l; |
16
|
|
|
|
|
|
|
my $pad; |
17
|
955
|
|
|
|
|
1534
|
for ( @_ ) { |
18
|
955
|
100
|
|
|
|
1694
|
defined or do { push @l, ''; next }; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
19
|
954
|
|
|
|
|
1344
|
my $s = ''; |
20
|
954
|
|
|
|
|
19956
|
for (split(/^/m, $_, -1)) { |
21
|
823
|
|
|
|
|
1414
|
my $offs; |
22
|
823
|
|
|
|
|
16408
|
for (split(/\t/, $_, -1)) { |
23
|
887
|
100
|
|
|
|
1552
|
if (defined $offs) { |
24
|
64
|
|
|
|
|
97
|
$pad = $tabstop - $offs % $tabstop; |
25
|
64
|
|
|
|
|
128
|
$s .= " " x $pad; |
26
|
|
|
|
|
|
|
} |
27
|
887
|
|
|
|
|
5927
|
$s .= $_; |
28
|
887
|
|
|
3
|
|
145347
|
$offs = /^\pM/ + ( () = /\PM/g ); |
|
3
|
|
|
|
|
1873
|
|
|
3
|
|
|
|
|
42
|
|
|
3
|
|
|
|
|
47
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
954
|
|
|
|
|
2239
|
push(@l, $s); |
32
|
|
|
|
|
|
|
} |
33
|
955
|
100
|
|
|
|
2041
|
return @l if wantarray; |
34
|
734
|
|
|
|
|
1451
|
return $l[0]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub unexpand |
38
|
|
|
|
|
|
|
{ |
39
|
412
|
|
|
412
|
1
|
1757
|
my (@l) = @_; |
40
|
412
|
|
|
|
|
1387
|
my @e; |
41
|
|
|
|
|
|
|
my $x; |
42
|
412
|
|
|
|
|
0
|
my $line; |
43
|
412
|
|
|
|
|
0
|
my @lines; |
44
|
412
|
|
|
|
|
0
|
my $lastbit; |
45
|
412
|
|
|
|
|
781
|
my $ts_as_space = " " x $tabstop; |
46
|
412
|
|
|
|
|
810
|
for $x (@l) { |
47
|
414
|
100
|
|
|
|
920
|
defined $x or next; |
48
|
411
|
|
|
|
|
8443
|
@lines = split("\n", $x, -1); |
49
|
411
|
|
|
|
|
671
|
for $line (@lines) { |
50
|
609
|
|
|
|
|
988
|
$line = expand($line); |
51
|
609
|
|
|
|
|
4628
|
@e = split(/((?:\PM\pM*|^\pM+){$tabstop})/,$line,-1); |
52
|
609
|
|
|
|
|
487876
|
$lastbit = pop(@e); |
53
|
609
|
100
|
|
|
|
1171
|
$lastbit = '' |
54
|
|
|
|
|
|
|
unless defined $lastbit; |
55
|
609
|
50
|
|
|
|
1106
|
$lastbit = "\t" |
56
|
|
|
|
|
|
|
if $lastbit eq $ts_as_space; |
57
|
609
|
|
|
|
|
1028
|
for $_ (@e) { |
58
|
3578
|
|
|
|
|
5152
|
s/ +$/\t/; |
59
|
|
|
|
|
|
|
} |
60
|
609
|
|
|
|
|
4107
|
$line = join('',@e, $lastbit); |
61
|
|
|
|
|
|
|
} |
62
|
411
|
|
|
|
|
1181
|
$x = join("\n", @lines); |
63
|
|
|
|
|
|
|
} |
64
|
412
|
50
|
|
|
|
743
|
return @l if wantarray; |
65
|
412
|
|
|
|
|
1620
|
return $l[0]; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |