From: Ilya Zakharevich Date: Wed, 9 Dec 1998 10:39:31 +0000 (+0200) Subject: Warn on unrecognized alpha escapes. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c9f97d15d3a5d7fcbfc403087c4a4a450990ff7c;p=p5sagit%2Fp5-mst-13.2.git Warn on unrecognized alpha escapes. To: perl5-porters@perl.org (Mailing list Perl5) Message-ID: p4raw-id: //depot/cfgperl@2516 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 0b157c1..e0e9b12 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -57,6 +57,12 @@ no useful value. See L. checksumming process loses information, and you can't go the other way. See L. +=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. diff --git a/regcomp.c b/regcomp.c index 2f39b27..82d2b8e 100644 --- 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 --- 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;