summaryrefslogtreecommitdiff
path: root/handy.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@khw-desktop.(none)>2010-02-19 23:53:36 -0700
committerSteve Hay <steve.m.hay@googlemail.com>2010-02-20 11:03:53 +0000
commitcb233ae346c666d88ee890fc837f4cd3195c1f0b (patch)
tree0d414ca0a66af489c1d4764b5aec0f2061aa6b72 /handy.h
parentc3c4140635dd08363a20c93a8c8b6d8e7464b891 (diff)
downloadperl-cb233ae346c666d88ee890fc837f4cd3195c1f0b.tar.gz
PATCH: deprecation warnings for unreasonable charnames
Prior to now just about anything has been legal for a character name in \N{...}. This means that legal code was broken by having \N{3,4} for example mean [^\n]{3,4}. Such code doesn't come from standard charnames, but from legal custom translators. This patch deprecates "unreasonable" names. handy.h is changed by the addition of macros that taken together define the names we deem reasonable, namely alpha beginning with alphanumerics and some punctuations as continuations. toke.c is changed to parse each name and to raise a warning if any problematic characters are found. Some tests and diagnostic documentation are also included.
Diffstat (limited to 'handy.h')
-rw-r--r--handy.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/handy.h b/handy.h
index 911deca5dc..d12972d529 100644
--- a/handy.h
+++ b/handy.h
@@ -462,6 +462,18 @@ US-ASCII (Basic Latin) range are viewed as not having any case.
#define isALNUM(c) (isALPHA(c) || isDIGIT(c) || (c) == '_')
#define isIDFIRST(c) (isALPHA(c) || (c) == '_')
#define isALPHA(c) (isUPPER(c) || isLOWER(c))
+/* ALPHAU includes Unicode semantics for latin1 characters. It has an extra
+ * >= AA test to speed up ASCII-only tests at the expense of the others */
+#define isALPHAU(c) (isALPHA(c) || (NATIVE_TO_UNI((U8) c) >= 0xAA \
+ && ((NATIVE_TO_UNI((U8) c) >= 0xC0 \
+ && NATIVE_TO_UNI((U8) c) != 0xD7 && NATIVE_TO_UNI((U8) c) != 0xF7) \
+ || NATIVE_TO_UNI((U8) c) == 0xAA \
+ || NATIVE_TO_UNI((U8) c) == 0xB5 \
+ || NATIVE_TO_UNI((U8) c) == 0xBA)))
+#define isALNUMU(c) (isDIGIT(c) || isALPHAU(c) || (c) == '_')
+
+/* continuation character for legal NAME in \N{NAME} */
+#define isCHARNAME_CONT(c) (isALNUMU(c) || (c) == ' ' || (c) == '-' || (c) == '(' || (c) == ')' || (c) == ':' || NATIVE_TO_UNI((U8) c) == 0xA0)
#define isSPACE(c) \
((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) =='\r' || (c) == '\f')
#define isPSXSPC(c) (isSPACE(c) || (c) == '\v')