toke.c: Fix EBCDIC bugs with single char variable names
authorKarl Williamson <public@khwilliamson.com>
Sat, 13 Apr 2013 19:16:00 +0000 (13:16 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 29 Aug 2013 15:56:07 +0000 (09:56 -0600)
Latin1 variable single character variable names should all be legal,
but the test was not for non-ASCII, it was for variant characters.  On
EBCDIC platforms, this isn't the same as non-ASCII.

The legal control character variable names are not the same as the C0
and DEL controls, but are \001 .. \037, minus those that traditionally
match \s on ASCII platforms, plus \c?.

toke.c

diff --git a/toke.c b/toke.c
index 37ed7f1..2764709 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -9344,10 +9344,17 @@ S_scan_ident(pTHX_ char *s, const char *send, char *dest, STRLEN destlen, I32 ck
           s++;
     }
 
-#define VALID_LEN_ONE_IDENT(d, u)     (isPUNCT_A((U8)(d))     \
-                                        || isCNTRL_A((U8)(d)) \
-                                        || isDIGIT_A((U8)(d)) \
-                                        || (!(u) && !UTF8_IS_INVARIANT((U8)(d))))
+/*  \c?, \c\, \c^, \c_, and \cA..\cZ minus the ones that have traditionally
+ *  been matched by \s on ASCII platforms, are the legal control char names
+ *  here, that is \c? plus 1-32 minus the \s ones. */
+#define VALID_LEN_ONE_IDENT(d, u) (isPUNCT_A((U8)(d))                       \
+                                   || isDIGIT_A((U8)(d))                    \
+                                   || (!(u) && !isASCII((U8)(d)))           \
+                                   || ((((U8)(d)) < 32)                     \
+                                       && (((((U8)(d)) >= 14)               \
+                                           || (((U8)(d)) <= 8 && (d) != 0) \
+                                           || (((U8)(d)) == 13))))          \
+                                   || (((U8)(d)) == toCTRL('?')))
     if (s < send
         && (isIDFIRST_lazy_if(s, is_utf8) || VALID_LEN_ONE_IDENT(*s, is_utf8)))
     {