From 95f34b6fc646073944e61496c615de11b8bca7da Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 3 Feb 2014 11:52:24 -0700 Subject: [PATCH] Fix [[:blank:]] handling when no isblank() on platform isblank() is a C99 construct, Perl tries to handle the use of this on C89 platforms by using the standard hard-coded definition. However, this code was not updated to account for UTF-8 locales when handling for those was recently added (31f05a37c), since in a UTF-8 locale the no-break space is also considered to be a blank. This commit fixes that. Previously regcomp.c generated the hard-coded definitions when there was no isblank(), using #ifdef'd code. That special handling was removed, and [:blank:] is always treated just like any other POSIX class. The specialness of it is hidden entirely in handy.h. This simplifies the regcomp.c code slightly. I considered removing the special handling for isascii(), also a C99 construct, in the name of simplicity over the slight speed that would be lost. But the special handling is only a single line in two places, so I left it in. --- handy.h | 4 ++-- regcomp.c | 21 --------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/handy.h b/handy.h index 8815084..d695cf5 100644 --- a/handy.h +++ b/handy.h @@ -1325,8 +1325,8 @@ EXTCONST U32 PL_charclass[]; #if defined(HAS_ISBLANK) && ! defined(USE_NEXT_CTYPE) # define isBLANK_LC(c) _generic_LC(c, _CC_BLANK, isblank) -#else -# define isBLANK_LC(c) isBLANK(c) +#else /* Unlike isASCII, varies if in a UTF-8 locale */ +# define isBLANK_LC(c) (IN_UTF8_CTYPE_LOCALE) ? isBLANK_L1(c) : isBLANK(c) #endif #ifdef USE_NEXT_CTYPE /* NeXT computers */ diff --git a/regcomp.c b/regcomp.c index 8246497..92e3ef4 100644 --- a/regcomp.c +++ b/regcomp.c @@ -13682,9 +13682,6 @@ parseit: #ifndef HAS_ISASCII && classnum != _CC_ASCII #endif -#ifndef HAS_ISBLANK - && classnum != _CC_BLANK -#endif ) { /* See if it already matches the complement of this POSIX @@ -13768,16 +13765,6 @@ parseit: ? &posixes : &nposixes; SV** source_ptr = &PL_XPosix_ptrs[classnum]; -#ifndef HAS_ISBLANK - /* If the platform doesn't have isblank(), we handle locale - * with the hardcoded ASII values. */ - if (LOC && classnum == _CC_BLANK) { - _invlist_subtract(*source_ptr, - PL_UpperLatin1, - source_ptr); - } -#endif - _invlist_union_maybe_complement_2nd( *posixes_ptr, *source_ptr, @@ -14145,14 +14132,6 @@ parseit: if (op > POSIXA) { /* /aa is same as /a */ op = POSIXA; } -#ifndef HAS_ISBLANK - if (op == POSIXL - && (namedclass == ANYOF_BLANK - || namedclass == ANYOF_NBLANK)) - { - op = POSIXA; - } -#endif join_posix: /* The odd numbered ones are the complements of the -- 2.7.4