summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-01-14 10:56:06 -0700
committerKarl Williamson <public@khwilliamson.com>2013-01-19 21:04:27 -0700
commite62d0b1335a7959680be5f7e56910067d6f33c1f (patch)
treeb141fb3f24b2c436468d42c4d19e681d361ec7b0
parent902994e45aafa5c63ac8bf2219075daf29139b3c (diff)
downloadperl-e62d0b1335a7959680be5f7e56910067d6f33c1f.tar.gz
Revert "Deprecate literal unescaped "{" in regexes."
This reverts commit 2a53d3314d380af5ab5283758219417c6dfa36e9. 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).
-rw-r--r--pod/perldiag.pod16
-rw-r--r--regcomp.c29
-rw-r--r--t/lib/warnings/regcomp10
-rw-r--r--t/re/pat_advanced.t1
4 files changed, 22 insertions, 34 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 0ba41a639b..8df73326ca 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -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
@@ -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
diff --git a/regcomp.c b/regcomp.c
index a22f8ff734..1cf4a84510 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -10165,6 +10165,12 @@ tryagain:
vFAIL("Internal urp");
/* Supposed to be caught earlier. */
break;
+ case '{':
+ if (!regcurly(RExC_parse)) {
+ RExC_parse++;
+ goto defchar;
+ }
+ /* FALL THROUGH */
case '?':
case '+':
case '*':
@@ -10244,6 +10250,9 @@ tryagain:
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++;
@@ -10255,6 +10264,9 @@ tryagain:
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':
@@ -10755,22 +10767,15 @@ tryagain:
/* 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) {
diff --git a/t/lib/warnings/regcomp b/t/lib/warnings/regcomp
index 09caf0308d..20ee8cfef9 100644
--- a/t/lib/warnings/regcomp
+++ b/t/lib/warnings/regcomp
@@ -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]
#
diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t
index 60ae9d6a42..29a64ddf60 100644
--- a/t/re/pat_advanced.t
+++ b/t/re/pat_advanced.t
@@ -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';