| 1 | package Unicode::CaseFold; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Unicode case-folding for case-insensitive lookups. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.01'; # VERSION | |||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | 1 | our $AUTHORITY = 'cpan:ARODLAND'; # AUTHORITY | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use 5.008001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Scalar::Util 1.11 (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | require Exporter; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 19 | 1 | our @EXPORT_OK = qw(case_fold); | |||||||||||||||||||||||||||
| 20 | 1 | our @EXPORT = qw(fc); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | our $SIMPLE_FOLDING; | |||||||||||||||||||||||||||
| 23 | 1 | our $XS = 0; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=8 SCAR=23.4
| |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | unless ($ENV{PERL_UNICODE_CASEFOLD_PP}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 1 | local $@; | |||||||||||||||||||||||||||
| 28 | 1 | eval { | |||||||||||||||||||||||||||
| 29 | 1 | our $VERSION; | |||||||||||||||||||||||||||
| 30 | 1 | require XSLoader; | |||||||||||||||||||||||||||
| 31 | XSLoader::load(__PACKAGE__, | ||||||||||||||||||||||||||||
| 32 | exists $Unicode::CaseFold::{VERSION} | ||||||||||||||||||||||||||||
| 33 | 1 | ▶ | ? ${ $Unicode::CaseFold::{VERSION} } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | : () | ||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||
| 36 | }; | ||||||||||||||||||||||||||||
| 37 | 1 | ▶ | die $@ if $@ && $@ !~ /object version|loadable object/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and not $@ =~ /object version|loadable object/
MC/DC0%0/2
$@ and not $@ =~ /object version|loadable object/
$@
not $@ =~ /object version|loadable object/
Truth table33%1/3
A and not(B)
A= $@B= not $@ =~ /object version|loadable object/
| |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | $XS = 1 unless $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | $SIMPLE_FOLDING = 0 unless $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 1 | ▶ | if (!$XS) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | require Unicode::CaseFoldPP; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 99 | ▶ | sub fc { | ||||||||||||||||||||||||||
|
Subroutine
fc: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 99 | ▶ | @_ = ($_) unless @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 99 | goto &case_fold; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||
| 52 | # Perl 5.10+ supports the (_) prototype which does the $_-defaulting for us, | ||||||||||||||||||||||||||||
| 53 | # and handles "lexical $_". Older perl doesn't, but we can fake it fairly | ||||||||||||||||||||||||||||
| 54 | # closely with a (;$) prototype. Older perl didn't have lexical $_ anyway. | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | ▶ | if ($^V ge v5.10.0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 1 | Scalar::Util::set_prototype(\&fc, '_'); | |||||||||||||||||||||||||||
| 58 | } else { | ||||||||||||||||||||||||||||
| 59 | 0 | Scalar::Util::set_prototype(\&fc, ';$'); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | 1; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||||||||