warning at use of /c modifier with s///
authorMark-Jason Dominus <mjd@plover.com>
Thu, 28 Mar 2002 10:36:03 +0000 (05:36 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 28 Mar 2002 16:23:41 +0000 (16:23 +0000)
Message-ID: <20020328153603.11992.qmail@plover.com>

p4raw-id: //depot/perl@15586

pod/perldelta.pod
pod/perldiag.pod
t/lib/warnings/toke
toke.c

index b9e9936..2d4e716 100644 (file)
@@ -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
 
index 60b67c9..35f26c4 100644 (file)
@@ -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
index af67277..73dd229 100644 (file)
@@ -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 (file)
--- 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) {