From: Nicholas Clark Date: Wed, 17 Mar 2010 13:58:25 +0000 (+0000) Subject: Encapsulate lookups in PL_{varies,simple} within macros REGNODE_{VARIES,SIMPLE} X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e52fc5395a9d11f134b6e4ecacde7782d1af6b26;p=p5sagit%2Fp5-mst-13.2.git Encapsulate lookups in PL_{varies,simple} within macros REGNODE_{VARIES,SIMPLE} This allows the implementation of the lookup mechanism to change. --- diff --git a/regcomp.c b/regcomp.c index c8c47e9..c290fbd 100644 --- a/regcomp.c +++ b/regcomp.c @@ -3116,7 +3116,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, } flags &= ~SCF_DO_STCLASS; } - else if (strchr((const char*)PL_varies,OP(scan))) { + else if (REGNODE_VARIES(OP(scan))) { I32 mincount, maxcount, minnext, deltanext, fl = 0; I32 f = flags, pos_before = 0; regnode * const oscan = scan; @@ -3268,7 +3268,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, /* Skip open. */ nxt = regnext(nxt); - if (!strchr((const char*)PL_simple,OP(nxt)) + if (!REGNODE_SIMPLE(OP(nxt)) && !(PL_regkind[OP(nxt)] == EXACT && STR_LEN(nxt) == 1)) goto nogo; @@ -3527,7 +3527,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, data->longest = &(data->longest_float); } } - else if (strchr((const char*)PL_simple,OP(scan))) { + else if (REGNODE_SIMPLE(OP(scan))) { int value = 0; if (flags & SCF_DO_SUBSTR) { @@ -4604,7 +4604,7 @@ reStudy: ri->regstclass = trie_op; } #endif - else if (strchr((const char*)PL_simple,OP(first))) + else if (REGNODE_SIMPLE(OP(first))) ri->regstclass = first; else if (PL_regkind[OP(first)] == BOUND || PL_regkind[OP(first)] == NBOUND) diff --git a/regcomp.pl b/regcomp.pl index 0c63b94..fdfa7e6 100644 --- a/regcomp.pl +++ b/regcomp.pl @@ -91,6 +91,8 @@ sub process_flags { my $out_string = join ', ', @selected, 0; $out_string =~ s/(.{1,70},) /$1\n /g; return $comment . <<"EOP"; +#define REGNODE_\U$varname\E(node) strchr((const char *)PL_${varname}, (node)) + #ifndef DOINIT EXTCONST U8 PL_${varname}[]; #else diff --git a/regnodes.h b/regnodes.h index a501416..c9ba109 100644 --- a/regnodes.h +++ b/regnodes.h @@ -662,6 +662,8 @@ EXTCONST char * const PL_reg_extflags_name[] = { #endif /* DOINIT */ /* The following have no fixed length. U8 so we can do strchr() on it. */ +#define REGNODE_VARIES(node) strchr((const char *)PL_varies, (node)) + #ifndef DOINIT EXTCONST U8 PL_varies[]; #else @@ -674,6 +676,8 @@ EXTCONST U8 PL_varies[] = { /* The following always have a length of 1. U8 we can do strchr() on it. */ /* (Note that length 1 means "one character" under UTF8, not "one octet".) */ +#define REGNODE_SIMPLE(node) strchr((const char *)PL_simple, (node)) + #ifndef DOINIT EXTCONST U8 PL_simple[]; #else