sub alias (@) # Set up a single alias
{
my @errors;
+ my $nbsp = chr utf8::unicode_to_native(0xA0);
my $alias = ref $_[0] ? $_[0] : { @_ };
foreach my $name (sort keys %$alias) { # Sort only because it helps having
}
$^H{charnames_name_aliases}{$name} = $value;
+ if (warnings::enabled('deprecated')
+ && $name =~ / ( .* $nbsp ) ( .* ) $ /x)
+ {
+ carp "NO-BREAK SPACE in a charnames alias definition is "
+ . "deprecated; marked by <-- HERE in '$1 <-- HERE "
+ . $2 . "'";
+ }
}
}
}
contain any combination of word (C<\w>) characters, SPACE (U+0020),
HYPHEN-MINUS (U+002D), LEFT PARENTHESIS (U+0028), RIGHT PARENTHESIS (U+0029),
and NO-BREAK SPACE (U+00A0). These last three should never have been allowed
-in names, and are retained for backwards compatibility only; they may be
+in names, and are retained for backwards compatibility only; NO-BREAK SPACE IS
+currently deprecated and scheduled for removal in Perl v5.26; the other two
+may also be
deprecated and removed in future releases of Perl, so don't use them for new
names. (More precisely, the first character of a name you specify must be
something that matches all of C<\p{ID_Start}>, C<\p{Alphabetic}>, and
XXX Any deprecated features, syntax, modules etc. should be listed here.
+=head2 Using a NO-BREAK space in a character alias for C<\N{...}> is now
+deprecated
+
+This non-graphic character is essentially indistinguishable from a
+regular space, and so should not be allowed. See
+L<charnames/CUSTOM ALIASES>.
+
=head2 Module removals
XXX Remove this section if inapplicable.
will be another way to do what you want that is, if not secure, at least
securable. See L<perlsec>.
+=item NO-BREAK SPACE in a charnames alias definition is deprecated
+
+(D deprecated) You defined a character name which contained a no-break
+space character. Change it to a regular space. Usually these names are
+defined in the C<:alias> import argument to C<use charnames>, but they
+could be defined by a translator installed into C<$^H{charnames}>. See
+L<charnames/CUSTOM ALIASES>.
+
=item No code specified for -%c
(F) Perl's B<-e> and B<-E> command-line options require an argument. If
BOM first
BOM tail
+NBSP native
+NBSP string
+
DEL native
CR native
LF native
charnames alias definitions may not contain trailing white-space; marked by <-- HERE in 'TRAILING SPACE <-- HERE '
Invalid character in charnames alias definition; marked by <-- HERE in '٤<-- HERE 転車に乗る人'
Invalid character in charnames alias definition; marked by <-- HERE in '自転車・<-- HERE に乗る人' at - line \d+
+########
+# NAME Using NBSP in :alias names is deprectated
+use utf8;
+use open qw( :utf8 :std );
+use charnames ":alias" => { "NBSP SEPARATED SPACE" => "BLACK SMILING FACE" };
+print "ok\n" if "\N{NBSP SEPARATED SPACE}" eq "\x{263B}";
+print "ok\n" if "\N{NBSP SEPARATED SPACE}" eq "\x{263B}";
+no warnings 'deprecated';
+print "ok\n" if "\N{NBSP SEPARATED SPACE}" eq "\x{263B}";
+EXPECT
+OPTIONS regex
+NO-BREAK SPACE in a charnames alias definition is deprecated; marked by <-- HERE in 'NBSP SEPARATED <-- HERE SPACE' at - line \d+.
+ok
+ok
+ok
}
undef $w;
+ my $NBSP_Latin1 = "NBSP"
+ . latin1_to_native("\xA0")
+ . "SEPARATED"
+ . latin1_to_native("\xA0")
+ . "SPACE";
+ my $NBSP_utf8 = $NBSP_Latin1;
+ utf8::upgrade($NBSP_utf8);
+ eval qq[is("\\N{$NBSP_Latin1}", "$NBSP_Latin1", "An NBSP in character name works")];
+ like ($w, qr/NO-BREAK SPACE in a charnames alias definition is deprecated/, "... but returns a deprecation warning");
+ undef $w;
+ {
+ use feature 'unicode_eval';
+ eval qq[use utf8; is("\\N{$NBSP_utf8}", "$NBSP_utf8", "Same under 'use utf8': they work")];
+ like ($w, qr/NO-BREAK SPACE in a charnames alias definition is deprecated/, "... but return a deprecation warning");
+ }
+ {
+ # disable lexical warnings
+ BEGIN { ${^WARNING_BITS} = undef; $^W = 0 }
+ undef $w;
+ () = eval qq["\\N{$NBSP_Latin1}"];
+ like ($w, qr/NO-BREAK SPACE in a charnames alias definition is deprecated/, "And returns a deprecation warning outside of lexical warnings");
+ undef $w;
+ use feature 'unicode_eval';
+ eval qq[use utf8; () = "\\N{$NBSP_utf8}"];
+ like ($w, qr/NO-BREAK SPACE in a charnames alias definition is deprecated/, "... same under utf8");
+ }
+ {
+ no warnings 'deprecated';
+ undef $w;
+ eval qq["\\N{$NBSP_Latin1}"];
+ ok (! defined $w, "... and no warning if warnings are off");
+ use feature 'unicode_eval';
+ eval qq[use utf8; "\\N{$NBSP_utf8}"];
+ ok (! defined $w, "... same under 'use utf8'");
+ }
+ {
+ use warnings FATAL=>'deprecated';
+ () = eval qq["\\N{$NBSP_Latin1}"];
+ like ($@, qr/NO-BREAK SPACE in a charnames alias definition is deprecated/, "... the warning can be fatal");
+ use feature 'unicode_eval';
+ eval qq[use utf8; () = "\\N{$NBSP_utf8}"];
+ like ($@, qr/NO-BREAK SPACE in a charnames alias definition is deprecated/, "... same under utf8");
+ }
+
{
BEGIN { no strict; *CnameTest:: = *{"_charnames\0A::" } }
package CnameTest { sub translator { pop } }
if (*s == ' ' && *(s-1) == ' ') {
goto multi_spaces;
}
+ if ((U8) *s == NBSP_NATIVE && ckWARN_d(WARN_DEPRECATED)) {
+ Perl_warner(aTHX_ packWARN(WARN_DEPRECATED),
+ "NO-BREAK SPACE in a charnames "
+ "alias definition is deprecated");
+ }
s++;
}
}
{
goto bad_charname;
}
+ if (*s == *NBSP_UTF8
+ && *(s+1) == *(NBSP_UTF8+1)
+ && ckWARN_d(WARN_DEPRECATED))
+ {
+ Perl_warner(aTHX_ packWARN(WARN_DEPRECATED),
+ "NO-BREAK SPACE in a charnames "
+ "alias definition is deprecated");
+ }
s += 2;
}
else {
#define BOM_UTF8_FIRST_BYTE 0xEF /* U+FEFF */
#define BOM_UTF8_TAIL "\xBB\xBF" /* U+FEFF */
+#define NBSP_NATIVE 0xA0 /* U+00A0 */
+#define NBSP_UTF8 "\xC2\xA0" /* U+00A0 */
+
#define DEL_NATIVE 0x7F /* U+007F */
#define CR_NATIVE 0x0D /* U+000D */
#define LF_NATIVE 0x0A /* U+000A */