utf8_heavy: Return pointer to special treatment hash.
authorKarl Williamson <public@khwilliamson.com>
Sat, 14 May 2011 16:10:21 +0000 (10:10 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 19 May 2011 16:31:20 +0000 (10:31 -0600)
Many of the mapping tables that utf8_heavy.pl deals with have maps that
don't fit into the general scheme of things, and a hash is generated for
those.  This patch causes utf8_heavy to add an entry to the object it
generates containing a reference to this hash.  Prior to this, the name
of the hash had to be known to the users of the table.

lib/utf8_heavy.pl

index b744b3b..13caa39 100644 (file)
@@ -74,6 +74,8 @@ sub croak { require Carp; Carp::croak(@_) }
         #   Upon success, a new (or cached) blessed object is returned with
         #   keys TYPE, BITS, EXTRAS, LIST, and NONE with values having the
         #   same meanings as the input parameters.
+        #   And if there is a special-treatment hash in the file, a reference
+        #   to it is returned in the entry with key SPECIALS
         my $file; ## file to load data from, and also part of the %Cache key.
         my $ListSorted = 0;
 
@@ -540,6 +542,15 @@ sub croak { require Carp; Carp::croak(@_) }
 
         if ($file) {
             $Cache{$class, $file} = $SWASH;
+            if ($type
+                && exists $utf8::SwashInfo{$type}
+                && exists $utf8::SwashInfo{$type}{'specials_name'})
+            {
+                my $specials_name = $utf8::SwashInfo{$type}{'specials_name'};
+                no strict "refs";
+                print STDERR "\nspecials_name => $SWASH->{'SPECIALS'}\n" if DEBUG;
+                $SWASH->{'SPECIALS'} = \%$specials_name;
+            }
         }
 
         pop @recursed if @recursed && $type;