From a35d759aff667e2ddcde81fae0f6dbaecf27e7b1 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 19 Nov 2012 13:00:47 -0700 Subject: [PATCH] Refactor is_CNTRL_utf8(), is_utf8_cntrl() All controls will always be in the Latin1 range by Unicode's stability policy. This means that we don't have to call is_utf8_cntrl() when the input to the is_CNTRL_utf8() macro is above Latin1; we can just fail. And that means that Perl_is_utf8_cntrl() can just use the macro. --- handy.h | 2 +- utf8.c | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/handy.h b/handy.h index 0f50d8b..613129e 100644 --- a/handy.h +++ b/handy.h @@ -1008,7 +1008,7 @@ EXTCONST U32 PL_charclass[]; /* Because ASCII is invariant under utf8, the non-utf8 macro works */ #define isASCII_utf8(p) isASCII(*p) -#define isCNTRL_utf8(p) _generic_utf8(_CC_CNTRL, is_utf8_cntrl, p) +#define isCNTRL_utf8(p) _generic_utf8_utf8(_CC_CNTRL, p, 0) #define isGRAPH_utf8(p) _generic_utf8(_CC_GRAPH, is_utf8_graph, p) #define isPRINT_utf8(p) _generic_utf8(_CC_PRINT, is_utf8_print, p) #define isPUNCT_utf8(p) _generic_utf8(_CC_PUNCT, is_utf8_punct, p) diff --git a/utf8.c b/utf8.c index 76d0331..cc38b0f 100644 --- a/utf8.c +++ b/utf8.c @@ -2147,15 +2147,7 @@ Perl_is_utf8_cntrl(pTHX_ const U8 *p) PERL_ARGS_ASSERT_IS_UTF8_CNTRL; - if (isASCII(*p)) { - return isCNTRL_A(*p); - } - - /* All controls are in Latin1 */ - if (! UTF8_IS_DOWNGRADEABLE_START(*p)) { - return 0; - } - return isCNTRL_L1(TWO_BYTE_UTF8_TO_UNI(*p, *(p+1))); + return isCNTRL_utf8(p); } bool -- 2.7.4