In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/5e2aa8f5378f1ea747613936965416cd7ab17628?hp=e0d4127d4f78760fc7f7c1fa6ebacf705baedb07>
- Log ----------------------------------------------------------------- commit 5e2aa8f5378f1ea747613936965416cd7ab17628 Author: Karl Williamson <[email protected]> Date: Sat Apr 9 16:05:09 2011 -0600 perlop: Update for 5.14 additions M pod/perlop.pod commit 9442e3b8d7c9c3e8121cad5682064cfc3e185f32 Author: Karl Williamson <[email protected]> Date: Tue Apr 12 11:50:06 2011 -0600 regcomp: Improve error message for (?-d:...) As agreed, this improvement is going into 5.14. A customized message is output, instead of a generic one. M pod/perldiag.pod M regcomp.c M t/re/reg_mesg.t commit 0c96c706fef52effd833861ae408c0cedef51125 Author: Karl Williamson <[email protected]> Date: Tue Apr 12 11:25:37 2011 -0600 PATCH: [perl #86972]: Tweak error messages An earlier commit in this series changed some error messages. I realized that it did not make sense really to use "/a" for the regex modifier, when the message was for the infix form "(?a:", so this just removes the slash. M regcomp.c M t/re/reg_mesg.t commit 0a06cafa01b2bd0066e041822184a026c59925ba Author: Karl Williamson <[email protected]> Date: Tue Apr 12 11:18:36 2011 -0600 perldelta: Typo M pod/perldelta.pod commit f0f9b3b837ba5aa54ede5cd72ec0f3e00345c17d Author: Karl Williamson <[email protected]> Date: Sat Apr 9 16:33:07 2011 -0600 perlreapi: Update as little as possible for 5.14 This keeps the docs at parity with earlier Perls. M pod/perlreapi.pod ----------------------------------------------------------------------- Summary of changes: pod/perldelta.pod | 2 +- pod/perldiag.pod | 10 ++++++++-- pod/perlop.pod | 14 ++++++++------ pod/perlreapi.pod | 23 ++++++++++++++--------- regcomp.c | 23 ++++++++++++++--------- t/re/reg_mesg.t | 11 ++++++----- 6 files changed, 51 insertions(+), 32 deletions(-) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 35fadaa..87753f4 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -3802,7 +3802,7 @@ None of these match. Also, this matching doesn't fully conform to the current Unicode standard, which asks that the matching be made upon the NFD -(Normalization Form .ecomposed) of the text. However, as of this +(Normalization Form Decomposed) of the text. However, as of this writing, March 2010, the Unicode standard is currently in flux about what they will recommend doing with regard to such cases. It may be that they will throw out the whole concept of multi-character matches. diff --git a/pod/perldiag.pod b/pod/perldiag.pod index e9c5543..88c55a8 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -4021,6 +4021,13 @@ expression compiler gave it. (F syntax, regexp) The regular expression pattern had too many occurrences of the specified modifier. Remove the extraneous ones. +=item Regexp modifier "%c" may not appear after the "-" + +(F regexp) Turning off the given modifier has the side effect of turning +on another one. Perl currently doesn't allow this. Reword the regular +expression to use the modifier you want to turn on (and place it before +the minus), instead of the one you want to turn off. + =item Regexp modifiers "/%c" and "/%c" are mutually exclusive (F syntax, regexp) The regular expression pattern had more than one of these @@ -4168,8 +4175,7 @@ where the problem was discovered. See L<perlre>. <-- HERE shows in the regular expression about where the problem was discovered. This happens when using the C<(?^...)> construct to tell Perl to use the default regular expression modifiers, and you -redundantly specify a default modifier; or having a modifier that can't -be turned off (such as C<"p"> or C<"l">) after a minus. For other +redundantly specify a default modifier. For other causes, see L<perlre>. =item Sequence \%s... not terminated in regex; marked by <-- HERE in m/%s/ diff --git a/pod/perlop.pod b/pod/perlop.pod index 046b616..3a33bb4 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -1328,8 +1328,10 @@ Options (specified by the following modifiers) are: that ${^PREMATCH}, ${^MATCH}, ${^POSTMATCH} will be defined. o Compile pattern only once. l Use the locale - u Use Unicode semantics - a Use ASCII for \d, \s, \w + u Use Unicode rules + a Use ASCII for \d, \s, \w; specifying two a's further restricts + /i matching so that no ASCII character will match a non-ASCII + one d Use Unicode or native charset, as in 5.12 and earlier If a precompiled pattern is embedded in a larger pattern then the effect @@ -1338,11 +1340,11 @@ modifier has is not propagated, being restricted to those patterns explicitly using it. The last four modifiers listed above, added in Perl 5.14, -control the character set semantics. They are documented in -L<perlre/Modifiers>. +control the character set semantics. See L<perlre> for additional information on valid syntax for STRING, and -for a detailed look at the semantics of regular expressions. +for a detailed look at the semantics of regular expressions. In +particular, all the modifiers are further explained in L<perlre/Modifiers>. =item m/PATTERN/msixpodualgc X<m> X<operator, match> @@ -1385,7 +1387,7 @@ the trailing delimiter. This avoids expensive run-time recompilations, and is useful when the value you are interpolating won't change over the life of the script. However, mentioning C</o> constitutes a promise that you won't change the variables in the pattern. If you change them, -Perl won't even notice. See also L<"qr/STRING/msixpodual">. +Perl won't even notice. =item The empty pattern // diff --git a/pod/perlreapi.pod b/pod/perlreapi.pod index 7028650..1c694a7 100644 --- a/pod/perlreapi.pod +++ b/pod/perlreapi.pod @@ -120,21 +120,26 @@ TODO: Document those cases. =item C</p> - RXf_PMf_KEEPCOPY -=back - -Additional flags: - -=over 4 - -=item RXf_PMf_LOCALE - -Set if C<use locale> is in effect. If present in C<< rx->extflags >> +=item Character set + +The character set semantics are determined by an enum that is contained +in this field. This is still experimental and subject to change, but +the current interface returns the rules by use of the in-line function +C<get_regex_charset(const U32 flags)>. The only currently documented +value returned from it is REGEX_LOCALE_CHARSET, which is set if +C<use locale> is in effect. If present in C<< rx->extflags >> C<split> will use the locale dependent definition of whitespace under when RXf_SKIPWHITE or RXf_WHITE are in effect. Under ASCII whitespace is defined as per L<isSPACE|perlapi/isSPACE>, and by the internal macros C<is_utf8_space> under UTF-8 and C<isSPACE_LC> under C<use locale>. +=back + +Additional flags: + +=over 4 + =item RXf_UTF8 Set if the pattern is L<SvUTF8()|perlapi/SvUTF8>, set by Perl_pmruntime. diff --git a/regcomp.c b/regcomp.c index 8cad5b1..0858841 100644 --- a/regcomp.c +++ b/regcomp.c @@ -7086,7 +7086,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth) goto excess_modifier; } else if (flagsp == &negflags) { - goto fail_modifiers; + goto neg_modifier; } cs = REGEX_LOCALE_CHARSET; has_charset_modifier = LOCALE_PAT_MOD; @@ -7097,14 +7097,14 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth) goto excess_modifier; } else if (flagsp == &negflags) { - goto fail_modifiers; + goto neg_modifier; } cs = REGEX_UNICODE_CHARSET; has_charset_modifier = UNICODE_PAT_MOD; break; case ASCII_RESTRICT_PAT_MOD: if (flagsp == &negflags) { - goto fail_modifiers; + goto neg_modifier; } if (has_charset_modifier) { if (cs != REGEX_ASCII_RESTRICTED_CHARSET) { @@ -7119,11 +7119,12 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth) has_charset_modifier = ASCII_RESTRICT_PAT_MOD; break; case DEPENDS_PAT_MOD: - if (has_use_defaults - || flagsp == &negflags) - { + if (has_use_defaults) { goto fail_modifiers; } + else if (flagsp == &negflags) { + goto neg_modifier; + } else if (has_charset_modifier) { goto excess_modifier; } @@ -7140,15 +7141,19 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth) excess_modifier: RExC_parse++; if (has_charset_modifier == ASCII_RESTRICT_PAT_MOD) { - vFAIL2("Regexp modifier \"/%c\" may appear a maximum of twice", ASCII_RESTRICT_PAT_MOD); + vFAIL2("Regexp modifier \"%c\" may appear a maximum of twice", ASCII_RESTRICT_PAT_MOD); } else if (has_charset_modifier == *(RExC_parse - 1)) { - vFAIL2("Regexp modifier \"/%c\" may not appear twice", *(RExC_parse - 1)); + vFAIL2("Regexp modifier \"%c\" may not appear twice", *(RExC_parse - 1)); } else { - vFAIL3("Regexp modifiers \"/%c\" and \"/%c\" are mutually exclusive", has_charset_modifier, *(RExC_parse - 1)); + vFAIL3("Regexp modifiers \"%c\" and \"%c\" are mutually exclusive", has_charset_modifier, *(RExC_parse - 1)); } /*NOTREACHED*/ + neg_modifier: + RExC_parse++; + vFAIL2("Regexp modifier \"%c\" may not appear after the \"-\"", *(RExC_parse - 1)); + /*NOTREACHED*/ case ONCE_PAT_MOD: /* 'o' */ case GLOBAL_PAT_MOD: /* 'g' */ if (SIZE_ONLY && ckWARN(WARN_REGEXP)) { diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t index 827900f..d6b343b 100644 --- a/t/re/reg_mesg.t +++ b/t/re/reg_mesg.t @@ -64,11 +64,12 @@ my @death = '/(?^-i)foo/' => 'Sequence (?^-...) not recognized in regex; marked by {#} in m/(?^-{#}i)foo/', '/(?^d:foo)/' => 'Sequence (?^d...) not recognized in regex; marked by {#} in m/(?^d{#}:foo)/', '/(?^d)foo/' => 'Sequence (?^d...) not recognized in regex; marked by {#} in m/(?^d{#})foo/', - '/(?^lu:foo)/' => 'Regexp modifiers "/l" and "/u" are mutually exclusive in regex; marked by {#} in m/(?^lu{#}:foo)/', - '/(?^lu)foo/' => 'Regexp modifiers "/l" and "/u" are mutually exclusive in regex; marked by {#} in m/(?^lu{#})foo/', -'/(?da:foo)/' => 'Regexp modifiers "/d" and "/a" are mutually exclusive in regex; marked by {#} in m/(?da{#}:foo)/', -'/(?lil:foo)/' => 'Regexp modifier "/l" may not appear twice in regex; marked by {#} in m/(?lil{#}:foo)/', -'/(?aaia:foo)/' => 'Regexp modifier "/a" may appear a maximum of twice in regex; marked by {#} in m/(?aaia{#}:foo)/', + '/(?^lu:foo)/' => 'Regexp modifiers "l" and "u" are mutually exclusive in regex; marked by {#} in m/(?^lu{#}:foo)/', + '/(?^lu)foo/' => 'Regexp modifiers "l" and "u" are mutually exclusive in regex; marked by {#} in m/(?^lu{#})foo/', +'/(?da:foo)/' => 'Regexp modifiers "d" and "a" are mutually exclusive in regex; marked by {#} in m/(?da{#}:foo)/', +'/(?lil:foo)/' => 'Regexp modifier "l" may not appear twice in regex; marked by {#} in m/(?lil{#}:foo)/', +'/(?aaia:foo)/' => 'Regexp modifier "a" may appear a maximum of twice in regex; marked by {#} in m/(?aaia{#}:foo)/', +'/(?i-l:foo)/' => 'Regexp modifier "l" may not appear after the "-" in regex; marked by {#} in m/(?i-l{#}:foo)/', '/((x)/' => 'Unmatched ( in regex; marked by {#} in m/({#}(x)/', -- Perl5 Master Repository
