Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit e56da2d

Browse files
committed
Undeprecate some uses of unescaped { in patterns
perl5 really went ahead with fatalizing too many occurences of unescaped {} with every prefix, cperl fatalizes only the actually reserved character prefixes: \NpPbBxog. [cperl #362] Remove the old (and unused) deprecation messages. See commit 76416d1 - Karl Williamson
1 parent 7d35067 commit e56da2d

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

pod/perldiag.pod

+3-5
Original file line numberDiff line numberDiff line change
@@ -6826,11 +6826,9 @@ C<undef *foo>.
68266826
(A) You've accidentally run your script through B<csh> instead of Perl.
68276827
Check the #! line, or manually feed your script into Perl yourself.
68286828

6829-
=item Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by S<<-- HERE> in m/%s/
6829+
=item Unescaped left brace in regex is passed through in regex; marked by S<<-- HERE> in m/%s/
68306830

6831-
=item Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.32), passed through in regex; marked by S<<-- HERE> in m/%s/
6832-
6833-
(D deprecated, regexp) The simple rule to remember, if you want to
6831+
(W regexp) The simple rule to remember, if you want to
68346832
match a literal C<"{"> character (U+007B C<LEFT CURLY BRACKET>) in a
68356833
regular expression pattern, is to escape each literal instance of it in
68366834
some way. Generally easiest is to precede it with a backslash, like
@@ -6883,7 +6881,7 @@ as the first character following a quantifier
68836881

68846882
=item *
68856883

6886-
in cperl only if the unicode group is one of the following reserved:
6884+
in cperl only if the unicode group is one of the following reserved prefixes:
68876885

68886886
Name: /\N{/
68896887
Property: /\p{/ /\P{/

regcomp.c

+23-9
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ static const scan_data_t zero_scan_data = {
820820
REPORT_LOCATION_ARGS(loc)); \
821821
} STMT_END
822822

823+
/* now unused */
823824
#define ckWARNregdep(loc,m) STMT_START { \
824825
__ASSERT_(PASS2) Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, \
825826
WARN_REGEXP), \
@@ -11641,10 +11642,9 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth)
1164111642
&& UCHARAT(RExC_parse-2) == '\\'
1164211643
&& strpbrk(RExC_parse-1, "NpPbBxog") == RExC_parse-1)
1164311644
{
11644-
ckWARNregdep(RExC_parse + 1,
11645-
"Unescaped left brace in regex is "
11646-
"deprecated here (and will be fatal "
11647-
"in Perl 5.32), passed through");
11645+
ckWARNreg(RExC_parse + 1,
11646+
"Unescaped left brace in regex is "
11647+
"passed through");
1164811648
}
1164911649
/* Not bothering to indent here, as the above 'else' is temporary
1165011650
* */
@@ -13869,6 +13869,22 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
1386913869
* cperl special-cases only \NpPbBxog{} [cperl #362], later ({...}),
1387013870
* all other cases are legal. */
1387113871
#ifndef USE_CPERL
13872+
/* perl5 policy: */
13873+
/* Trying to gain new uses for '{' without breaking too
13874+
* much existing code is hard. The solution currently
13875+
* adopted is:
13876+
* 1) If there is no ambiguity that a '{' should always
13877+
* be taken literally, at the start of a construct, we
13878+
* just do so.
13879+
* 2) If the literal '{' conflicts with our desired use
13880+
* of it as a metacharacter, we die. The deprecation
13881+
* cycles for this have come and gone.
13882+
* 3) If there is ambiguity, we raise a simple warning.
13883+
* This could happen, for example, if the user
13884+
* intended it to introduce a quantifier, but slightly
13885+
* misspelled the quantifier. Without this warning,
13886+
* the quantifier would silently be taken as a literal
13887+
* string of characters instead of a meta construct */
1387213888
if (!(p - RExC_parse > 1
1387313889
&& UCHARAT(p-2) == '\\'
1387413890
&& strpbrk(p-1, "NpPbBxog") == p-1))
@@ -13886,10 +13902,8 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
1388613902
vFAIL("Unescaped left brace in regex is illegal here");
1388713903
}
1388813904
if (PASS2) {
13889-
ckWARNregdep(p + 1,
13890-
"Unescaped left brace in regex is "
13891-
"deprecated here (and will be fatal "
13892-
"in Perl 5.30), passed through");
13905+
ckWARNreg(p + 1, "Unescaped left brace in regex is"
13906+
" passed through");
1389313907
}
1389413908
}
1389513909
#endif
@@ -14407,7 +14421,7 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
1440714421
&& UCHARAT(RExC_parse-2) == '\\'
1440814422
&& strpbrk(RExC_parse-1, "NpPbBxog") == RExC_parse-1) /* [cperl #362] */
1440914423
{
14410-
ckWARNregdep(RExC_parse + 1, "Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through");
14424+
ckWARNreg(RExC_parse + 1, "Unescaped left brace in regex is passed through");
1441114425
}
1441214426

1441314427
return(ret);

t/re/reg_mesg.t

+5-4
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ my @warning_only_under_strict = (
663663
"/[$low_mixed_alpha-$high_mixed_alpha]/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/[$low_mixed_alpha-$high_mixed_alpha\{#}]/",
664664
"/[$low_mixed_digit-$high_mixed_digit]/" => "Ranges of ASCII printables should be some subset of \"0-9\", \"A-Z\", or \"a-z\" {#} m/[$low_mixed_digit-$high_mixed_digit\{#}]/",
665665
#'/\b<GCB}/' => 'Unescaped literal \'}\' {#} m/\b<GCB}{#}/',
666+
'/\b<GCB}/' => '',
666667
'/[ ]def]/' => 'Unescaped literal \']\' {#} m/[ ]def]{#}/',
667668
);
668669

@@ -694,13 +695,13 @@ my @deprecated = (
694695
'/^{/' => "",
695696
'/foo|{/' => "",
696697
'/foo|^{/' => "",
697-
#'/foo({bar)/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.32), passed through {#} m/foo({{#}bar)/',
698+
#'/foo({bar)/' => 'Unescaped left brace in regex passed through {#} m/foo({{#}bar)/',
698699
'/foo(:?{bar)/' => "",
699700
'/\s*{/' => "",
700701
'/a{3,4}{/' => "",
701-
#'/.{/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/.{{#}/',
702-
#'/[x]{/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/[x]{{#}/',
703-
#'/\p{Latin}{/' => 'Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through {#} m/\p{Latin}{{#}/',
702+
#'/.{/' => 'Unescaped left brace in regex passed through {#} m/.{{#}/',
703+
#'/[x]{/' => 'Unescaped left brace in regex passed through {#} m/[x]{{#}/',
704+
#'/\p{Latin}{/' => 'Unescaped left brace in regex passed through {#} m/\p{Latin}{{#}/',
704705
);
705706

706707
for my $strict ("", "use re 'strict';") {

0 commit comments

Comments
 (0)