line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
20
|
|
|
20
|
|
2434
|
use strict; use warnings; |
|
20
|
|
|
20
|
|
56
|
|
|
20
|
|
|
|
|
596
|
|
|
20
|
|
|
|
|
98
|
|
|
20
|
|
|
|
|
39
|
|
|
20
|
|
|
|
|
1048
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Text::Tabs; |
4
|
|
|
|
|
|
|
|
5
|
20
|
|
|
20
|
|
129
|
BEGIN { require Exporter; *import = \&Exporter::import } |
|
20
|
|
|
|
|
3817
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw( expand unexpand $tabstop ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2023.0510'; |
10
|
|
|
|
|
|
|
our $SUBVERSION = 'modern'; # back-compat vestige |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $tabstop = 8; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub expand { |
15
|
955
|
|
|
955
|
1
|
3857
|
my @l; |
16
|
|
|
|
|
|
|
my $pad; |
17
|
955
|
|
|
|
|
1530
|
for ( @_ ) { |
18
|
955
|
100
|
|
|
|
1714
|
defined or do { push @l, ''; next }; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
19
|
954
|
|
|
|
|
1318
|
my $s = ''; |
20
|
954
|
|
|
|
|
21443
|
for (split(/^/m, $_, -1)) { |
21
|
823
|
|
|
|
|
1117
|
my $offs; |
22
|
823
|
|
|
|
|
16259
|
for (split(/\t/, $_, -1)) { |
23
|
887
|
100
|
|
|
|
1580
|
if (defined $offs) { |
24
|
64
|
|
|
|
|
102
|
$pad = $tabstop - $offs % $tabstop; |
25
|
64
|
|
|
|
|
119
|
$s .= " " x $pad; |
26
|
|
|
|
|
|
|
} |
27
|
887
|
|
|
|
|
5532
|
$s .= $_; |
28
|
887
|
|
|
3
|
|
147659
|
$offs = /^\pM/ + ( () = /\PM/g ); |
|
3
|
|
|
|
|
1717
|
|
|
3
|
|
|
|
|
44
|
|
|
3
|
|
|
|
|
46
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
954
|
|
|
|
|
2292
|
push(@l, $s); |
32
|
|
|
|
|
|
|
} |
33
|
955
|
100
|
|
|
|
2105
|
return @l if wantarray; |
34
|
734
|
|
|
|
|
1478
|
return $l[0]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub unexpand |
38
|
|
|
|
|
|
|
{ |
39
|
412
|
|
|
412
|
1
|
1820
|
my (@l) = @_; |
40
|
412
|
|
|
|
|
1331
|
my @e; |
41
|
|
|
|
|
|
|
my $x; |
42
|
412
|
|
|
|
|
0
|
my $line; |
43
|
412
|
|
|
|
|
0
|
my @lines; |
44
|
412
|
|
|
|
|
0
|
my $lastbit; |
45
|
412
|
|
|
|
|
797
|
my $ts_as_space = " " x $tabstop; |
46
|
412
|
|
|
|
|
761
|
for $x (@l) { |
47
|
414
|
100
|
|
|
|
850
|
defined $x or next; |
48
|
411
|
|
|
|
|
8329
|
@lines = split("\n", $x, -1); |
49
|
411
|
|
|
|
|
687
|
for $line (@lines) { |
50
|
609
|
|
|
|
|
984
|
$line = expand($line); |
51
|
609
|
|
|
|
|
4676
|
@e = split(/((?:\PM\pM*|^\pM+){$tabstop})/,$line,-1); |
52
|
609
|
|
|
|
|
490993
|
$lastbit = pop(@e); |
53
|
609
|
100
|
|
|
|
1179
|
$lastbit = '' |
54
|
|
|
|
|
|
|
unless defined $lastbit; |
55
|
609
|
50
|
|
|
|
1123
|
$lastbit = "\t" |
56
|
|
|
|
|
|
|
if $lastbit eq $ts_as_space; |
57
|
609
|
|
|
|
|
1034
|
for $_ (@e) { |
58
|
3578
|
|
|
|
|
5204
|
s/ +$/\t/; |
59
|
|
|
|
|
|
|
} |
60
|
609
|
|
|
|
|
3678
|
$line = join('',@e, $lastbit); |
61
|
|
|
|
|
|
|
} |
62
|
411
|
|
|
|
|
1080
|
$x = join("\n", @lines); |
63
|
|
|
|
|
|
|
} |
64
|
412
|
50
|
|
|
|
755
|
return @l if wantarray; |
65
|
412
|
|
|
|
|
1652
|
return $l[0]; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |