From: David Dyck Date: Mon, 26 Jun 2000 09:32:02 +0000 (-0700) Subject: Do no -warn on \_, only on \alpha. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=524710647511337b71f94221f2bea48278a5a629;p=p5sagit%2Fp5-mst-13.2.git Do no -warn on \_, only on \alpha. Subject: New Unrecognized escape warning for /\_/ from activestate perl-current5.6.0 Message-ID: p4raw-id: //depot/cfgperl@6241 --- diff --git a/regcomp.c b/regcomp.c index 89b3e53..0407e69 100644 --- a/regcomp.c +++ b/regcomp.c @@ -2646,7 +2646,8 @@ tryagain: FAIL("trailing \\ in regexp"); /* FALL THROUGH */ default: - if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && isALPHA(*p)) + if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && + isALPHA(*p) && *p != '_') Perl_warner(aTHX_ WARN_REGEXP, "/%.127s/: Unrecognized escape \\%c passed through", PL_regprecomp, @@ -2959,7 +2960,8 @@ S_regclass(pTHX) PL_regcomp_parse += numlen; break; default: - if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && isALPHA(value)) + if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && + isALPHA(value) && value != (UV)'_') Perl_warner(aTHX_ WARN_REGEXP, "/%.127s/: Unrecognized escape \\%c in character class passed through", PL_regprecomp, @@ -3443,7 +3445,8 @@ S_regclassutf8(pTHX) PL_regcomp_parse += numlen; break; default: - if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && isALPHA(value)) + if (!SIZE_ONLY && ckWARN(WARN_REGEXP) && + isALPHA(value) && value != (U32)'_') Perl_warner(aTHX_ WARN_REGEXP, "/%.127s/: Unrecognized escape \\%c in character class passed through", PL_regprecomp, diff --git a/t/pragma/warn/regcomp b/t/pragma/warn/regcomp index 5d0c291..cd2e5c2 100644 --- a/t/pragma/warn/regcomp +++ b/t/pragma/warn/regcomp @@ -46,10 +46,13 @@ Strange *+?{} on zero-length expression at - line 4. ######## # regcomp.c [S_regatom] $x = '\m' ; +$y = '\_' ; use warnings 'regexp' ; $a =~ /a$x/ ; +$b =~ /b$y/ ; no warnings 'regexp' ; $a =~ /a$x/ ; +$b =~ /b$y/ ; EXPECT /a\m/: Unrecognized escape \m passed through at - line 4. ######## @@ -159,7 +162,9 @@ EXPECT # regcomp.c [S_regclass S_regclassutf8] use warnings 'regexp' ; $a =~ /[a\zb]/ ; +$b =~ /[a\_b]/ ; no warnings 'regexp' ; $a =~ /[a\zb]/ ; +$b =~ /[a\_b]/ ; EXPECT /[a\zb]/: Unrecognized escape \z in character class passed through at - line 3. diff --git a/t/pragma/warn/toke b/t/pragma/warn/toke index 64f5368..b410e19 100644 --- a/t/pragma/warn/toke +++ b/t/pragma/warn/toke @@ -529,8 +529,10 @@ Ambiguous use of * resolved as operator * at - line 10. # toke.c use warnings 'misc' ; my $a = "\m" ; +my $b = "\_" ; no warnings 'misc' ; $a = "\m" ; +$b = "\_" ; EXPECT Unrecognized escape \m passed through at - line 3. ######## diff --git a/toke.c b/toke.c index fe14358..4c97aea 100644 --- a/toke.c +++ b/toke.c @@ -1392,7 +1392,7 @@ S_scan_const(pTHX_ char *start) default: { dTHR; - if (ckWARN(WARN_MISC) && isALNUM(*s)) + if (ckWARN(WARN_MISC) && isALNUM(*s) && *s != '_') Perl_warner(aTHX_ WARN_MISC, "Unrecognized escape \\%c passed through", *s);