In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/d8d26cacf9f6b2fbd47665039d13384d3ccfd516?hp=1921e03146ca6022defa6af5267c4dd20c0ca699>
- Log ----------------------------------------------------------------- commit d8d26cacf9f6b2fbd47665039d13384d3ccfd516 Author: Karl Williamson <[email protected]> Date: Thu Mar 24 19:45:24 2016 -0600 PATCH: [perl #123417] Deprecate empty \N{} M pod/perldelta.pod M pod/perldiag.pod M t/lib/warnings/regcomp M t/re/pat_advanced.t M t/re/reg_mesg.t M t/re/regexp.t M toke.c commit c642c6b2f3e0e46492630a2e09eadb41be549bba Author: Karl Williamson <[email protected]> Date: Tue Mar 22 11:03:51 2016 -0600 t/re/re_tests: Add missing \ escape to a test This just happened to work, but the backslash should be escaped, as it is evaluated in qq context M t/re/re_tests ----------------------------------------------------------------------- Summary of changes: pod/perldelta.pod | 5 ++++- pod/perldiag.pod | 6 ++++++ t/lib/warnings/regcomp | 40 +++++++++++++++++++++++++++++++++++++++- t/re/pat_advanced.t | 1 + t/re/re_tests | 2 +- t/re/reg_mesg.t | 6 ++---- t/re/regexp.t | 2 +- toke.c | 5 ++++- 8 files changed, 58 insertions(+), 9 deletions(-) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index ecdac94..4cf4422 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -47,7 +47,10 @@ XXX For a release on a stable branch, this section aspires to be: =head1 Deprecations -XXX Any deprecated features, syntax, modules etc. should be listed here. +=head2 \N{} with nothing between the braces is deprecated + +This had been illegal until v5.22, and will be illegal again in a future +Perl version. =head2 Module removals diff --git a/pod/perldiag.pod b/pod/perldiag.pod index fd91cd4..505dec9 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -6231,6 +6231,12 @@ problems when being input or output, which is likely where this message came from. If you really really know what you are doing you can turn off this warning by C<no warnings 'surrogate';>. +=item Unknown charname '' is deprecated + +(D deprecated) You had a C<\N{}> with nothing between the braces. This +usage is deprecated, and will be made a syntax error in a future Perl +version. + =item Unknown charname '%s' (F) The name you used inside C<\N{}> is unknown to Perl. Check the diff --git a/t/lib/warnings/regcomp b/t/lib/warnings/regcomp index 5d13678..08cb27b 100644 --- a/t/lib/warnings/regcomp +++ b/t/lib/warnings/regcomp @@ -1,6 +1,7 @@ regcomp.c These tests have been moved to t/re/reg_mesg.t except for those that explicitly test line numbers - and those that don't have a <-- HERE in them, and those that die plus have warnings + and those that don't have a <-- HERE in them, and those that + die plus have warnings, or otherwise require special handling __END__ use warnings 'regexp'; @@ -80,3 +81,40 @@ eval {/$_/}, print "$_ ==> ", $@ || "OK!\n" for "]]]]]]]]][\\", "]]]]][\\" EXPECT ]]]]]]]]][\ ==> Unmatched [ in regex; marked by <-- HERE in m/]]]]]]]]][\ <-- HERE / at - line 2. ]]]]][\ ==> Unmatched [ in regex; marked by <-- HERE in m/]]]]][\ <-- HERE / at - line 2. +######## +# NAME [perl #123417] +use warnings 'regexp'; +qr/[\N{}]/; +qr/\N{}/; +no warnings 'regexp'; +qr/[\N{}]/; +qr/\N{}/; +no warnings 'deprecated'; +qr/[\N{}]/; +qr/\N{}/; +EXPECT +Unknown charname '' is deprecated at - line 2. +Ignoring zero length \N{} in character class in regex; marked by <-- HERE in m/[\N{} <-- HERE ]/ at - line 2. +Unknown charname '' is deprecated at - line 3. +Unknown charname '' is deprecated at - line 5. +Unknown charname '' is deprecated at - line 6. +######## +# NAME [perl #123417] +# OPTION fatal +use warnings 'regexp'; +no warnings 'experimental::re_strict'; +use re 'strict'; +qr/[\N{}]/; +EXPECT +Unknown charname '' is deprecated at - line 5. +Zero length \N{} in regex; marked by <-- HERE in m/[\N{} <-- HERE ]/ at - line 5. +######## +# NAME [perl #123417] +# OPTION fatal +use warnings 'regexp'; +no warnings 'experimental::re_strict'; +use re 'strict'; +qr/\N{}/; +EXPECT +Unknown charname '' is deprecated at - line 5. +Zero length \N{} in regex; marked by <-- HERE in m/\N{} <-- HERE / at - line 5. diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t index ab145eb..376272b 100644 --- a/t/re/pat_advanced.t +++ b/t/re/pat_advanced.t @@ -2434,6 +2434,7 @@ EOF like($string, qr/$string/i, "LATIN SMALL SHARP S matches itself under /id"); unlike($folded_string, qr/$string/i, "LATIN SMALL SHARP S doesn't match 'ss' under /di"); + no warnings 'deprecated'; like($folded_string, qr/\N{}$string/i, "\\N{} earlier than LATIN SMALL SHARP S transforms /di into /ui, matches 'ss'"); like($folded_string, qr/$string\N{}/i, "\\N{} after LATIN SMALL SHARP S transforms /di into /ui, matches 'ss'"); } diff --git a/t/re/re_tests b/t/re/re_tests index 25061e1..34ac94a 100644 --- a/t/re/re_tests +++ b/t/re/re_tests @@ -1954,7 +1954,7 @@ foo(*ACCEPT:foo) foo y $::REGMARK foo (foo(*ACCEPT:foo)) foo y $::REGMARK foo A(*FAIL:foo)[BC] A n $::REGERROR foo -\N(?#comment){SPACE} A c - Missing braces on \N{} +\N(?#comment){SPACE} A c - Missing braces on \\N{} ab(?#Comment){2}c abbc y $& abbc \p A A c - Character following \\p must be '{' or a single-character Unicode property name # [perl #126187 \P:A A c - Character following \\P must be '{' or a single-character Unicode property name diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t index f08c708..0fe4539 100644 --- a/t/re/reg_mesg.t +++ b/t/re/reg_mesg.t @@ -300,10 +300,6 @@ my @death_only_under_strict = ( => 'Non-hex character {#} m/\x{ABCDEFG{#}}/', 'm/[\x{ABCDEFG}]/' => 'Illegal hexadecimal digit \'G\' ignored', => 'Non-hex character {#} m/[\x{ABCDEFG{#}}]/', - 'm/[\N{}]/' => 'Ignoring zero length \\N{} in character class {#} m/[\\N{}{#}]/', - => 'Zero length \\N{} {#} m/[\\N{}{#}]/', - 'm/\N{}/' => "", - => 'Zero length \\N{} {#} m/\\N{}{#}/', "m'[\\y]\\x{100}'" => 'Unrecognized escape \y in character class passed through {#} m/[\y{#}]\x{100}/', => 'Unrecognized escape \y in character class {#} m/[\y{#}]\x{100}/', 'm/[a-\d]\x{100}/' => 'False [] range "a-\d" {#} m/[a-\d{#}]\x{100}/', @@ -716,6 +712,8 @@ for my $strict ("", "no warnings 'experimental::re_strict'; use re 'strict';") { $_ = "x"; + #use feature 'unicode_eval'; + #print STDERR __LINE__, ": ", "eval '$strict no warnings; $regex'", "\n"; eval "$strict no warnings; $regex"; } if (is($@, "", "$strict $regex did not die")) { diff --git a/t/re/regexp.t b/t/re/regexp.t index f27a027..8e98e55 100644 --- a/t/re/regexp.t +++ b/t/re/regexp.t @@ -406,7 +406,7 @@ EOFCODE # Probably we should annotate specific tests with which warnings # categories they're known to trigger, and hence should be # disabled just for that test - no warnings qw(uninitialized regexp); + no warnings qw(uninitialized regexp deprecated); eval $code; } chomp( my $err = $@ ); diff --git a/toke.c b/toke.c index fd359ed..c95f6d2 100644 --- a/toke.c +++ b/toke.c @@ -2518,8 +2518,11 @@ S_get_and_check_backslash_N_name(pTHX_ const char* s, const char* const e) PERL_ARGS_ASSERT_GET_AND_CHECK_BACKSLASH_N_NAME; - if (!SvCUR(res)) + if (!SvCUR(res)) { + Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), + "Unknown charname '' is deprecated"); return res; + } if (UTF && ! is_utf8_string_loc((U8 *) backslash_ptr, e - backslash_ptr, -- Perl5 Master Repository
