summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-10-19 10:35:04 -0600
committerKarl Williamson <khw@cpan.org>2014-10-21 09:26:51 -0600
commit4475d0d23c30e1ffbe123b0f5e3b800c0be35f4c (patch)
tree88804141159b5e2604bab47db3c456ce57f29ef2 /toke.c
parentde1631081e2407e5021257de0eb1de20ad1534ca (diff)
downloadperl-4475d0d23c30e1ffbe123b0f5e3b800c0be35f4c.tar.gz
Deprecate all length-1 non-graphic variable names
v5.20 deprecated all otherwise-legal control characters as length-1 variable names. This extends this to include all non-graphic characters. The practical effect of this occurs only when not under "use utf8", and affects just the C1 controls (code points 0x80 through 0xFF), NO-BREAK SPACE, and SOFT HYPHEN.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index 41f3ce9f64..51075e5711 100644
--- a/toke.c
+++ b/toke.c
@@ -8572,8 +8572,22 @@ S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni)
: 1)
&& VALID_LEN_ONE_IDENT(s, is_utf8))
{
- if ( isCNTRL_A((U8)*s) ) {
- deprecate("literal control characters in variable names");
+ /* Deprecate all non-graphic characters. Include SHY as a non-graphic,
+ * because often it has no graphic representation. (We can't get to
+ * here with SHY when 'is_utf8' is true, so no need to include a UTF-8
+ * test for it.) */
+ if ((is_utf8)
+ ? ! isGRAPH_utf8( (U8*) s)
+ : (! isGRAPH_L1( (U8) *s)
+ || UNLIKELY((U8) *(s) == LATIN1_TO_NATIVE(0xAD))))
+ {
+ /* Split messages for back compat */
+ if (isCNTRL_A( (U8) *s)) {
+ deprecate("literal control characters in variable names");
+ }
+ else {
+ deprecate("literal non-graphic characters in variable names");
+ }
}
if (is_utf8) {