X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/36897d6498ecb95fe6bf65c28b19473476e54b34..2402c6dd1926cbfcbf0d1814ec041034fc265c4b:/lib/_charnames.pm diff --git a/lib/_charnames.pm b/lib/_charnames.pm index 4806b8f..92286c2 100644 --- a/lib/_charnames.pm +++ b/lib/_charnames.pm @@ -144,6 +144,7 @@ sub carp 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 @@ -185,19 +186,30 @@ sub alias (@) # Set up a single alias . "'"; } else { - $^H{charnames_name_aliases}{$name} = $value; - - if (warnings::enabled('deprecated')) { if ($name =~ / ( .* \s ) ( \s* ) $ /x) { - carp "Trailing white-space in a charnames alias definition is deprecated; marked by <-- HERE in '$1 <-- HERE " . $2 . "'"; + push @errors, "charnames alias definitions may not contain " + . "trailing white-space; marked by <-- HERE in " + . "'$1 <-- HERE " . $2 . "'"; + next; } # Use '+' instead of '*' in this regex, because any trailing - # blanks have already been warned about. + # blanks have already been found if ($name =~ / ( .*? \s{2} ) ( .+ ) /x) { - carp "A sequence of multiple spaces in a charnames alias definition is deprecated; marked by <-- HERE in '$1 <-- HERE " . $2 . "'"; + push @errors, "charnames alias definitions may not contain a " + . "sequence of multiple spaces; marked by <-- HERE " + . "in '$1 <-- HERE " . $2 . "'"; + next; + } + + $^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 . "'"; } - } } } }