This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop having one of the following qw() warnings hide the other:
authorEric Brine <ikegami@adaelis.com>
Wed, 22 Jun 2011 08:06:10 +0000 (01:06 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 4 Jul 2011 05:02:56 +0000 (22:02 -0700)
 - Possible attempt to separate words with commas
 - Possible attempt to put comments in qw() list

t/lib/warnings/toke
toke.c

index b7653ce..faef138 100644 (file)
@@ -275,13 +275,22 @@ Possible attempt to separate words with commas at - line 3.
 ########
 # toke.c
 use warnings 'qw' ;
-@a = qw(a b #) ;
+@a = qw(a b c # #) ;
 no warnings 'qw' ;
-@a = qw(a b #) ;
+@a = qw(a b c # #) ;
 EXPECT
 Possible attempt to put comments in qw() list at - line 3.
 ########
 # toke.c
+use warnings 'qw' ;
+@a = qw(a, b, c # #) ;
+no warnings 'qw' ;
+@a = qw(a, b, c # #) ;
+EXPECT
+Possible attempt to separate words with commas at - line 3.
+Possible attempt to put comments in qw() list at - line 3.
+########
+# toke.c
 use warnings 'syntax' ;
 print ("");
 print ("") and $x = 1;
diff --git a/toke.c b/toke.c
index 3686162..db03f9a 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -7645,7 +7645,8 @@ Perl_yylex(pTHX)
                missingterm(NULL);
            PL_expect = XOPERATOR;
            if (SvCUR(PL_lex_stuff)) {
-               int warned = 0;
+               int warned_comma = !ckWARN(WARN_QW);
+               int warned_comment = warned_comma;
                d = SvPV_force(PL_lex_stuff, len);
                while (len) {
                    for (; isSPACE(*d) && len; --len, ++d)
@@ -7653,17 +7654,17 @@ Perl_yylex(pTHX)
                    if (len) {
                        SV *sv;
                        const char *b = d;
-                       if (!warned && ckWARN(WARN_QW)) {
+                       if (!warned_comma || !warned_comment) {
                            for (; !isSPACE(*d) && len; --len, ++d) {
-                               if (*d == ',') {
+                               if (!warned_comma && *d == ',') {
                                    Perl_warner(aTHX_ packWARN(WARN_QW),
                                        "Possible attempt to separate words with commas");
-                                   ++warned;
+                                   ++warned_comma;
                                }
-                               else if (*d == '#') {
+                               else if (!warned_comment && *d == '#') {
                                    Perl_warner(aTHX_ packWARN(WARN_QW),
                                        "Possible attempt to put comments in qw() list");
-                                   ++warned;
+                                   ++warned_comment;
                                }
                            }
                        }