diff options
author | Karl Williamson <public@khwilliamson.com> | 2011-04-11 11:06:05 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2011-04-11 11:31:57 -0600 |
commit | 342c85242bced7dbfd83bf3d2621282751e996b8 (patch) | |
tree | 8f410d0ebca08e0a610feb6fea91703f84b41102 /ext/re/re.pm | |
parent | efc5c7c332b6baa4c90ca3e3de1fba8ce28448ae (diff) | |
download | perl-342c85242bced7dbfd83bf3d2621282751e996b8.tar.gz |
PATCH: final [perl #86972]: Allow /(?aia)/
This fixes "use re '/aia'", and completes the sequence of commits
for this ticket.
Diffstat (limited to 'ext/re/re.pm')
-rw-r--r-- | ext/re/re.pm | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/ext/re/re.pm b/ext/re/re.pm index 35d2e29a69..9d0921b80e 100644 --- a/ext/re/re.pm +++ b/ext/re/re.pm @@ -4,7 +4,7 @@ package re; use strict; use warnings; -our $VERSION = "0.17"; +our $VERSION = "0.18"; our @ISA = qw(Exporter); our @EXPORT_OK = ('regmust', qw(is_regexp regexp_pattern @@ -145,9 +145,26 @@ sub bits { } elsif ($s =~ s/^\///) { my $reflags = $^H{reflags} || 0; my $seen_charset; - while ($s =~ m/( aa | . )/gx) { + while ($s =~ m/( . )/gx) { $_ = $1; if (/[adul]/) { + # The 'a' may be repeated; hide this from the rest of the + # code by counting and getting rid of all of them, then + # changing to 'aa' if there is a repeat. + if ($_ eq 'a') { + my $sav_pos = pos $s; + my $a_count = $s =~ s/a//g; + pos $s = $sav_pos - 1; # -1 because got rid of the 'a' + if ($a_count > 2) { + require Carp; + Carp::carp( + qq 'The "a" flag may only appear a maximum of twice' + ); + } + elsif ($a_count == 2) { + $_ = 'aa'; + } + } if ($on) { if ($seen_charset) { require Carp; @@ -157,12 +174,6 @@ sub bits { .qq 'are exclusive' ); } - elsif ($seen_charset eq 'a') { - Carp::carp( - qq 'The "a" flag may only appear twice if ' - .qq 'adjacent, like "aa"' - ); - } else { Carp::carp( qq 'The "$seen_charset" flag may not appear ' |