From 216bfc0a080a7190b7235110e12114b87f6e7b56 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sat, 12 Feb 2011 21:08:50 -0700 Subject: [PATCH] regcomp.c: include { in unregcognized \q{ warning The warning message about regex unrecognized escapes passed through is changed to include any literal '{' following the 2-char escape. e.g., "\q{" will include the { in the message as part of the escape. --- pod/perldiag.pod | 4 ++-- regcomp.c | 9 +++++++-- t/lib/warnings/regcomp | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 81c0c26..871e0a2 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -4818,10 +4818,10 @@ escape was discovered. recognized by Perl. The character was understood literally, but this may change in a future version of Perl. -=item Unrecognized escape \%c passed through in regex; marked by <-- HERE in m/%s/ +=item Unrecognized escape \%s passed through in regex; marked by <-- HERE in m/%s/ (W regexp) You used a backslash-character combination which is not -recognized by Perl. The character was understood literally, but this may +recognized by Perl. The character(s) were understood literally, but this may change in a future version of Perl. The <-- HERE shows in the regular expression about where the escape was discovered. diff --git a/regcomp.c b/regcomp.c index 43fa7f0..62e9448 100644 --- a/regcomp.c +++ b/regcomp.c @@ -8558,8 +8558,13 @@ tryagain: FAIL("Trailing \\"); /* FALL THROUGH */ default: - if (!SIZE_ONLY&& isALPHA(*p)) - ckWARN2reg(p + 1, "Unrecognized escape \\%c passed through", UCHARAT(p)); + if (!SIZE_ONLY&& isALPHA(*p)) { + /* Include any { following the alpha to emphasize + * that it could be part of an escape at some point + * in the future */ + int len = (*(p + 1) == '{') ? 2 : 1; + ckWARN3reg(p + len, "Unrecognized escape \\%.*s passed through", len, p); + } goto normal_default; } break; diff --git a/t/lib/warnings/regcomp b/t/lib/warnings/regcomp index 932fc83..b318784 100644 --- a/t/lib/warnings/regcomp +++ b/t/lib/warnings/regcomp @@ -56,12 +56,15 @@ Unrecognized escape \m passed through in regex; marked by <-- HERE in m/a\m <-- # The \q should warn, the \_ should NOT warn. use warnings 'regexp'; "foo" =~ /\q/; +"foo" =~ /\q{/; "bar" =~ /\_/; no warnings 'regexp'; "foo" =~ /\q/; +"foo" =~ /\q{/; "bar" =~ /\_/; EXPECT Unrecognized escape \q passed through in regex; marked by <-- HERE in m/\q <-- HERE / at - line 4. +Unrecognized escape \q{ passed through in regex; marked by <-- HERE in m/\q{ <-- HERE / at - line 5. ######## # regcomp.c [S_regpposixcc S_checkposixcc] # -- 1.8.3.1