summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-12-04 17:50:51 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-12-04 17:50:51 +0000
commit6d5c990f28c2a18264defef032a496e2e3dfb7cd (patch)
tree23cbcbd365bbc2e293a764976cdc9f1d9ec506af
parent3c6f95d1b67124c82147911f846eb1993443a39a (diff)
downloadperl-6d5c990f28c2a18264defef032a496e2e3dfb7cd.tar.gz
Better version of last patch, by Yves Orton.
Actually the regexp engine structure only needs one compilation function hook. p4raw-id: //depot/perl@29459
-rw-r--r--ext/re/re.xs6
-rw-r--r--ext/re/re_top.h1
-rw-r--r--regcomp.c15
-rw-r--r--regcomp.h18
-rw-r--r--regexp.h19
5 files changed, 26 insertions, 33 deletions
diff --git a/ext/re/re.xs b/ext/re/re.xs
index 284a4e93b3..2646a5208c 100644
--- a/ext/re/re.xs
+++ b/ext/re/re.xs
@@ -11,8 +11,7 @@
START_EXTERN_C
-extern regexp* my_regcomp (pTHX_ char* exp, char* xend, PMOP* pm);
-extern regexp* my_re_compile(pTHX_ char *exp, char *xend, PMOP *pm);
+extern regexp* my_re_compile (pTHX_ char* exp, char* xend, PMOP* pm);
extern I32 my_regexec (pTHX_ regexp* prog, char* stringarg, char* strend,
char* strbeg, I32 minend, SV* screamer,
void* data, U32 flags);
@@ -32,8 +31,7 @@ EXTERN_C const struct regexp_engine my_reg_engine;
END_EXTERN_C
const struct regexp_engine my_reg_engine = {
- my_regcomp,
- my_re_compile,
+ my_re_compile,
my_regexec,
my_re_intuit_start,
my_re_intuit_string,
diff --git a/ext/re/re_top.h b/ext/re/re_top.h
index 9f12979b6c..b4a3d6f39b 100644
--- a/ext/re/re_top.h
+++ b/ext/re/re_top.h
@@ -12,7 +12,6 @@
#define Perl_regdump my_regdump
#define Perl_regprop my_regprop
#define Perl_re_intuit_start my_re_intuit_start
-#define Perl_pregcomp my_regcomp
#define Perl_re_compile my_re_compile
#define Perl_regfree_internal my_regfree
#define Perl_re_intuit_string my_re_intuit_string
diff --git a/regcomp.c b/regcomp.c
index 7e77e77dbe..b7510a9196 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -3965,20 +3965,18 @@ Perl_reginitcolors(pTHX)
extern const struct regexp_engine my_reg_engine;
#define RE_ENGINE_PTR &my_reg_engine
#endif
-
+
+#ifndef PERL_IN_XSUB_RE
regexp *
Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
{
dVAR;
- GET_RE_DEBUG_FLAGS_DECL;
- DEBUG_r(if (!PL_colorset) reginitcolors());
-#ifndef PERL_IN_XSUB_RE
- {
+ HV * const table = GvHV(PL_hintgv);
/* Dispatch a request to compile a regexp to correct
regexp engine. */
- HV * const table = GvHV(PL_hintgv);
if (table) {
SV **ptr= hv_fetchs(table, "regcomp", FALSE);
+ GET_RE_DEBUG_FLAGS_DECL;
if (ptr && SvIOK(*ptr) && SvIV(*ptr)) {
const regexp_engine *eng=INT2PTR(regexp_engine*,SvIV(*ptr));
DEBUG_COMPILE_r({
@@ -3988,10 +3986,9 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
return CALLREGCOMP_ENG(eng, exp, xend, pm);
}
}
- }
-#endif
return Perl_re_compile(aTHX_ exp, xend, pm);
}
+#endif
regexp *
Perl_re_compile(pTHX_ char *exp, char *xend, PMOP *pm)
@@ -4013,6 +4010,8 @@ Perl_re_compile(pTHX_ char *exp, char *xend, PMOP *pm)
RExC_state_t copyRExC_state;
#endif
GET_RE_DEBUG_FLAGS_DECL;
+ DEBUG_r(if (!PL_colorset) reginitcolors());
+
if (exp == NULL)
FAIL("NULL regexp argument");
diff --git a/regcomp.h b/regcomp.h
index e1b17e57bb..1075080d95 100644
--- a/regcomp.h
+++ b/regcomp.h
@@ -92,6 +92,23 @@ typedef OP OP_4tree; /* Will be redefined later. */
* special test to reverse the sign of BACK pointers since the offset is
* stored negative.]
*/
+typedef struct regexp_internal {
+ regexp_paren_ofs *swap; /* Swap copy of *startp / *endp */
+ U32 *offsets; /* offset annotations 20001228 MJD
+ data about mapping the program to the
+ string*/
+ regnode *regstclass; /* Optional startclass as identified or constructed
+ by the optimiser */
+ struct reg_data *data; /* Additional miscellaneous data used by the program.
+ Used to make it easier to clone and free arbitrary
+ data that the regops need. Often the ARG field of
+ a regop is an index into this structure */
+ regnode program[1]; /* Unwarranted chumminess with compiler. */
+} regexp_internal;
+
+#define RXi_SET(x,y) (x)->pprivate = (void*)(y)
+#define RXi_GET(x) ((regexp_internal *)((x)->pprivate))
+#define RXi_GET_DECL(r,ri) regexp_internal *ri = RXi_GET(r)
struct regnode_string {
U8 str_len;
@@ -404,7 +421,6 @@ EXTCONST U8 PL_simple[] = {
EXTCONST regexp_engine PL_core_reg_engine;
#else /* DOINIT */
EXTCONST regexp_engine PL_core_reg_engine = {
- Perl_pregcomp,
Perl_re_compile,
Perl_regexec_flags,
Perl_re_intuit_start,
diff --git a/regexp.h b/regexp.h
index abc744c38d..85af91e1bb 100644
--- a/regexp.h
+++ b/regexp.h
@@ -84,24 +84,6 @@ typedef struct regexp {
} regexp;
-typedef struct regexp_internal {
- regexp_paren_ofs *swap; /* Swap copy of *startp / *endp */
- U32 *offsets; /* offset annotations 20001228 MJD
- data about mapping the program to the
- string*/
- regnode *regstclass; /* Optional startclass as identified or constructed
- by the optimiser */
- struct reg_data *data; /* Additional miscellaneous data used by the program.
- Used to make it easier to clone and free arbitrary
- data that the regops need. Often the ARG field of
- a regop is an index into this structure */
- regnode program[1]; /* Unwarranted chumminess with compiler. */
-} regexp_internal;
-
-#define RXi_SET(x,y) (x)->pprivate = (void*)(y)
-#define RXi_GET(x) ((regexp_internal *)((x)->pprivate))
-#define RXi_GET_DECL(r,ri) regexp_internal *ri = RXi_GET(r)
-
typedef struct re_scream_pos_data_s
{
char **scream_olds; /* match pos */
@@ -110,7 +92,6 @@ typedef struct re_scream_pos_data_s
typedef struct regexp_engine {
regexp* (*comp) (pTHX_ char* exp, char* xend, PMOP* pm);
- regexp* (*compile) (pTHX_ char *exp, char *xend, PMOP *pm);
I32 (*exec) (pTHX_ regexp* prog, char* stringarg, char* strend,
char* strbeg, I32 minend, SV* screamer,
void* data, U32 flags);