summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2016-03-28 21:26:41 -0600
committerKarl Williamson <khw@cpan.org>2016-05-09 10:47:46 -0600
commit60108b47d6130990788b7498d939598cebe8a0b8 (patch)
tree673c8ffe79b56d6917557e633d52409add19aead
parentacab2422b2372f4b4d6e2542e9b9cf3dc0b83e92 (diff)
downloadperl-60108b47d6130990788b7498d939598cebe8a0b8.tar.gz
Make deprecated qr//xx fatal
This has been deprecated since v5.22
-rw-r--r--ext/re/re.pm16
-rw-r--r--ext/re/t/reflags.t4
-rw-r--r--pod/perldelta.pod6
-rw-r--r--pod/perldiag.pod15
-rw-r--r--regcomp.c5
-rw-r--r--regexp.h7
-rw-r--r--t/re/reg_mesg.t9
-rw-r--r--toke.c8
8 files changed, 34 insertions, 36 deletions
diff --git a/ext/re/re.pm b/ext/re/re.pm
index 058b8aa961..b924fd9fc7 100644
--- a/ext/re/re.pm
+++ b/ext/re/re.pm
@@ -4,7 +4,7 @@ package re;
use strict;
use warnings;
-our $VERSION = "0.32";
+our $VERSION = "0.33";
our @ISA = qw(Exporter);
our @EXPORT_OK = ('regmust',
qw(is_regexp regexp_pattern
@@ -247,17 +247,9 @@ sub bits {
")");
}
}
- if (exists $seen{'x'} && $seen{'x'} > 1
- && (warnings::enabled("deprecated")
- || warnings::enabled("regexp")))
- {
- my $message = "Having more than one /x regexp modifier is deprecated";
- if (warnings::enabled("deprecated")) {
- warnings::warn("deprecated", $message);
- }
- else {
- warnings::warn("regexp", $message);
- }
+ if (exists $seen{'x'} && $seen{'x'} > 1) {
+ require Carp;
+ Carp::croak("Only one /x regex modifier is allowed");
}
if ($turning_all_off) {
diff --git a/ext/re/t/reflags.t b/ext/re/t/reflags.t
index fd1c35a848..a481c98799 100644
--- a/ext/re/t/reflags.t
+++ b/ext/re/t/reflags.t
@@ -179,7 +179,7 @@ is qr//, '(?^:)', 'no re "/aai"';
$w = "";
eval "use re '/xamax'";
- like $w, qr/Having more than one \/x regexp modifier is deprecated/,
- "warning with eval \"use re \"/xamax\"";
+ like $@, qr/Only one \/x regex modifier is allowed/,
+ "error with eval \"use re \"/xamax\"";
}
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 027617ff48..7ede889fb0 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -41,6 +41,12 @@ v5.20. This affects things like C<$I<\cT>>, where I<\cT> is a literal
control (such as a C<NAK> or C<NEGATIVE ACKNOWLEDGE> character) in the
source code.
+=head2 C<qr//xx> is no longer permissible
+
+Using more than one C</x> regular expression pattern modifier on a
+single pattern is now forbidden. This is to allow a future enhancement
+to the language. This usage has been deprecated since v5.22.
+
=head2 C<NBSP> is no longer permissible in C<\N{...}>
The name of a character may no longer contain non-breaking spaces. It
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 0383ccbca7..35cbb19af0 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -2464,13 +2464,6 @@ created on an emergency basis to prevent a core dump.
(F) The parser has given up trying to parse the program after 10 errors.
Further error messages would likely be uninformative.
-=item Having more than one /%c regexp modifier is deprecated
-
-(D deprecated, regexp) You used the indicated regular expression pattern
-modifier at least twice in a string of modifiers. It is deprecated to
-do this with this particular modifier, to allow future extensions to the
-Perl language.
-
=item Hexadecimal float: exponent overflow
(W overflow) The hexadecimal floating point has a larger exponent
@@ -4134,6 +4127,14 @@ call, or call a constructor from the FileHandle package.
(W unopened) You tried to invoke a file test operator on a filehandle
that isn't open. Check your control flow. See also L<perlfunc/-X>.
+=item Only one /x regex modifier is allowed
+
+=item Only one /x regex modifier is allowed in regex; marked by <-- HERE in m/%s/
+
+(F) You used the C</x> regular expression pattern modifier at least
+twice in a string of modifiers. It is illegal to do this with, to allow
+future extensions to the Perl language.
+
=item oops: oopsAV
(S internal) An internal warning that the grammar is screwed up.
diff --git a/regcomp.c b/regcomp.c
index be6cb96a70..48d817b4f9 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -10233,8 +10233,9 @@ S_parse_lparen_question_flags(pTHX_ RExC_state_t *pRExC_state)
if (RExC_flags & RXf_PMf_FOLD) {
RExC_contains_i = 1;
}
- if (PASS2) {
- STD_PMMOD_FLAGS_PARSE_X_WARN(x_mod_count);
+
+ if (UNLIKELY((x_mod_count) > 1)) {
+ vFAIL("Only one /x regex modifier is allowed");
}
return;
/*NOTREACHED*/
diff --git a/regexp.h b/regexp.h
index 78aa899625..8a471f9d0b 100644
--- a/regexp.h
+++ b/regexp.h
@@ -287,13 +287,6 @@ and check for NULL.
case XTENDED_PAT_MOD: *(pmfl) |= RXf_PMf_EXTENDED; (x_count)++; break;\
case NOCAPTURE_PAT_MOD: *(pmfl) |= RXf_PMf_NOCAPTURE; break;
-#define STD_PMMOD_FLAGS_PARSE_X_WARN(x_count) \
- if (UNLIKELY((x_count) > 1)) { \
- Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_REGEXP), \
- "Having more than one /%c regexp modifier is deprecated", \
- XTENDED_PAT_MOD); \
- }
-
/* Note, includes charset ones, assumes 0 is the default for them */
#define STD_PMMOD_FLAGS_CLEAR(pmfl) \
*(pmfl) &= ~(RXf_PMf_FOLD|RXf_PMf_MULTILINE|RXf_PMf_SINGLELINE|RXf_PMf_EXTENDED|RXf_PMf_CHARSET|RXf_PMf_NOCAPTURE)
diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t
index 0fe4539695..db837d54d3 100644
--- a/t/re/reg_mesg.t
+++ b/t/re/reg_mesg.t
@@ -268,6 +268,11 @@ my @death =
'/(?[\ |!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[\ |!{#}])/', # [perl #126180]
'/(?[()-!])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[()-!{#}])/', # [perl #126204]
'/(?[!()])/' => 'Incomplete expression within \'(?[ ])\' {#} m/(?[!(){#}])/', # [perl #126404]
+ '/abc/xix' => 'Only one /x regex modifier is allowed',
+ '/(?xmsixp:abc)/' => 'Only one /x regex modifier is allowed {#} m/(?xmsixp{#}:abc)/',
+ '/(?xmsixp)abc/' => 'Only one /x regex modifier is allowed {#} m/(?xmsixp{#})abc/',
+ '/(?xxxx:abc)/' => 'Only one /x regex modifier is allowed {#} m/(?xxxx{#}:abc)/',
+
);
# These are messages that are warnings when not strict; death under 'use re
@@ -618,10 +623,6 @@ my @deprecated = (
'Unescaped left brace in regex is deprecated, passed through {#} m/\q{{#}/'
],
'/:{4,a}/' => 'Unescaped left brace in regex is deprecated, passed through {#} m/:{{#}4,a}/',
- '/abc/xix' => 'Having more than one /x regexp modifier is deprecated',
- '/(?xmsixp:abc)/' => 'Having more than one /x regexp modifier is deprecated',
- '/(?xmsixp)abc/' => 'Having more than one /x regexp modifier is deprecated',
- '/(?xxxx:abc)/' => 'Having more than one /x regexp modifier is deprecated',
);
for my $strict ("", "use re 'strict';") {
diff --git a/toke.c b/toke.c
index 39b2c76919..b16544ba66 100644
--- a/toke.c
+++ b/toke.c
@@ -9248,7 +9248,9 @@ S_scan_pat(pTHX_ char *start, I32 type)
"Use of /c modifier is meaningless without /g" );
}
- STD_PMMOD_FLAGS_PARSE_X_WARN(x_mod_count);
+ if (UNLIKELY((x_mod_count) > 1)) {
+ yyerror("Only one /x regex modifier is allowed");
+ }
PL_lex_op = (OP*)pm;
pl_yylval.ival = OP_MATCH;
@@ -9303,7 +9305,9 @@ S_scan_subst(pTHX_ char *start)
}
}
- STD_PMMOD_FLAGS_PARSE_X_WARN(x_mod_count);
+ if (UNLIKELY((x_mod_count) > 1)) {
+ yyerror("Only one /x regex modifier is allowed");
+ }
if ((pm->op_pmflags & PMf_CONTINUE)) {
Perl_ck_warner(aTHX_ packWARN(WARN_REGEXP), "Use of /c modifier is meaningless in s///" );