line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Wrap::Smart::XS; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
352100
|
use strict; |
|
5
|
|
|
|
|
41
|
|
|
5
|
|
|
|
|
203
|
|
4
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
173
|
|
5
|
5
|
|
|
5
|
|
27
|
use base qw(Exporter); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
797
|
|
6
|
5
|
|
|
5
|
|
2442
|
use boolean qw(true); |
|
5
|
|
|
|
|
16879
|
|
|
5
|
|
|
|
|
21
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
374
|
use Carp qw(croak); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
270
|
|
9
|
5
|
|
|
5
|
|
2916
|
use Params::Validate ':all'; |
|
5
|
|
|
|
|
47424
|
|
|
5
|
|
|
|
|
1274
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our ($VERSION, @EXPORT_OK, %EXPORT_TAGS, @subs); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$VERSION = '0.06_04'; |
14
|
|
|
|
|
|
|
@subs = qw(exact_wrap fuzzy_wrap); |
15
|
|
|
|
|
|
|
@EXPORT_OK = @subs; |
16
|
|
|
|
|
|
|
%EXPORT_TAGS = ('all' => [ @subs ]); |
17
|
|
|
|
|
|
|
|
18
|
5
|
|
|
5
|
|
41
|
use constant WRAP_AT_DEFAULT => 160; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1656
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
validation_options( |
21
|
|
|
|
|
|
|
on_fail => sub |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
my ($error) = @_; |
24
|
|
|
|
|
|
|
chomp $error; |
25
|
|
|
|
|
|
|
croak $error; |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
stack_skip => 2, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub exact_wrap |
31
|
|
|
|
|
|
|
{ |
32
|
10
|
|
|
10
|
1
|
4744
|
_validate(@_); |
33
|
10
|
|
|
|
|
493
|
my ($text, $wrap_at) = @_; |
34
|
|
|
|
|
|
|
|
35
|
10
|
|
100
|
|
|
34
|
$wrap_at ||= WRAP_AT_DEFAULT; |
36
|
|
|
|
|
|
|
|
37
|
10
|
|
|
|
|
74
|
return xs_exact_wrap($text, $wrap_at); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub fuzzy_wrap |
41
|
|
|
|
|
|
|
{ |
42
|
68
|
|
|
68
|
1
|
71384
|
_validate(@_); |
43
|
68
|
|
|
|
|
2517
|
my ($text, $wrap_at) = @_; |
44
|
|
|
|
|
|
|
|
45
|
68
|
|
100
|
|
|
238
|
$wrap_at ||= WRAP_AT_DEFAULT; |
46
|
|
|
|
|
|
|
|
47
|
68
|
|
|
|
|
720
|
return xs_fuzzy_wrap($text, $wrap_at); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _validate |
51
|
|
|
|
|
|
|
{ |
52
|
78
|
|
|
78
|
|
349
|
validate_pos(@_, |
53
|
|
|
|
|
|
|
{ type => SCALAR }, |
54
|
|
|
|
|
|
|
{ type => SCALAR, optional => true, regex => qr/^\d+$/ }, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
require XSLoader; |
59
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
__END__ |