summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2010-11-04 15:02:17 -0600
committerFather Chrysostomos <sprout@cpan.org>2010-11-05 16:11:42 -0700
commita44f4b74513a213052e4f78beb022f158efcf1a1 (patch)
tree2f199cfc762a9b4f0e70cd5691836c84bf7329ed /lib
parent68bb50b07e1a4db5feeb6f3d6d69e055a27e2aee (diff)
downloadperl-a44f4b74513a213052e4f78beb022f158efcf1a1.tar.gz
utf8_heavy.pl: Make callable during Perl's compilation
It's possible for this to be called during the compilation phase of Perl by miniperl before the Unicode tables have been built. This patch checks if dynamic loading is available, and if not evals the require needed to gain access to the tables. If it succeeds, the tables have been built; if it doesn't, instead of dying, just return empty tables, as currently the things being built don't require information outside the ASCII range, which is hard-coded into Perl without needing the tables. In the future, that may not be the case, and then likely the tables will have to be shipped with Perl, and make regen would be done to rebuild them.
Diffstat (limited to 'lib')
-rw-r--r--lib/utf8_heavy.pl19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/utf8_heavy.pl b/lib/utf8_heavy.pl
index 250eb69f05..56cfe059c2 100644
--- a/lib/utf8_heavy.pl
+++ b/lib/utf8_heavy.pl
@@ -25,7 +25,7 @@ sub croak { require Carp; Carp::croak(@_) }
my ($class, $type, $list, $minbits, $none) = @_;
local $^D = 0 if $^D;
- print STDERR __LINE__, ": ", join(", ", @_), "\n" if DEBUG;
+ print STDERR __LINE__, ": class=$class, type=$type, list=$list, minbits=$minbits, none=$none\n" if DEBUG;
##
## Get the list of codepoints for the type.
@@ -78,7 +78,8 @@ sub croak { require Carp; Carp::croak(@_) }
GETFILE:
{
##
- ## It could be a user-defined property.
+ ## It could be a user-defined property. Look in current
+ ## package if no package given
##
my $caller1 = $type =~ s/(.+)::// ? $1 : caller(1);
@@ -93,7 +94,19 @@ sub croak { require Carp; Carp::croak(@_) }
}
}
- require "$unicore_dir/Heavy.pl";
+ # During Perl's compilation, this routine may be called before
+ # the tables are constructed. If so, we have a chicken/egg
+ # problem. If we die, the tables never get constructed, so
+ # keep going, but return an empty table so only what the code
+ # has compiled in internally (currently ASCII/Latin1 range
+ # matching) will work.
+ if (! defined &DynaLoader::boot_DynaLoader) {
+ eval "require '$unicore_dir/Heavy.pl'";
+ last GETFILE if $@;
+ }
+ else {
+ require "$unicore_dir/Heavy.pl";
+ }
# Everything is caseless matching
my $property_and_table = lc $type;