This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regen/regcharclass.pl: Don't generate macro twice
authorKarl Williamson <khw@cpan.org>
Tue, 29 Apr 2014 01:42:32 +0000 (19:42 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 30 May 2014 16:24:27 +0000 (10:24 -0600)
Until this patch, this could happen if both 'safe' and 'fast' are
specified with a cp macro.

regen/regcharclass.pl

index b837af4..002cd0f 100755 (executable)
@@ -1389,6 +1389,14 @@ EOF
             my ( $type, $ret )= split /-/, $type_spec;
             $ret ||= 'len';
             foreach my $mod ( @mods ) {
+
+                # 'safe' is irrelevant with code point macros, so skip if
+                # there is also a 'fast', but don't skip if this is the only
+                # way a cp macro will get generated.  Below we convert 'safe'
+                # to 'fast' in this instance
+                next if $type =~ /^cp/
+                        && $mod eq 'safe'
+                        && grep { 'fast' eq $_ } @mods;
                 delete $mods{$mod};
                 my $macro= $obj->make_macro(
                     type     => $type,