Skip to content

Commit

Permalink
Revert "Deprecate literal unescaped "{" in regexes."
Browse files Browse the repository at this point in the history
This reverts commit 2a53d33.

Not the entire commit was reverted, but the deprecation message is
gone.  This caused too many problems.  See thread
http://www.nntp.perl.org/group/perl.perl5.porters/2012/11/msg195425.html
(which lists previous threads).
  • Loading branch information
Karl Williamson committed Jan 20, 2013
1 parent 902994e commit e62d0b1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 34 deletions.
16 changes: 2 additions & 14 deletions pod/perldiag.pod
Expand Up @@ -536,9 +536,9 @@ check the return value of your socket() call? See L<perlfunc/bind>.
(W unopened) You tried binmode() on a filehandle that was never opened.
Check your control flow and number of arguments.

=item "\b{" is deprecated; use "\b\{" instead
=item "\b{" is deprecated; use "\b\{" instead in regex; marked by <-- HERE in m/%s/

=item "\B{" is deprecated; use "\B\{" instead
=item "\B{" is deprecated; use "\B\{" instead in regex; marked by <-- HERE in m/%s/

(W deprecated, regexp) Use of an unescaped "{" immediately following a
C<\b> or C<\B> is now deprecated so as to reserve its use for Perl
Expand Down Expand Up @@ -5093,18 +5093,6 @@ C<undef *foo>.
(A) You've accidentally run your script through B<csh> instead of Perl.
Check the #! line, or manually feed your script into Perl yourself.

=item Unescaped left brace in regex is deprecated, passed through in regex;
marked by <-- HERE in m/%s/

(D deprecated, regexp) You used a literal C<"{"> character in a regular
expression pattern. You should change to use C<"\{"> instead, because a future
version of Perl (tentatively v5.20) will consider this to be a syntax error. If
the pattern delimiters are also braces, any matching right brace
(C<"}">) should also be escaped to avoid confusing the parser, for
example,

qr{abc\{def\}ghi}

=item unexec of %s into %s failed!

(F) The unexec() routine failed for some reason. See your local FSF
Expand Down
29 changes: 17 additions & 12 deletions regcomp.c
Expand Up @@ -10165,6 +10165,12 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
vFAIL("Internal urp");
/* Supposed to be caught earlier. */
break;
case '{':
if (!regcurly(RExC_parse)) {
RExC_parse++;
goto defchar;
}
/* FALL THROUGH */
case '?':
case '+':
case '*':
Expand Down Expand Up @@ -10244,6 +10250,9 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
ret = reg_node(pRExC_state, op);
FLAGS(ret) = get_regex_charset(RExC_flags);
*flagp |= SIMPLE;
if (! SIZE_ONLY && (U8) *(RExC_parse + 1) == '{') {
ckWARNregdep(RExC_parse, "\"\\b{\" is deprecated; use \"\\b\\{\" instead");
}
goto finish_meta_pat;
case 'B':
RExC_seen_zerolen++;
Expand All @@ -10255,6 +10264,9 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
ret = reg_node(pRExC_state, op);
FLAGS(ret) = get_regex_charset(RExC_flags);
*flagp |= SIMPLE;
if (! SIZE_ONLY && (U8) *(RExC_parse + 1) == '{') {
ckWARNregdep(RExC_parse, "\"\\B{\" is deprecated; use \"\\B\\{\" instead");
}
goto finish_meta_pat;

case 'D':
Expand Down Expand Up @@ -10755,22 +10767,15 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
/* FALL THROUGH */
default:
if (!SIZE_ONLY&& isALPHANUMERIC(*p)) {
ckWARN2reg(p + 1, "Unrecognized escape \\%.1s passed through", p);
/* Include any { following the alpha to emphasize
* that it could be part of an escape at some point
* in the future */
int len = (isALPHA(*p) && *(p + 1) == '{') ? 2 : 1;
ckWARN3reg(p + len, "Unrecognized escape \\%.*s passed through", len, p);
}
goto normal_default;
}
break;
case '{':
/* Currently we don't warn when the lbrace is at the start
* of a construct. This catches it in the middle of a
* literal string, or when its the first thing after
* something like "\b" */
if (! SIZE_ONLY
&& (len || (p > RExC_start && isALPHA_A(*(p -1)))))
{
ckWARNregdep(p + 1, "Unescaped left brace in regex is deprecated, passed through");
}
/*FALLTHROUGH*/
default:
normal_default:
if (UTF8_IS_START(*p) && UTF) {
Expand Down
10 changes: 3 additions & 7 deletions t/lib/warnings/regcomp
Expand Up @@ -59,24 +59,20 @@ Unrecognized escape \m passed through in regex; marked by <-- HERE in m/a\m <--
use warnings 'regexp'; no warnings "deprecated";
"foo" =~ /\q/;
"foo" =~ /\q{/;
"foo" =~ /\w{/;
"foo" =~ /a\b{cde/;
"foo" =~ /a\B{cde/;
"bar" =~ /\_/;
no warnings 'regexp';
"foo" =~ /\q/;
"foo" =~ /\q{/;
"foo" =~ /\w{/;
"foo" =~ /a\b{cde/;
"foo" =~ /a\B{cde/;
"bar" =~ /\_/;
EXPECT
Unrecognized escape \q passed through in regex; marked by <-- HERE in m/\q <-- HERE / at - line 4.
Unrecognized escape \q passed through in regex; marked by <-- HERE in m/\q <-- HERE {/ at - line 5.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\q{ <-- HERE / at - line 5.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\w{ <-- HERE / at - line 6.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/a\b{ <-- HERE cde/ at - line 7.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/a\B{ <-- HERE cde/ at - line 8.
Unrecognized escape \q{ passed through in regex; marked by <-- HERE in m/\q{ <-- HERE / at - line 5.
"\b{" is deprecated; use "\b\{" instead in regex; marked by <-- HERE in m/a\ <-- HERE b{cde/ at - line 6.
"\B{" is deprecated; use "\B\{" instead in regex; marked by <-- HERE in m/a\ <-- HERE B{cde/ at - line 7.
########
# regcomp.c [S_regpposixcc S_regclass]
#
Expand Down
1 change: 0 additions & 1 deletion t/re/pat_advanced.t
Expand Up @@ -1194,7 +1194,6 @@ sub run_tests {

{
# \, breaks {3,4}
no warnings qw{deprecated regexp};
ok "xaaay" !~ /xa{3\,4}y/, '\, in a pattern';
ok "xa{3,4}y" =~ /xa{3\,4}y/, '\, in a pattern';

Expand Down

0 comments on commit e62d0b1

Please sign in to comment.