Do no -warn on \_, only on \alpha.
David Dyck [Mon, 26 Jun 2000 09:32:02 +0000 (02:32 -0700)]
Subject: New Unrecognized escape warning for /\_/ from activestate perl-current5.6.0
Message-ID: <Pine.LNX.4.05.10006260830280.3054-100000@dd.tc.fluke.com>

p4raw-id: //depot/cfgperl@6241

regcomp.c
t/pragma/warn/regcomp
t/pragma/warn/toke
toke.c

index 89b3e53..0407e69 100644 (file)
--- 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,
index 5d0c291..cd2e5c2 100644 (file)
@@ -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.
index 64f5368..b410e19 100644 (file)
@@ -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 (file)
--- 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);