-#define GET_SELF_FROM_PPRIVATE(pprivate) \
- re__engine__Plugin self; \
- SELF_FROM_PPRIVATE(self,pprivate);
+#define GET_SELF_FROM_PPRIVATE(pprivate) \
+ re__engine__Plugin self; \
+ SELF_FROM_PPRIVATE(self,pprivate);
-#define SELF_FROM_PPRIVATE(self, pprivate) \
- if (sv_isobject(pprivate)) { \
- SV * ref = SvRV((SV*)pprivate); \
- IV tmp = SvIV((SV*)ref); \
- self = INT2PTR(re__engine__Plugin,tmp); \
- } else { \
- Perl_croak(aTHX_ "Not an object"); \
- }
+#define SELF_FROM_PPRIVATE(self, pprivate) \
+ if (sv_isobject(pprivate)) { \
+ SV *ref = SvRV((SV *) pprivate); \
+ IV tmp = SvIV((SV *) ref); \
+ self = INT2PTR(re__engine__Plugin, tmp); \
+ } else { \
+ Perl_croak(aTHX_ "Not an object"); \
+ }
#if XSH_HAS_PERL(5, 19, 4)
# define REP_ENG_EXEC_MINEND_TYPE SSize_t
#if XSH_HAS_PERL(5, 19, 4)
# define REP_ENG_EXEC_MINEND_TYPE SSize_t
const I32, SV const * const);
EXTERN_C I32 Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const,
const SV * const, const I32);
const I32, SV const * const);
EXTERN_C I32 Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const,
const SV * const, const I32);
-EXTERN_C SV * Plugin_named_buff (pTHX_ REGEXP * const, SV * const,
- SV * const, const U32);
-EXTERN_C SV * Plugin_named_buff_iter (pTHX_ REGEXP * const, const SV * const,
- const U32);
+EXTERN_C SV * Plugin_named_buff(pTHX_ REGEXP * const, SV * const,
+ SV * const, const U32);
+EXTERN_C SV * Plugin_named_buff_iter(pTHX_ REGEXP * const, const SV * const,
+ const U32);
EXTERN_C SV * Plugin_package(pTHX_ REGEXP * const);
#ifdef USE_ITHREADS
EXTERN_C void * Plugin_dupe(pTHX_ REGEXP * const, CLONE_PARAMS *);
EXTERN_C SV * Plugin_package(pTHX_ REGEXP * const);
#ifdef USE_ITHREADS
EXTERN_C void * Plugin_dupe(pTHX_ REGEXP * const, CLONE_PARAMS *);
- Plugin_comp,
- Plugin_exec,
- Plugin_intuit,
- Plugin_checkstr,
- Plugin_free,
- Plugin_numbered_buff_FETCH,
- Plugin_numbered_buff_STORE,
- Plugin_numbered_buff_LENGTH,
- Plugin_named_buff,
- Plugin_named_buff_iter,
- Plugin_package
+ Plugin_comp,
+ Plugin_exec,
+ Plugin_intuit,
+ Plugin_checkstr,
+ Plugin_free,
+ Plugin_numbered_buff_FETCH,
+ Plugin_numbered_buff_STORE,
+ Plugin_numbered_buff_LENGTH,
+ Plugin_named_buff,
+ Plugin_named_buff_iter,
+ Plugin_package
- /* Pointer back to the containing regexp struct so that accessors
- * can modify nparens, gofs etc. */
- struct regexp * rx;
+ /* Pointer back to the containing regexp struct so that accessors
+ * can modify nparens, gofs etc. */
+ struct regexp *rx;
- /* ->num_captures */
- SV * cb_num_capture_buff_FETCH;
- SV * cb_num_capture_buff_STORE;
- SV * cb_num_capture_buff_LENGTH;
+ /* ->num_captures */
+ SV *cb_num_capture_buff_FETCH;
+ SV *cb_num_capture_buff_STORE;
+ SV *cb_num_capture_buff_LENGTH;
} *re__engine__Plugin;
#if XSH_HAS_PERL(5, 11, 0)
# define rxREGEXP(RX) (SvANY(RX))
} *re__engine__Plugin;
#if XSH_HAS_PERL(5, 11, 0)
# define rxREGEXP(RX) (SvANY(RX))
#else
# define rxREGEXP(RX) (RX)
# define newREGEXP(RX) (Newxz((RX), 1, struct regexp))
#else
# define rxREGEXP(RX) (RX)
# define newREGEXP(RX) (Newxz((RX), 1, struct regexp))
- h = rep_hint();
- if (!h) /* This looks like a pragma leak. Apply the default behaviour */
- return re_compile(pattern, flags);
+ h = rep_hint();
+ if (!h) /* This looks like a pragma leak. Apply the default behaviour */
+ return re_compile(pattern, flags);
- /* exp/xend version of the pattern & length */
- pbuf = SvPV((SV*)pattern, plen);
+ /* exp/xend version of the pattern & length */
+ pbuf = SvPV((SV *) pattern, plen);
- /* Our blessed object */
- obj = newSV(0);
- SvREFCNT_inc_simple_void_NN(obj);
- Newxz(re, 1, struct replug);
- sv_setref_pv(obj, "re::engine::Plugin", (void*)re);
+ /* Our blessed object */
+ obj = newSV(0);
+ SvREFCNT_inc_simple_void_NN(obj);
+ Newxz(re, 1, struct replug);
+ sv_setref_pv(obj, "re::engine::Plugin", (void *) re);
- re->rx = rx; /* Make the rx accessible from self->rx */
- rx->intflags = flags; /* Flags for internal use */
- rx->extflags = flags; /* Flags for perl to use */
- rx->engine = RE_ENGINE_PLUGIN; /* Compile to use this engine */
+ re->rx = rx; /* Make the rx accessible from self->rx */
+ rx->intflags = flags; /* Flags for internal use */
+ rx->extflags = flags; /* Flags for perl to use */
+ rx->engine = RE_ENGINE_PLUGIN; /* Compile to use this engine */
- rx->refcnt = 1; /* Refcount so we won't be destroyed */
-
- /* Precompiled pattern for pp_regcomp to use */
- rx->prelen = plen;
- rx->precomp = savepvn(pbuf, rx->prelen);
-
- /* Set up qr// stringification to be equivalent to the supplied
- * pattern, this should be done via overload eventually.
- */
- rx->wraplen = rx->prelen;
- Newx(rx->wrapped, rx->wraplen, char);
- Copy(rx->precomp, rx->wrapped, rx->wraplen, char);
+ rx->refcnt = 1; /* Refcount so we won't be destroyed */
+
+ /* Precompiled pattern for pp_regcomp to use */
+ rx->prelen = plen;
+ rx->precomp = savepvn(pbuf, rx->prelen);
+
+ /* Set up qr// stringification to be equivalent to the supplied
+ * pattern, this should be done via overload eventually.
+ */
+ rx->wraplen = rx->prelen;
+ Newx(rx->wrapped, rx->wraplen, char);
+ Copy(rx->precomp, rx->wrapped, rx->wraplen, char);
- /* Store the pattern for ->pattern */
- re->pattern = (SV*)pattern;
- SvREFCNT_inc_simple_void(re->pattern);
+ /* Store the pattern for ->pattern */
+ re->pattern = (SV *) pattern;
+ SvREFCNT_inc_simple_void(re->pattern);
- /* If there's an exec callback, store it into the private object so
- * that it will be the one to be called, even if the engine changes
- * in between */
- if (h->exec) {
- re->cb_exec = h->exec;
- SvREFCNT_inc_simple_void_NN(h->exec);
- }
+ /* If there's an exec callback, store it into the private object so
+ * that it will be the one to be called, even if the engine changes
+ * in between */
+ if (h->exec) {
+ re->cb_exec = h->exec;
+ SvREFCNT_inc_simple_void_NN(h->exec);
+ }
- re->cb_num_capture_buff_FETCH = NULL;
- re->cb_num_capture_buff_STORE = NULL;
- re->cb_num_capture_buff_LENGTH = NULL;
+ re->cb_num_capture_buff_FETCH = NULL;
+ re->cb_num_capture_buff_STORE = NULL;
+ re->cb_num_capture_buff_LENGTH = NULL;
- /* Call our callback function if one was defined, if not we've
- * already set up all the stuff we're going to to need for
- * subsequent exec and other calls */
- if (h->comp) {
- ENTER;
- SAVETMPS;
+ /* Call our callback function if one was defined, if not we've
+ * already set up all the stuff we're going to to need for
+ * subsequent exec and other calls */
+ if (h->comp) {
+ ENTER;
+ SAVETMPS;
- /* If any of the comp-time accessors were called we'll have to
- * update the regexp struct with the new info.
- */
+ /* If any of the comp-time accessors were called we'll have to
+ * update the regexp struct with the new info.
+ */
+ Newxz(rx->offs, rx->nparens + 1, regexp_paren_pair);
char *strbeg, REP_ENG_EXEC_MINEND_TYPE minend,
SV *sv, void *data, U32 flags)
{
char *strbeg, REP_ENG_EXEC_MINEND_TYPE minend,
SV *sv, void *data, U32 flags)
{
- /* Store the current str for ->str */
- SvREFCNT_dec(self->str);
- self->str = sv;
- SvREFCNT_inc_simple_void(self->str);
+ /* Store the current str for ->str */
+ SvREFCNT_dec(self->str);
+ self->str = sv;
+ SvREFCNT_inc_simple_void(self->str);
- PERL_UNUSED_ARG(strpos);
- PERL_UNUSED_ARG(strend);
- PERL_UNUSED_ARG(flags);
- PERL_UNUSED_ARG(data);
- return NULL;
+ PERL_UNUSED_ARG(strpos);
+ PERL_UNUSED_ARG(strend);
+ PERL_UNUSED_ARG(flags);
+ PERL_UNUSED_ARG(data);
+
+ return NULL;
- SvREFCNT_dec(self->cb_num_capture_buff_FETCH);
- SvREFCNT_dec(self->cb_num_capture_buff_STORE);
- SvREFCNT_dec(self->cb_num_capture_buff_LENGTH);
+ SvREFCNT_dec(self->cb_num_capture_buff_FETCH);
+ SvREFCNT_dec(self->cb_num_capture_buff_STORE);
+ SvREFCNT_dec(self->cb_num_capture_buff_LENGTH);
- dSP;
- I32 items;
- SV * callback;
- struct regexp *rx = rxREGEXP(RX);
- GET_SELF_FROM_PPRIVATE(rx->pprivate);
-
- callback = self->cb_num_capture_buff_FETCH;
-
- if (callback) {
- ENTER;
- SAVETMPS;
-
- PUSHMARK(SP);
- XPUSHs(rx->pprivate);
- XPUSHs(sv_2mortal(newSViv(paren)));
- PUTBACK;
-
- items = call_sv(callback, G_SCALAR);
-
- if (items == 1) {
- SV *ret;
-
- SPAGAIN;
- ret = POPs;
- sv_setsv(sv, ret);
- } else {
- sv_setsv(sv, &PL_sv_undef);
- }
-
- PUTBACK;
- FREETMPS;
- LEAVE;
- } else {
- sv_setsv(sv, &PL_sv_undef);
- }
+ dSP;
+ I32 items;
+ SV *callback;
+ struct regexp *rx = rxREGEXP(RX);
+
+ GET_SELF_FROM_PPRIVATE(rx->pprivate);
+
+ callback = self->cb_num_capture_buff_FETCH;
+
+ if (callback) {
+ ENTER;
+ SAVETMPS;
+
+ PUSHMARK(SP);
+ XPUSHs(rx->pprivate);
+ XPUSHs(sv_2mortal(newSViv(paren)));
+ PUTBACK;
+
+ items = call_sv(callback, G_SCALAR);
+
+ if (items == 1) {
+ SV *ret;
+ SPAGAIN;
+ ret = POPs;
+ sv_setsv(sv, ret);
+ } else {
+ sv_setsv(sv, &PL_sv_undef);
+ }
+
+ PUTBACK;
+ FREETMPS;
+ LEAVE;
+ } else {
+ sv_setsv(sv, &PL_sv_undef);
+ }
-SV*
-Plugin_named_buff (pTHX_ REGEXP * const RX, SV * const key, SV * const value,
- const U32 flags)
+SV *
+Plugin_named_buff(pTHX_ REGEXP * const RX, SV * const key, SV * const value,
+ const U32 flags)
- stash = gv_stashpvn(XSH_PACKAGE, XSH_PACKAGE_LEN, 1);
- newCONSTSUB(stash, "REP_THREADSAFE", newSVuv(XSH_THREADSAFE));
- newCONSTSUB(stash, "REP_FORKSAFE", newSVuv(XSH_FORKSAFE));
+ stash = gv_stashpvn(XSH_PACKAGE, XSH_PACKAGE_LEN, 1);
+ newCONSTSUB(stash, "REP_THREADSAFE", newSVuv(XSH_THREADSAFE));
+ newCONSTSUB(stash, "REP_FORKSAFE", newSVuv(XSH_FORKSAFE));
#endif /* XSH_THREADSAFE */
void
pattern(re::engine::Plugin self, ...)
PPCODE:
#endif /* XSH_THREADSAFE */
void
pattern(re::engine::Plugin self, ...)
PPCODE:
- flags = self->rx->intflags;
- if (flags & PMf_FOLD) /* /i */
- mods[n++] = 'i';
- if (flags & PMf_MULTILINE) /* /m */
- mods[n++] = 'm';
- if (flags & PMf_SINGLELINE) /* /s */
- mods[n++] = 's';
- if (flags & PMf_EXTENDED) /* /x */
- mods[n++] = 'x';
- if (flags & RXf_PMf_KEEPCOPY) /* /p */
- mods[n++] = 'p';
- mods[n] = '\0';
- EXTEND(SP, 2 * n);
- for (i = 0; i < n; ++i) {
- mPUSHp(mods + i, 1);
- PUSHs(&PL_sv_yes);
- }
- XSRETURN(2 * n);
+ flags = self->rx->intflags;
+ if (flags & PMf_FOLD) /* /i */
+ mods[n++] = 'i';
+ if (flags & PMf_MULTILINE) /* /m */
+ mods[n++] = 'm';
+ if (flags & PMf_SINGLELINE) /* /s */
+ mods[n++] = 's';
+ if (flags & PMf_EXTENDED) /* /x */
+ mods[n++] = 'x';
+ if (flags & RXf_PMf_KEEPCOPY) /* /p */
+ mods[n++] = 'p';
+ mods[n] = '\0';
+ EXTEND(SP, 2 * n);
+ for (i = 0; i < n; ++i) {
+ mPUSHp(mods + i, 1);
+ PUSHs(&PL_sv_yes);
+ }
+ XSRETURN(2 * n);
- if (items > 1) {
- self->rx->minlen = (I32)SvIV(ST(1));
- XSRETURN_EMPTY;
- } else {
- if (self->rx->minlen) {
- XPUSHs(sv_2mortal(newSViv(self->rx->minlen)));
- } else {
- XPUSHs(sv_2mortal(&PL_sv_undef));
- }
- }
+ if (items > 1) {
+ self->rx->minlen = (I32)SvIV(ST(1));
+ XSRETURN_EMPTY;
+ } else {
+ if (self->rx->minlen) {
+ XPUSHs(sv_2mortal(newSViv(self->rx->minlen)));
+ } else {
+ XPUSHs(sv_2mortal(&PL_sv_undef));
+ }
+ }
- if (items > 1) {
- self->rx->gofs = (U32)SvIV(ST(1));
- XSRETURN_EMPTY;
- } else {
- if (self->rx->gofs) {
- XPUSHs(sv_2mortal(newSVuv(self->rx->gofs)));
- } else {
- XPUSHs(sv_2mortal(&PL_sv_undef));
- }
- }
+ if (items > 1) {
+ self->rx->gofs = (U32)SvIV(ST(1));
+ XSRETURN_EMPTY;
+ } else {
+ if (self->rx->gofs) {
+ XPUSHs(sv_2mortal(newSVuv(self->rx->gofs)));
+ } else {
+ XPUSHs(sv_2mortal(&PL_sv_undef));
+ }
+ }
- if (items > 1) {
- self->rx->nparens = (U32)SvIV(ST(1));
- XSRETURN_EMPTY;
- } else {
- if (self->rx->nparens) {
- XPUSHs(sv_2mortal(newSVuv(self->rx->nparens)));
- } else {
- XPUSHs(sv_2mortal(&PL_sv_undef));
- }
- }
+ if (items > 1) {
+ self->rx->nparens = (U32)SvIV(ST(1));
+ XSRETURN_EMPTY;
+ } else {
+ if (self->rx->nparens) {
+ XPUSHs(sv_2mortal(newSVuv(self->rx->nparens)));
+ } else {
+ XPUSHs(sv_2mortal(&PL_sv_undef));
+ }
+ }
- if (items > 1) {
- SvREFCNT_dec(self->cb_num_capture_buff_FETCH);
- self->cb_num_capture_buff_FETCH = ST(1);
- SvREFCNT_inc_simple_void(self->cb_num_capture_buff_FETCH);
- }
+ if (items > 1) {
+ SvREFCNT_dec(self->cb_num_capture_buff_FETCH);
+ self->cb_num_capture_buff_FETCH = ST(1);
+ SvREFCNT_inc_simple_void(self->cb_num_capture_buff_FETCH);
+ }
- if (items > 1) {
- SvREFCNT_dec(self->cb_num_capture_buff_STORE);
- self->cb_num_capture_buff_STORE = ST(1);
- SvREFCNT_inc_simple_void(self->cb_num_capture_buff_STORE);
- }
+ if (items > 1) {
+ SvREFCNT_dec(self->cb_num_capture_buff_STORE);
+ self->cb_num_capture_buff_STORE = ST(1);
+ SvREFCNT_inc_simple_void(self->cb_num_capture_buff_STORE);
+ }
- if (items > 1) {
- SvREFCNT_dec(self->cb_num_capture_buff_LENGTH);
- self->cb_num_capture_buff_LENGTH = ST(1);
- SvREFCNT_inc_simple_void(self->cb_num_capture_buff_LENGTH);
- }
+ if (items > 1) {
+ SvREFCNT_dec(self->cb_num_capture_buff_LENGTH);
+ self->cb_num_capture_buff_LENGTH = ST(1);
+ SvREFCNT_inc_simple_void(self->cb_num_capture_buff_LENGTH);
+ }