line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
20
|
|
|
20
|
|
2508
|
use strict; use warnings; |
|
20
|
|
|
20
|
|
57
|
|
|
20
|
|
|
|
|
589
|
|
|
20
|
|
|
|
|
95
|
|
|
20
|
|
|
|
|
37
|
|
|
20
|
|
|
|
|
1133
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Text::Tabs; |
4
|
|
|
|
|
|
|
|
5
|
20
|
|
|
20
|
|
110
|
BEGIN { require Exporter; *import = \&Exporter::import } |
|
20
|
|
|
|
|
3586
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT = qw( expand unexpand $tabstop ); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2023.0511'; |
10
|
|
|
|
|
|
|
our $SUBVERSION = 'modern'; # back-compat vestige |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $tabstop = 8; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub expand { |
15
|
955
|
|
|
955
|
1
|
3929
|
my @l; |
16
|
|
|
|
|
|
|
my $pad; |
17
|
955
|
|
|
|
|
1524
|
for ( @_ ) { |
18
|
955
|
100
|
|
|
|
1707
|
defined or do { push @l, ''; next }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
19
|
954
|
|
|
|
|
1303
|
my $s = ''; |
20
|
954
|
|
|
|
|
20076
|
for (split(/^/m, $_, -1)) { |
21
|
823
|
|
|
|
|
1058
|
my $offs; |
22
|
823
|
|
|
|
|
16226
|
for (split(/\t/, $_, -1)) { |
23
|
887
|
100
|
|
|
|
1648
|
if (defined $offs) { |
24
|
64
|
|
|
|
|
109
|
$pad = $tabstop - $offs % $tabstop; |
25
|
64
|
|
|
|
|
126
|
$s .= " " x $pad; |
26
|
|
|
|
|
|
|
} |
27
|
887
|
|
|
|
|
5611
|
$s .= $_; |
28
|
887
|
|
|
3
|
|
145909
|
$offs = /^\pM/ + ( () = /\PM/g ); |
|
3
|
|
|
|
|
1909
|
|
|
3
|
|
|
|
|
42
|
|
|
3
|
|
|
|
|
47
|
|
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
954
|
|
|
|
|
2246
|
push(@l, $s); |
32
|
|
|
|
|
|
|
} |
33
|
955
|
100
|
|
|
|
2446
|
return @l if wantarray; |
34
|
734
|
|
|
|
|
1480
|
return $l[0]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub unexpand |
38
|
|
|
|
|
|
|
{ |
39
|
412
|
|
|
412
|
1
|
1851
|
my (@l) = @_; |
40
|
412
|
|
|
|
|
1323
|
my @e; |
41
|
|
|
|
|
|
|
my $x; |
42
|
412
|
|
|
|
|
0
|
my $line; |
43
|
412
|
|
|
|
|
0
|
my @lines; |
44
|
412
|
|
|
|
|
0
|
my $lastbit; |
45
|
412
|
|
|
|
|
787
|
my $ts_as_space = " " x $tabstop; |
46
|
412
|
|
|
|
|
762
|
for $x (@l) { |
47
|
414
|
100
|
|
|
|
817
|
defined $x or next; |
48
|
411
|
|
|
|
|
8434
|
@lines = split("\n", $x, -1); |
49
|
411
|
|
|
|
|
666
|
for $line (@lines) { |
50
|
609
|
|
|
|
|
990
|
$line = expand($line); |
51
|
609
|
|
|
|
|
4597
|
@e = split(/((?:\PM\pM*|^\pM+){$tabstop})/,$line,-1); |
52
|
609
|
|
|
|
|
489959
|
$lastbit = pop(@e); |
53
|
609
|
100
|
|
|
|
1252
|
$lastbit = '' |
54
|
|
|
|
|
|
|
unless defined $lastbit; |
55
|
609
|
50
|
|
|
|
1111
|
$lastbit = "\t" |
56
|
|
|
|
|
|
|
if $lastbit eq $ts_as_space; |
57
|
609
|
|
|
|
|
1052
|
for $_ (@e) { |
58
|
3578
|
|
|
|
|
5148
|
s/ +$/\t/; |
59
|
|
|
|
|
|
|
} |
60
|
609
|
|
|
|
|
3662
|
$line = join('',@e, $lastbit); |
61
|
|
|
|
|
|
|
} |
62
|
411
|
|
|
|
|
1167
|
$x = join("\n", @lines); |
63
|
|
|
|
|
|
|
} |
64
|
412
|
50
|
|
|
|
746
|
return @l if wantarray; |
65
|
412
|
|
|
|
|
1649
|
return $l[0]; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |