From: Yitzchak Scott-Thoennes Date: Mon, 22 Mar 2004 10:32:05 +0000 (-0800) Subject: Re: [PATCH] warn on !=~ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=decca21cb05bd8819a555574b7c51f4597013939;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] warn on !=~ Message-ID: <20040322183106.GA1284@efn.org> More warnings for this case. p4raw-id: //depot/perl@22553 --- diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index f9072ab..3197824 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -824,14 +824,23 @@ $a !=~ /1/; $a !=~ m#1#; $a !=~/1/; $a !=~ ?/?; +$a !=~ y/1//; +$a !=~ tr/1//; +$a !=~ s/1//; $a != ~/1/; no warnings "syntax"; $a !=~ /1/; $a !=~ m#1#; $a !=~/1/; $a !=~ ?/?; +$a !=~ y/1//; +$a !=~ tr/1//; +$a !=~ s/1//; EXPECT !=~ should be !~ at - line 4. !=~ should be !~ at - line 5. !=~ should be !~ at - line 6. !=~ should be !~ at - line 7. +!=~ should be !~ at - line 8. +!=~ should be !~ at - line 9. +!=~ should be !~ at - line 10. diff --git a/toke.c b/toke.c index 46aa3aa..e27e32c 100644 --- a/toke.c +++ b/toke.c @@ -3383,14 +3383,18 @@ Perl_yylex(pTHX) s++; tmp = *s++; if (tmp == '=') { - /* was this !=~ where !~ was meant? */ + /* was this !=~ where !~ was meant? + * warn on m:!=~\s+([/?]|[msy]\W|tr\W): */ + if (*s == '~' && ckWARN(WARN_SYNTAX)) { char *t = s+1; while (t < PL_bufend && isSPACE(*t)) ++t; - if (*t == '/' || (*t == 'm' && !isALNUM(t[1])) || *t == '?') + if (*t == '/' || *t == '?' || + ((*t == 'm' || *t == 's' || *t == 'y') && !isALNUM(t[1])) || + (*t == 't' && t[1] == 'r' && !isALNUM(t[2]))) Perl_warner(aTHX_ packWARN(WARN_SYNTAX), "!=~ should be !~"); }