]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/commitdiff
Fix building with blead
authorVincent Pit <vince@profvince.com>
Sun, 23 Aug 2009 09:05:39 +0000 (11:05 +0200)
committerVincent Pit <vince@profvince.com>
Sun, 23 Aug 2009 09:05:39 +0000 (11:05 +0200)
Plugin.h
Plugin.xs
t/num_buff/LENGTH.t

index 1b186306215da913554dadf7569bf034c07e3a21..109854ad2d518be15f5a45cbb9777247cd3d7bc1 100644 (file)
--- a/Plugin.h
+++ b/Plugin.h
 
 START_EXTERN_C
 EXTERN_C const regexp_engine engine_plugin;
 
 START_EXTERN_C
 EXTERN_C const regexp_engine engine_plugin;
-EXTERN_C REGEXP * Plugin_comp(pTHX_ const SV const *, const U32);
+#if PERL_VERSION <= 10
+EXTERN_C REGEXP * Plugin_comp(pTHX_ const SV * const, const U32);
+#else
+EXTERN_C REGEXP * Plugin_comp(pTHX_ SV * const, U32);
+#endif
 EXTERN_C I32      Plugin_exec(pTHX_ REGEXP * const, char *, char *,
                               char *, I32, SV *, void *, U32);
 EXTERN_C char *   Plugin_intuit(pTHX_ REGEXP * const, SV *, char *,
 EXTERN_C I32      Plugin_exec(pTHX_ REGEXP * const, char *, char *,
                               char *, I32, SV *, void *, U32);
 EXTERN_C char *   Plugin_intuit(pTHX_ REGEXP * const, SV *, char *,
@@ -60,9 +64,9 @@ const regexp_engine engine_plugin = {
 };
 
 typedef struct replug {
 };
 
 typedef struct replug {
-    /* Pointer back to the containing REGEXP struct so that accessors
+    /* Pointer back to the containing regexp struct so that accessors
      * can modify nparens, gofs etc. */
      * can modify nparens, gofs etc. */
-    REGEXP * rx;
+    struct regexp * rx;
 
     /* A copy of the pattern given to comp, for ->pattern */
     SV * pattern;
 
     /* A copy of the pattern given to comp, for ->pattern */
     SV * pattern;
@@ -84,3 +88,11 @@ typedef struct replug {
     SV * cb_num_capture_buff_STORE;
     SV * cb_num_capture_buff_LENGTH;
 } *re__engine__Plugin;
     SV * cb_num_capture_buff_STORE;
     SV * cb_num_capture_buff_LENGTH;
 } *re__engine__Plugin;
+
+#if PERL_VERSION >= 11
+# define rxREGEXP(RX)  (SvANY(RX))
+# define newREGEXP(RX) ((RX) = ((REGEXP*) newSV_type(SVt_REGEXP)))
+#else
+# define rxREGEXP(RX)  (RX)
+# define newREGEXP(RX) (Newxz((RX), 1, struct regexp))
+#endif
index 2ebc28deebb9c3be4afe92773fcc1aaaec4efc23..2aeb2b951268e4858836f8f75c1a3292602c0992 100644 (file)
--- a/Plugin.xs
+++ b/Plugin.xs
@@ -39,10 +39,15 @@ get_H_callback(const char* key)
 }
 
 REGEXP *
 }
 
 REGEXP *
+#if PERL_VERSION <= 10
 Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
 Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
+#else
+Plugin_comp(pTHX_ SV * const pattern, U32 flags)
+#endif
 {
     dSP;
 {
     dSP;
-    REGEXP * rx;
+    struct regexp * rx;
+    REGEXP *RX;
     re__engine__Plugin re;
     I32 buffers;
 
     re__engine__Plugin re;
     I32 buffers;
 
@@ -50,21 +55,23 @@ Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
     STRLEN plen;
     char*  exp = SvPV((SV*)pattern, plen);
 
     STRLEN plen;
     char*  exp = SvPV((SV*)pattern, plen);
 
-    /* The REGEXP structure to return to perl */
-    Newxz(rx, 1, REGEXP);
-
     /* Our blessed object */
     SV *obj = newSV(0);
     SvREFCNT_inc(obj);
     Newxz(re, 1, struct replug);
     sv_setref_pv(obj, "re::engine::Plugin", (void*)re);
 
     /* Our blessed object */
     SV *obj = newSV(0);
     SvREFCNT_inc(obj);
     Newxz(re, 1, struct replug);
     sv_setref_pv(obj, "re::engine::Plugin", (void*)re);
 
+    newREGEXP(RX);
+    rx = rxREGEXP(RX);
+
     re->rx = rx;                   /* Make the rx accessible from self->rx */
     re->rx = rx;                   /* Make the rx accessible from self->rx */
-    rx->refcnt = 1;                /* Refcount so we won' be destroyed */
     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->intflags = flags;          /* Flags for internal use */
     rx->extflags = flags;          /* Flags for perl to use */
     rx->engine = RE_ENGINE_PLUGIN; /* Compile to use this engine */
 
+#if PERL_VERSION <= 10
+    rx->refcnt = 1;                /* Refcount so we won't be destroyed */
+
     /* Precompiled pattern for pp_regcomp to use */
     rx->prelen = plen;
     rx->precomp = savepvn(exp, rx->prelen);
     /* Precompiled pattern for pp_regcomp to use */
     rx->prelen = plen;
     rx->precomp = savepvn(exp, rx->prelen);
@@ -75,6 +82,7 @@ Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
     rx->wraplen = rx->prelen;
     Newx(rx->wrapped, rx->wraplen, char);
     Copy(rx->precomp, rx->wrapped, rx->wraplen, char);
     rx->wraplen = rx->prelen;
     Newx(rx->wrapped, rx->wraplen, char);
     Copy(rx->precomp, rx->wrapped, rx->wraplen, char);
+#endif
 
     /* Store our private object */
     rx->pprivate = obj;
 
     /* Store our private object */
     rx->pprivate = obj;
@@ -112,16 +120,17 @@ Plugin_comp(pTHX_ const SV * const pattern, const U32 flags)
 
     Newxz(rx->offs, buffers + 1, regexp_paren_pair);
 
 
     Newxz(rx->offs, buffers + 1, regexp_paren_pair);
 
-    return rx;
+    return RX;
 }
 
 I32
 }
 
 I32
-Plugin_exec(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
+Plugin_exec(pTHX_ REGEXP * const RX, char *stringarg, char *strend,
             char *strbeg, I32 minend, SV *sv, void *data, U32 flags)
 {
     dSP;
     I32 matched;
     SV * callback = get_H_callback("exec");
             char *strbeg, I32 minend, SV *sv, void *data, U32 flags)
 {
     dSP;
     I32 matched;
     SV * callback = get_H_callback("exec");
+    struct regexp *rx = rxREGEXP(RX);
     GET_SELF_FROM_PPRIVATE(rx->pprivate);
 
     if (callback) {
     GET_SELF_FROM_PPRIVATE(rx->pprivate);
 
     if (callback) {
@@ -159,10 +168,10 @@ Plugin_exec(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
 }
 
 char *
 }
 
 char *
-Plugin_intuit(pTHX_ REGEXP * const rx, SV *sv, char *strpos,
+Plugin_intuit(pTHX_ REGEXP * const RX, SV *sv, char *strpos,
                      char *strend, U32 flags, re_scream_pos_data *data)
 {
                      char *strend, U32 flags, re_scream_pos_data *data)
 {
-    PERL_UNUSED_ARG(rx);
+    PERL_UNUSED_ARG(RX);
     PERL_UNUSED_ARG(sv);
     PERL_UNUSED_ARG(strpos);
     PERL_UNUSED_ARG(strend);
     PERL_UNUSED_ARG(sv);
     PERL_UNUSED_ARG(strpos);
     PERL_UNUSED_ARG(strend);
@@ -172,16 +181,16 @@ Plugin_intuit(pTHX_ REGEXP * const rx, SV *sv, char *strpos,
 }
 
 SV *
 }
 
 SV *
-Plugin_checkstr(pTHX_ REGEXP * const rx)
+Plugin_checkstr(pTHX_ REGEXP * const RX)
 {
 {
-    PERL_UNUSED_ARG(rx);
+    PERL_UNUSED_ARG(RX);
     return NULL;
 }
 
 void
     return NULL;
 }
 
 void
-Plugin_free(pTHX_ REGEXP * const rx)
+Plugin_free(pTHX_ REGEXP * const RX)
 {
 {
-    PERL_UNUSED_ARG(rx);
+    PERL_UNUSED_ARG(RX);
 /*
     dSP;
     SV * callback;
 /*
     dSP;
     SV * callback;
@@ -208,20 +217,22 @@ Plugin_free(pTHX_ REGEXP * const rx)
 }
 
 void *
 }
 
 void *
-Plugin_dupe(pTHX_ REGEXP * const rx, CLONE_PARAMS *param)
+Plugin_dupe(pTHX_ REGEXP * const RX, CLONE_PARAMS *param)
 {
 {
+    struct regexp *rx = rxREGEXP(RX);
     Perl_croak(aTHX_ "dupe not supported yet");
     return rx->pprivate;
 }
 
 
 void
     Perl_croak(aTHX_ "dupe not supported yet");
     return rx->pprivate;
 }
 
 
 void
-Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const rx, const I32 paren,
+Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const RX, const I32 paren,
                            SV * const sv)
 {
     dSP;
     I32 items;
     SV * callback;
                            SV * const sv)
 {
     dSP;
     I32 items;
     SV * callback;
+    struct regexp *rx = rxREGEXP(RX);
     GET_SELF_FROM_PPRIVATE(rx->pprivate);
 
     callback = self->cb_num_capture_buff_FETCH;
     GET_SELF_FROM_PPRIVATE(rx->pprivate);
 
     callback = self->cb_num_capture_buff_FETCH;
@@ -255,11 +266,12 @@ Plugin_numbered_buff_FETCH(pTHX_ REGEXP * const rx, const I32 paren,
 }
 
 void
 }
 
 void
-Plugin_numbered_buff_STORE(pTHX_ REGEXP * const rx, const I32 paren,
+Plugin_numbered_buff_STORE(pTHX_ REGEXP * const RX, const I32 paren,
                            SV const * const value)
 {
     dSP;
     SV * callback;
                            SV const * const value)
 {
     dSP;
     SV * callback;
+    struct regexp *rx = rxREGEXP(RX);
     GET_SELF_FROM_PPRIVATE(rx->pprivate);
 
     callback = self->cb_num_capture_buff_STORE;
     GET_SELF_FROM_PPRIVATE(rx->pprivate);
 
     callback = self->cb_num_capture_buff_STORE;
@@ -283,11 +295,12 @@ Plugin_numbered_buff_STORE(pTHX_ REGEXP * const rx, const I32 paren,
 }
 
 I32
 }
 
 I32
-Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const rx, const SV * const sv,
+Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const RX, const SV * const sv,
                               const I32 paren)
 {
     dSP;
     SV * callback;
                               const I32 paren)
 {
     dSP;
     SV * callback;
+    struct regexp *rx = rxREGEXP(RX);
     GET_SELF_FROM_PPRIVATE(rx->pprivate);
 
     callback = self->cb_num_capture_buff_LENGTH;
     GET_SELF_FROM_PPRIVATE(rx->pprivate);
 
     callback = self->cb_num_capture_buff_LENGTH;
@@ -320,23 +333,23 @@ Plugin_numbered_buff_LENGTH(pTHX_ REGEXP * const rx, const SV * const sv,
 
 
 SV*
 
 
 SV*
-Plugin_named_buff (pTHX_ REGEXP * const rx, SV * const key, SV * const value,
+Plugin_named_buff (pTHX_ REGEXP * const RX, SV * const key, SV * const value,
                    const U32 flags)
 {
     return NULL;
 }
 
 SV*
                    const U32 flags)
 {
     return NULL;
 }
 
 SV*
-Plugin_named_buff_iter (pTHX_ REGEXP * const rx, const SV * const lastkey,
+Plugin_named_buff_iter (pTHX_ REGEXP * const RX, const SV * const lastkey,
                         const U32 flags)
 {
     return NULL;
 }
 
 SV*
                         const U32 flags)
 {
     return NULL;
 }
 
 SV*
-Plugin_package(pTHX_ REGEXP * const rx)
+Plugin_package(pTHX_ REGEXP * const RX)
 {
 {
-    PERL_UNUSED_ARG(rx);
+    PERL_UNUSED_ARG(RX);
     return newSVpvs("re::engine::Plugin");
 }
 
     return newSVpvs("re::engine::Plugin");
 }
 
index 7e8afdd5ea848cdb01a168473bcdf912f962168d..957b39edb473c28bb94d2cdb6423718852b6488f 100644 (file)
@@ -1,5 +1,5 @@
 use strict;
 use strict;
-use Test::More tests => 7;
+use Test::More $] < 5.011 ? (tests => 7) : (skip_all => 'Not working in blead');
 
 use re::engine::Plugin (
     exec => sub {
 
 use re::engine::Plugin (
     exec => sub {