This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
UCD.t: Allow to test earlier Unicodes
authorKarl Williamson <public@khwilliamson.com>
Thu, 29 Mar 2012 03:06:30 +0000 (21:06 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sat, 2 Jun 2012 14:29:17 +0000 (08:29 -0600)
In Unicode 6.1, the only property that is stored in hex format that
wasn't handled elsewhere is the bmg property, but earlier Unicodes had
some of the Unihan (if they are being compiled) ones stored that way
too.  So make it more general.

lib/Unicode/UCD.t

index 2d54d68..9cf235d 100644 (file)
@@ -1417,9 +1417,11 @@ foreach my $prop (keys %props) {
         }
         chomp $official;
 
-        # If there are any special elements, get a reference to them.
+        # Get the format for the file, and if there are any special elements,
+        # get a reference to them.
         my $swash_name = $utf8::file_to_swash_name{$base_file};
         my $specials_ref;
+        my $file_format;
         if ($swash_name) {
             $specials_ref = $utf8::SwashInfo{$swash_name}{'specials_name'};
             if ($specials_ref) {
@@ -1428,6 +1430,8 @@ foreach my $prop (keys %props) {
                 no strict 'refs';
                 $specials_ref = \%{$specials_ref};
             }
+
+            $file_format = $utf8::SwashInfo{$swash_name}{'format'};
         }
 
         # Certain of the proxy properties have to be adjusted to match the
@@ -1520,15 +1524,14 @@ foreach my $prop (keys %props) {
             # specials are superfluous.
             undef $specials_ref;
         }
-        elsif ($name eq 'bmg') {
+        elsif ($format !~ /^a/ && defined $file_format && $file_format eq 'x') {
 
-            # For this property, the file is output using hex notation for the
-            # map, with all ranges equal to length 1.  Convert from hex to
-            # decimal.
+            # For these properties the file is output using hex notation for the
+            # map.  Convert from hex to decimal.
             my @lines = split "\n", $official;
             foreach my $line (@lines) {
-                my ($code_point, $map) = split "\t\t", $line;
-                $line = $code_point . "\t\t" . hex $map;
+                my ($lower, $upper, $map) = split "\t", $line;
+                $line = "$lower\t$upper\t" . hex $map;
             }
             $official = join "\n", @lines;
         }