From: Mark-Jason Dominus Date: Thu, 28 Mar 2002 10:36:03 +0000 (-0500) Subject: warning at use of /c modifier with s/// X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=64e578a2028c106ba475fea230ca8011441e4bed;p=p5sagit%2Fp5-mst-13.2.git warning at use of /c modifier with s/// Message-ID: <20020328153603.11992.qmail@plover.com> p4raw-id: //depot/perl@15586 --- diff --git a/pod/perldelta.pod b/pod/perldelta.pod index b9e9936..2d4e716 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 match modifier without an accompanying C modifier elicits a new warning: C. +Use of C in substitutions, even with C, elicits +C. =back diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 60b67c9..35f26c4 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3985,6 +3985,11 @@ returns no useful value. See L. (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 af67277a..73dd229 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. diff --git a/toke.c b/toke.c index 7bc7661..5571500 100644 --- a/toke.c +++ b/toke.c @@ -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) {