This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
lib/h2xs.t (was Re: [PATCH] h2xs)
[perl5.git] / lib / utf8_heavy.pl
index 71cbb17..b73cea0 100644 (file)
@@ -26,19 +26,32 @@ sub SWASHNEW {
     while (($caller = caller($i)) eq __PACKAGE__) { $i++ }
     my $encoding = $enc{$caller} || "unicode";
     (my $file = $type) =~ s!::!/!g;
-    $file =~ s#^(I[sn]|To)([A-Z].*)#$1/$2#;
-    $list ||= eval { $caller->$type(); }
-       || do "$file.pl"
-       || do "$encoding/$file.pl"
-       || do "$encoding/Is/${type}.pl"
-       || croak("Can't find $encoding character property definition via $caller->$type or $file.pl");
+    if ($file =~ /^In(.+)/) {
+       my $In = $1;
+       defined %utf8::In || do "$encoding/In.pl";
+       if (exists $utf8::In{$In}) {
+           $file = "$encoding/In/$utf8::In{$In}";
+       }
+    } else {
+       $file =~ s#^(Is|To)([A-Z].*)#$1/$2#;
+    }
+
+    {
+        $list ||=
+           ( exists &{"${caller}::${type}"} &&
+             eval { $caller->$type() } )
+           || do "$file.pl"
+           || do "$encoding/$file.pl"
+           || do "$encoding/Is/${type}.pl"
+           || croak("Can't find $encoding character property \"$type\"");
+    }
 
     $| = 1;
 
     if ($list) {
        my @tmp = split(/^/m, $list);
        my %seen;
-       local $^W = 0;
+       no warnings;
        $extras = join '', grep /^[^0-9a-fA-F]/, @tmp;
        $list = join '',
            sort { hex $a <=> hex $b }
@@ -123,8 +136,7 @@ sub SWASHGET {
 #              print "$min $max $val\n";
                if ($none) {
                    if ($min < $start) {
-                       $val += $start - $min;
-                       $val = $none if $val > $none;
+                       $val += $start - $min if $val < $none;
                        $min = $start;
                    }
                    for ($key = $min; $key <= $max; $key++) {