Upgrade to Test-Simple-0.70
[p5sagit/p5-mst-13.2.git] / regexp.h
index 0bf886b..9cf324f 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -31,6 +31,7 @@ struct reg_substr_data;
 struct reg_data;
 
 struct regexp_engine;
+struct regexp;
 
 struct reg_substr_datum {
     I32 min_offset;
@@ -48,11 +49,19 @@ struct reg_substr_data {
 #else
 #define SV_SAVED_COPY
 #endif
+
+/* swap buffer for paren structs */
+typedef struct regexp_paren_ofs {
+    I32 *startp;
+    I32 *endp;
+} regexp_paren_ofs;
+
 /* this is ordered such that the most commonly used 
    fields are at the start of the struct */
 typedef struct regexp {
         /* what engine created this regexp? */
        const struct regexp_engine* engine; 
+       struct regexp* mother_re; /* what re is this a lightweight copy of? */
        
        /* Information about the match that the perl core uses to manage things */
        U32 extflags;           /* Flags used both externally and internally */
@@ -71,8 +80,10 @@ typedef struct regexp {
         /* Data about the last/current match. These are modified during matching*/
         U32 lastparen;         /* last open paren matched */
        U32 lastcloseparen;     /* last close paren matched */
+        regexp_paren_ofs *swap; /* Swap copy of *startp / *endp */ 
         I32 *startp;            /* Array of offsets from start of string (@-) */
        I32 *endp;              /* Array of offsets from start of string (@+) */
+
        char *subbeg;           /* saved or original string 
                                   so \digit works forever. */
        I32 sublen;             /* Length of string pointed by subbeg */
@@ -111,6 +122,8 @@ typedef struct regexp_engine {
                            struct re_scream_pos_data_s *data);
     SV*            (*checkstr) (pTHX_ regexp *prog);
     void    (*free) (pTHX_ struct regexp* r);
+    SV*     (*numbered_buff_get) (pTHX_ const REGEXP * const rx, I32 paren, SV* usesv);
+    SV*     (*named_buff_get)(pTHX_ const REGEXP * const rx, SV* namesv, U32 flags);
 #ifdef USE_ITHREADS
     void* (*dupe) (pTHX_ const regexp *r, CLONE_PARAMS *param);
 #endif    
@@ -159,9 +172,13 @@ typedef struct regexp_engine {
 
 /* chars and strings used as regex pattern modifiers
  * Singlular is a 'c'har, plural is a "string"
+ *
+ * NOTE, KEEPCOPY was originally 'k', but was changed to 'p' for preserve
+ * for compatibility reasons with Regexp::Common which highjacked (?k:...)
+ * for its own uses. So 'k' is out as well.
  */
 #define EXEC_PAT_MOD         'e'
-#define KEEPCOPY_PAT_MOD     'k'
+#define KEEPCOPY_PAT_MOD     'p'
 #define ONCE_PAT_MOD         'o'
 #define GLOBAL_PAT_MOD       'g'
 #define CONTINUE_PAT_MOD     'c'
@@ -171,7 +188,7 @@ typedef struct regexp_engine {
 #define XTENDED_PAT_MOD      'x'
 
 #define ONCE_PAT_MODS        "o"
-#define KEEPCOPY_PAT_MODS    "k"
+#define KEEPCOPY_PAT_MODS    "p"
 #define EXEC_PAT_MODS        "e"
 #define LOOP_PAT_MODS        "gc"
 
@@ -210,7 +227,6 @@ typedef struct regexp_engine {
 #define RXf_TAINTED_SEEN       0x20000000
 /* two bits here  */
 
-
 #define RX_HAS_CUTGROUP(prog) ((prog)->intflags & PREGf_CUTGROUP_SEEN)
 #define RX_MATCH_TAINTED(prog) ((prog)->extflags & RXf_TAINTED_SEEN)
 #define RX_MATCH_TAINTED_on(prog) ((prog)->extflags |= RXf_TAINTED_SEEN)
@@ -293,7 +309,9 @@ typedef struct {
 
 /* structures for holding and saving the state maintained by regmatch() */
 
-#define MAX_RECURSE_EVAL_NOCHANGE_DEPTH 50
+#ifndef MAX_RECURSE_EVAL_NOCHANGE_DEPTH
+#define MAX_RECURSE_EVAL_NOCHANGE_DEPTH 1000
+#endif
 
 typedef I32 CHECKPOINT;
 
@@ -310,16 +328,41 @@ typedef struct regmatch_state {
            struct regmatch_state *prev_yes_state;
        } yes;
 
-       struct {
+        /* branchlike members */
+        /* this is a fake union member that matches the first elements
+         * of each member that needs to behave like a branch */
+        struct {
            /* this first element must match u.yes */
            struct regmatch_state *prev_yes_state;
-           reg_trie_accepted *accept_buff;
+           U32 lastparen;
+           CHECKPOINT cp;
+           
+        } branchlike;
+                   
+       struct {
+           /* the first elements must match u.branchlike */
+           struct regmatch_state *prev_yes_state;
+           U32 lastparen;
+           CHECKPOINT cp;
+           
+           regnode *next_branch; /* next branch node */
+       } branch;
+
+       struct {
+           /* the first elements must match u.branchlike */
+           struct regmatch_state *prev_yes_state;
+           U32 lastparen;
+           CHECKPOINT cp;
+
+           reg_trie_accepted *accept_buff; /* accepting states we have seen */
            U32         accepted; /* how many accepting states we have seen */
            U16         *jump;  /* positive offsets from me */
            regnode     *B;     /* node following the trie */
            regnode     *me;    /* Which node am I - needed for jump tries*/
        } trie;
 
+        /* special types - these members are used to store state for special
+           regops like eval, if/then, lookaround and the markpoint state */
        struct {
            /* this first element must match u.yes */
            struct regmatch_state *prev_yes_state;
@@ -338,6 +381,28 @@ typedef struct regmatch_state {
        struct {
            /* this first element must match u.yes */
            struct regmatch_state *prev_yes_state;
+           I32 wanted;
+           I32 logical;        /* saved copy of 'logical' var */
+           regnode  *me; /* the IFMATCH/SUSPEND/UNLESSM node  */
+       } ifmatch; /* and SUSPEND/UNLESSM */
+       
+       struct {
+           /* this first element must match u.yes */
+           struct regmatch_state *prev_yes_state;
+           struct regmatch_state *prev_mark;
+           SV* mark_name;
+           char *mark_loc;
+       } mark;
+       
+       struct {
+           int val;
+       } keeper;
+
+        /* quantifiers - these members are used for storing state for
+           for the regops used to implement quantifiers */
+       struct {
+           /* this first element must match u.yes */
+           struct regmatch_state *prev_yes_state;
            struct regmatch_state *prev_curlyx; /* previous cur_curlyx */
            CHECKPOINT  cp;     /* remember current savestack index */
            bool        minmod;
@@ -365,14 +430,6 @@ typedef struct regmatch_state {
        struct {
            /* this first element must match u.yes */
            struct regmatch_state *prev_yes_state;
-           U32 lastparen;
-           regnode *next_branch; /* next branch node */
-           CHECKPOINT cp;
-       } branch;
-
-       struct {
-           /* this first element must match u.yes */
-           struct regmatch_state *prev_yes_state;
            I32 c1, c2;         /* case fold search */
            CHECKPOINT cp;
            I32 alen;           /* length of first-matched A string */
@@ -393,25 +450,6 @@ typedef struct regmatch_state {
            regnode *A, *B;     /* the nodes corresponding to /A*B/  */
        } curly; /* and CURLYN/PLUS/STAR */
 
-       struct {
-           /* this first element must match u.yes */
-           struct regmatch_state *prev_yes_state;
-           I32 wanted;
-           I32 logical;        /* saved copy of 'logical' var */
-           regnode  *me; /* the IFMATCH/SUSPEND/UNLESSM node  */
-       } ifmatch; /* and SUSPEND/UNLESSM */
-       
-       struct {
-           /* this first element must match u.yes */
-           struct regmatch_state *prev_yes_state;
-           struct regmatch_state *prev_mark;
-           SV* mark_name;
-           char *mark_loc;
-       } mark;
-       
-       struct {
-           int val;
-       } keeper;
     } u;
 } regmatch_state;