diff options
author | Karl Williamson <public@khwilliamson.com> | 2013-01-04 12:34:34 -0700 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2013-01-04 13:08:22 -0700 |
commit | bd299e299a2e44d6d10ecebc24b6b6267e7db073 (patch) | |
tree | bdb683bab334eb344d5ccbe9f54c2b781cdd97b1 /lib | |
parent | 5198c1376b087a9fe884633b2b73800365a9b43a (diff) | |
download | perl-bd299e299a2e44d6d10ecebc24b6b6267e7db073.tar.gz |
charnames: Deprecate character names with spacing issues
A user-defined character name with trailing or multiple spaces in a row
is likely a typo, and hence likely won't match what the other uses of
it. These names also won't work if we extend :loose to these. This
now generates a warning.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_charnames.pm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/_charnames.pm b/lib/_charnames.pm index 5b80f96f98..9888301f33 100644 --- a/lib/_charnames.pm +++ b/lib/_charnames.pm @@ -173,10 +173,23 @@ sub alias (@) # Set up a single alias \p{_Perl_Charname_Begin} \p{_Perl_Charname_Continue}* $ /x) { + push @errors, $name; } 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 . "'"; + } + + # Use '+' instead of '*' in this regex, because any trailing + # blanks have already been warned about. + 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 . "'"; + } + } } } } |