summaryrefslogtreecommitdiff
path: root/lib/_charnames.pm
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-01-04 12:34:34 -0700
committerKarl Williamson <public@khwilliamson.com>2013-01-04 13:08:22 -0700
commitbd299e299a2e44d6d10ecebc24b6b6267e7db073 (patch)
treebdb683bab334eb344d5ccbe9f54c2b781cdd97b1 /lib/_charnames.pm
parent5198c1376b087a9fe884633b2b73800365a9b43a (diff)
downloadperl-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/_charnames.pm')
-rw-r--r--lib/_charnames.pm13
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 . "'";
+ }
+ }
}
}
}