This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mktables: Add tests for wrong equivalence attempts
authorKarl Williamson <public@khwilliamson.com>
Sat, 30 Oct 2010 15:43:50 +0000 (09:43 -0600)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 31 Oct 2010 13:11:41 +0000 (06:11 -0700)
mktables allows for multiple tables to be made equivalent, which in Unix
terminology means that they are essentially symbolic links.  However
this should happen only when they have the same code points in them to
begin with.  This adds a little more error checking.

lib/unicore/mktables

index b7cda64..b13fe0e 100644 (file)
@@ -6560,12 +6560,21 @@ sub trace { return main::trace(@_); }
         my $addr = do { no overloading; pack 'J', $self; };
         my $current_leader = ($related) ? $parent{$addr} : $leader{$addr};
 
-        if ($related &&
-            ! $other->perl_extension
-            && ! $current_leader->perl_extension)
-        {
-            Carp::my_carp_bug("set_equivalent_to should have 'Related => 0 for equivalencing two Unicode properties.  Assuming $self is not related to $other");
-            $related = 0;
+        if ($related) {
+            if ($current_leader->perl_extension) {
+                if ($other->perl_extension) {
+                    Carp::my_carp_bug("Use add_alias() to set two Perl tables '$self' and '$other', equivalent.");
+                    return;
+                }
+            } elsif (! $other->perl_extension) {
+                Carp::my_carp_bug("set_equivalent_to should have 'Related => 0 for equivalencing two Unicode properties.  Assuming $self is not related to $other");
+                $related = 0;
+            }
+        }
+
+        if (! $self->is_empty && ! $self->matches_identically_to($other)) {
+            Carp::my_carp_bug("$self should be empty or match identically to $other.  Not setting equivalent");
+            return;
         }
 
         my $leader = do { no overloading; pack 'J', $current_leader; };