From 4d7cd48281fd4dc117b56d5a263a4dc8987b9b11 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Thu, 25 Oct 2012 20:12:04 -0600 Subject: [PATCH] Make \N{alias} deprecations fatal. Since v5.12, using some non-name like characters, like commas, have generated a deprecation warning. The required 2 releases have been made, and they are now being made fatal. --- lib/charnames.pm | 10 +++------- pod/perldelta.pod | 11 +++++++++++ pod/perldiag.pod | 13 +++++-------- t/re/pat_advanced.t | 9 +++------ toke.c | 10 +++++----- 5 files changed, 27 insertions(+), 26 deletions(-) diff --git a/lib/charnames.pm b/lib/charnames.pm index 25c087d..0786690 100644 --- a/lib/charnames.pm +++ b/lib/charnames.pm @@ -270,13 +270,9 @@ conventions. The aliases override any standard definitions, so, if you're twisted enough, you can change C<"\N{LATIN CAPITAL LETTER A}"> to mean C<"B">, etc. -Note that an alias should not be something that is a legal curly -brace-enclosed quantifier (see L). For example -C<\N{123}> means to match 123 non-newline characters, and is not treated as a -charnames alias. Aliases are discouraged from beginning with anything -other than an alphabetic character and from containing anything other -than alphanumerics, spaces, dashes, parentheses, and underscores. -Currently they must be Latin1. +Aliases may not begin with anything other than an alphabetic character nor +contain anything other than alphanumerics, spaces, dashes, parentheses, and +underscores. Currently they must be Latin1. An alias can map to either an official Unicode character name (not a loose matched name) or to a diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 0af6b40..26d808f 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -54,6 +54,17 @@ behaviors, and since the REPLACEMENT CHARACTER has no use other than as a stand-in for some unknown character, any code that has this problem is buggy. +=head2 Formerly deprecated characters in C<\N{}> character name aliases are now errors. + +Since v5.12.0, it has been deprecated to use certain characters in +user-defined C<\N{...}> character names. These now cause a syntax +error. For example, it is now an error to begin a name with a digit, +such as in + + my $undraftable = "\N{4F}"; # Syntax error! + +or to have commas anywhere in the name. See L + =head1 Deprecations XXX Any deprecated features, syntax, modules etc. should be listed here. In diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 3c3a48e..5cac1d1 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1636,14 +1636,6 @@ there are neither package declarations nor a C<$VERSION>. long for Perl to handle. You have to be seriously twisted to write code that triggers this error. -=item Deprecated character in \N{...}; marked by <-- HERE in \N{%s<-- HERE %s - -(D deprecated) Just about anything is legal for the C<...> in C<\N{...}>. -But starting in 5.12, non-reasonable ones that don't look like names -are deprecated. A reasonable name begins with an alphabetic character -and continues with any combination of alphanumerics, dashes, spaces, -parentheses or colons. - =item Deprecated use of my() in false conditional (D deprecated) You used a declaration similar to C. There @@ -2368,6 +2360,11 @@ by Perl or by a user-supplied handler. See L. (F) The indicated attributes for a subroutine or variable were not recognized by Perl or by a user-supplied handler. See L. +=item Invalid character in \N{...}; marked by <-- HERE in \N{%s} + +(F) Only certain characters are valid for character names. The +indicated one isn't. See L. + =item Invalid conversion in %s: "%s" (W printf) Perl does not understand the given format conversion. See diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t index 9502928..538c3ef 100644 --- a/t/re/pat_advanced.t +++ b/t/re/pat_advanced.t @@ -1017,16 +1017,13 @@ sub run_tests { eval q [ok "\N{TOO-LONG-STR}" =~ /^\N{TOO-LONG-STR}$/, 'Verify that what once was too long a string works']; eval 'q(syntax error) =~ /\N{MALFORMED}/'; ok $@ && $@ =~ /Malformed/, 'Verify that malformed utf8 gives an error'; - undef $w; eval 'q() =~ /\N{4F}/'; - ok $w && $w =~ /Deprecated/, 'Verify that leading digit in name gives warning'; - undef $w; + ok $@ && $@ =~ /Invalid character/, 'Verify that leading digit in name gives error'; eval 'q() =~ /\N{COM,MA}/'; - ok $w && $w =~ /Deprecated/, 'Verify that comma in name gives warning'; - undef $w; + ok $@ && $@ =~ /Invalid character/, 'Verify that comma in name gives error'; my $name = "A\x{D7}O"; eval "q(W) =~ /\\N{$name}/"; - ok $w && $w =~ /Deprecated/, 'Verify that latin1 symbol in name gives warning'; + ok $@ && $@ =~ /Invalid character/, 'Verify that latin1 symbol in name gives error'; undef $w; $name = "A\x{D1}O"; eval "q(W) =~ /\\N{$name}/"; diff --git a/toke.c b/toke.c index f155107..b3c3767 100644 --- a/toke.c +++ b/toke.c @@ -2663,8 +2663,7 @@ S_get_and_check_backslash_N_name(pTHX_ const char* s, const char* const e) return NULL; } - /* Deprecate non-approved name syntax */ - if (ckWARN_d(WARN_DEPRECATED)) { + { bool problematic = FALSE; const char* i = s; @@ -2715,9 +2714,10 @@ S_get_and_check_backslash_N_name(pTHX_ const char* s, const char* const e) /* The e-i passed to the final %.*s makes sure that should the * trailing NUL be missing that this print won't run off the end of * the string */ - Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), - "Deprecated character in \\N{...}; marked by <-- HERE in \\N{%.*s<-- HERE %.*s", - (int)(i - s + 1), s, (int)(e - i), i + 1); + yyerror(Perl_form(aTHX_ + "Invalid character in \\N{...}; marked by <-- HERE in \\N{%.*s<-- HERE %.*s", + (int)(i - s + 1), s, (int)(e - i), i + 1)); + return NULL; } } -- 1.8.3.1