summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-03-17 13:58:25 +0000
committerNicholas Clark <nick@ccl4.org>2010-05-27 10:30:01 +0100
commite52fc5395a9d11f134b6e4ecacde7782d1af6b26 (patch)
tree15f42a15788ecd48523c3dde2082681e64fe63ea
parentf9ef50a71935a8e93b4030c12dcd1206ccab71ab (diff)
downloadperl-e52fc5395a9d11f134b6e4ecacde7782d1af6b26.tar.gz
Encapsulate lookups in PL_{varies,simple} within macros REGNODE_{VARIES,SIMPLE}
This allows the implementation of the lookup mechanism to change.
-rw-r--r--regcomp.c8
-rw-r--r--regcomp.pl2
-rw-r--r--regnodes.h4
3 files changed, 10 insertions, 4 deletions
diff --git a/regcomp.c b/regcomp.c
index c8c47e9c5b..c290fbd301 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 0c63b94380..fdfa7e6d16 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 a501416f9a..c9ba1093aa 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