| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Unicode::Confuse; |
|
2
|
1
|
|
|
1
|
|
59326
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
15
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
53
|
|
|
5
|
1
|
|
|
1
|
|
12
|
use utf8; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
|
7
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ |
|
9
|
|
|
|
|
|
|
canonical |
|
10
|
|
|
|
|
|
|
confusable |
|
11
|
|
|
|
|
|
|
similar |
|
12
|
|
|
|
|
|
|
/; |
|
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
14
|
|
|
|
|
|
|
all => \@EXPORT_OK, |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
|
17
|
1
|
|
|
1
|
|
633
|
use Unicode::Confuse::Regex; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
197
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $re = $Unicode::Confuse::Regex::re; |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
676
|
use JSON::Parse 'read_json'; |
|
|
1
|
|
|
|
|
1177
|
|
|
|
1
|
|
|
|
|
240
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $jfile = __FILE__; |
|
24
|
|
|
|
|
|
|
$jfile =~ s!\.pm$!/confusables.json!; |
|
25
|
|
|
|
|
|
|
our $data = read_json ($jfile); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub confusable |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
4
|
|
|
4
|
1
|
1142
|
my ($c) = @_; |
|
30
|
4
|
|
|
|
|
50
|
return $c =~ $re; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub canonical |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
4
|
|
|
4
|
1
|
9
|
my ($c) = @_; |
|
36
|
4
|
|
|
|
|
31
|
my $r; |
|
37
|
4
|
50
|
|
|
|
39
|
if ($c =~ $re) { |
|
38
|
4
|
|
|
|
|
27
|
$r = $data->{confusables}{$c}; |
|
39
|
4
|
50
|
|
|
|
9
|
if (! defined $r) { |
|
40
|
|
|
|
|
|
|
# $r is already the canonical form |
|
41
|
0
|
|
|
|
|
0
|
$r = $c; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
} |
|
44
|
4
|
|
|
|
|
16
|
return $r; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub similar |
|
48
|
|
|
|
|
|
|
{ |
|
49
|
0
|
|
|
0
|
1
|
|
my ($c) = @_; |
|
50
|
0
|
|
|
|
|
|
my $d = canonical ($c); |
|
51
|
0
|
0
|
|
|
|
|
if (! $d) { |
|
52
|
0
|
|
|
|
|
|
return (); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
0
|
|
|
|
|
|
my @similar; |
|
55
|
|
|
|
|
|
|
# The reverse data does not include the canonical form in its |
|
56
|
|
|
|
|
|
|
# list. |
|
57
|
0
|
|
|
|
|
|
push @similar, $d; |
|
58
|
0
|
|
|
|
|
|
my $r = $data->{reverse}{$d}; |
|
59
|
0
|
|
|
|
|
|
push @similar, @$r; |
|
60
|
0
|
|
|
|
|
|
return @similar; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |