diff options
-rw-r--r-- | pod/perldelta.pod | 2 | ||||
-rw-r--r-- | pod/perldiag.pod | 5 | ||||
-rw-r--r-- | t/lib/warnings/toke | 9 | ||||
-rw-r--r-- | toke.c | 8 |
4 files changed, 19 insertions, 5 deletions
diff --git a/pod/perldelta.pod b/pod/perldelta.pod index b9e9936397..2d4e716dfd 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -559,6 +559,8 @@ The command-line options -s and -F are now recognized on the shebang Use of the C</c> match modifier without an accompanying C</g> modifier elicits a new warning: C<Use of /c modifier is meaningless without /g>. +Use of C</c> in substitutions, even with C</g>, elicits +C<Use of /c modifier is meaningless in s///>. =back diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 60b67c9da8..35f26c4793 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3985,6 +3985,11 @@ returns no useful value. See L<perlmod>. (D deprecated) You are now encouraged to use the explicitly quoted form if you wish to use an empty line as the terminator of the here-document. +=item Use of /c modifier is meaningless in s/// + +(W regexp) You used the /c modifier in a substitution. The /c +modifier is not presently meaningful in substitutions. + =item Use of /c modifier is meaningless without /g (W regexp) You used the /c modifier with a regex operand, but didn't diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index af67277a3a..73dd229a9e 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -106,6 +106,8 @@ toke.c AOK Use of /c modifier is meaningless without /g + Use of /c modifier is meaningless in s/// + Mandatory Warnings ------------------ Use of "%s" without parentheses is ambiguous [check_uni] @@ -745,8 +747,10 @@ Unrecognized escape \q passed through at - line 4. # 20020328 mjd@plover.com at behest of jfriedl@yahoo.com use warnings 'regexp'; "foo" =~ /foo/c; +"foo" =~ /foo/cg; no warnings 'regexp'; "foo" =~ /foo/c; +"foo" =~ /foo/cg; EXPECT Use of /c modifier is meaningless without /g at - line 4. ######## @@ -755,7 +759,10 @@ Use of /c modifier is meaningless without /g at - line 4. use warnings 'regexp'; $_ = "ab" ; s/ab/ab/c; +s/ab/ab/cg; no warnings 'regexp'; s/ab/ab/c; +s/ab/ab/cg; EXPECT -Use of /c modifier is meaningless without /g at - line 5. +Use of /c modifier is meaningless in s/// at - line 5. +Use of /c modifier is meaningless in s/// at - line 6. @@ -27,6 +27,7 @@ static char ident_too_long[] = "Identifier too long"; static char c_without_g[] = "Use of /c modifier is meaningless without /g"; +static char c_in_subst[] = "Use of /c modifier is meaningless in s///"; static void restore_rsfp(pTHX_ void *f); #ifndef PERL_NO_UTF16_FILTER @@ -6340,11 +6341,10 @@ S_scan_subst(pTHX_ char *start) break; } - /* issue a warning if /c is specified,but /g is not */ - if (ckWARN(WARN_REGEXP) && - (pm->op_pmflags & PMf_CONTINUE) && !(pm->op_pmflags & PMf_GLOBAL)) + /* /c is not meaningful with s/// */ + if (ckWARN(WARN_REGEXP) && (pm->op_pmflags & PMf_CONTINUE)) { - Perl_warner(aTHX_ packWARN(WARN_REGEXP), c_without_g); + Perl_warner(aTHX_ packWARN(WARN_REGEXP), c_in_subst); } if (es) { |