This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Warn on unrecognized alpha escapes.
authorIlya Zakharevich <ilya@math.berkeley.edu>
Wed, 9 Dec 1998 10:39:31 +0000 (12:39 +0200)
committerJarkko Hietaniemi <jhi@iki.fi>
Tue, 29 Dec 1998 11:32:26 +0000 (11:32 +0000)
To: perl5-porters@perl.org (Mailing list Perl5)
Message-ID: <MLIST_199812090823.DAA17566@monk.mps.ohio-state.edu>

p4raw-id: //depot/cfgperl@2516

pod/perldiag.pod
regcomp.c
toke.c

index 0b157c1..e0e9b12 100644 (file)
@@ -57,6 +57,12 @@ no useful value.  See L<perlmod>.
 checksumming process loses information, and you can't go the other
 way.  See L<perlfunc/unpack>.
 
+=item /%s/: Unrecognized escape \\%c passed through
+
+(W) You used a backslash-character combination which is not recognized
+by Perl.  This combination appears in an interpolated variable or a 
+C<'>-delimited regular expression.
+
 =item %s (...) interpreted as function
 
 (W) You've run afoul of the rule that says that any list operator followed
@@ -2770,6 +2776,11 @@ an underbar into it.  You might also declare it as a subroutine.
 in your Perl script (or eval).  Perhaps you tried to run a compressed
 script, a binary program, or a directory as a Perl program.
 
+=item Unrecognized escape \\%c passed through
+
+(W) You used a backslash-character combination which is not recognized
+by Perl.
+
 =item Unrecognized signal name "%s"
 
 (F) You specified a signal name to the kill() function that was not recognized.
index 2f39b27..82d2b8e 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -1878,6 +1878,8 @@ tryagain:
                FAIL("trailing \\ in regexp");
            /* FALL THROUGH */
        default:
+           /* Do not generate `unrecognized' warnings here, we fall
+              back into the quick-grab loop below */
            goto defchar;
        }
        break;
@@ -2008,6 +2010,11 @@ tryagain:
                            FAIL("trailing \\ in regexp");
                        /* FALL THROUGH */
                    default:
+                       if (!SIZE_ONLY && ckWARN(WARN_UNSAFE) && isALPHA(*p))
+                           warner(WARN_UNSAFE, 
+                                  "/%.127s/: Unrecognized escape \\%c passed through",
+                                  PL_regprecomp,
+                                  *p);
                        goto normal_default;
                    }
                    break;
diff --git a/toke.c b/toke.c
index b1bd0d7..b9fa540 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1056,7 +1056,7 @@ scan_const(char *start)
            s++;
 
            /* some backslashes we leave behind */
-           if (*s && strchr(leaveit, *s)) {
+           if (*leaveit && *s && strchr(leaveit, *s)) {
                *d++ = '\\';
                *d++ = *s++;
                continue;
@@ -1091,6 +1091,10 @@ scan_const(char *start)
                /* FALL THROUGH */
            /* default action is to copy the quoted character */
            default:
+               if (ckWARN(WARN_UNSAFE) && isALPHA(*s))
+                   warner(WARN_UNSAFE, 
+                          "Unrecognized escape \\%c passed through",
+                          *s);
                *d++ = *s++;
                continue;