This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mktables: Generate a table for quotemeta
authorKarl Williamson <public@khwilliamson.com>
Tue, 14 Feb 2012 01:47:20 +0000 (18:47 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 16 Feb 2012 01:02:34 +0000 (18:02 -0700)
This adds a new table generated by mktables consisting of the code
points that should be escaped by quotemeta

lib/unicore/mktables

index 6fea440..6da0063 100644 (file)
@@ -12698,6 +12698,31 @@ END
         $unassigned->set_equivalent_to($age_default, Related => 1);
     }
 
+    # See L<perlfunc/quotemeta>
+    my $quotemeta = $perl->add_match_table('_Perl_Quotemeta',
+                                           Perl_Extension => 1,
+                                           Fate => $INTERNAL_ONLY,
+
+                                           # Initialize to what's common in
+                                           # all Unicode releases.
+                                           Initialize =>
+                                                $Space
+                                                + $gc->table('Control')
+                           );
+
+    # In early releases without the proper Unicode properties, just set to \W.
+    if (! defined (my $patsyn = property_ref('Pattern_Syntax'))
+        || ! defined (my $patws = property_ref('Pattern_White_Space'))
+        || ! defined (my $di = property_ref('Default_Ignorable_Code_Point')))
+    {
+        $quotemeta += ~ $Word;
+    }
+    else {
+        $quotemeta += $patsyn->table('Y')
+                   + $patws->table('Y')
+                   + $di->table('Y')
+                   + ((~ $Word) & $ASCII);
+    }
 
     # Finished creating all the perl properties.  All non-internal non-string
     # ones have a synonym of 'Is_' prefixed.  (Internal properties begin with