This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Don't try to recreate the LC_ALL C locale
[perl5.git] / regexp.h
index 39700e1..45f64e8 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -20,6 +20,8 @@
 
 #include "utf8.h"
 
+typedef SSize_t regnode_offset;
+
 struct regnode {
     U8 flags;
     U8  type;
@@ -105,57 +107,67 @@ struct reg_code_blocks {
   regexp's data array based on the data item's type.
 */
 
-#define _REGEXP_COMMON                                                 \
-        /* what engine created this regexp? */                         \
-       const struct regexp_engine* engine;                             \
-       REGEXP *mother_re; /* what re is this a lightweight copy of? */ \
-       HV *paren_names;   /* Optional hash of paren names */           \
-        /*--------------------------------------------------------*/    \
-       /* Information about the match that the perl core uses to */    \
-       /* manage things */                                             \
-       U32 extflags;   /* Flags used both externally and internally */ \
-       SSize_t minlen; /* mininum possible number of chars in string to match */\
-       SSize_t minlenret; /* mininum possible number of chars in $& */         \
-       STRLEN gofs;    /* chars left of pos that we search from */     \
-       /* substring data about strings that must appear in the */      \
-       /* final match, used for optimisations */                       \
-       struct reg_substr_data *substrs;                                \
-       U32 nparens;    /* number of capture buffers */                 \
-       /* private engine specific data */                              \
-       U32 intflags;   /* Engine Specific Internal flags */            \
-       void *pprivate; /* Data private to the regex engine which */    \
-                       /* created this object. */                      \
-        /*--------------------------------------------------------*/    \
-       /* Data about the last/current match. These are modified */     \
-       /* during matching */                                           \
-       U32 lastparen;                  /* last open paren matched */   \
-       U32 lastcloseparen;             /* last close paren matched */  \
-       /* Array of offsets for (@-) and (@+) */                        \
-       regexp_paren_pair *offs;                                        \
-        char **recurse_locinput; /* used to detect infinite recursion, XXX: move to internal */ \
-        /*--------------------------------------------------------*/    \
-       /* saved or original string so \digit works forever. */         \
-       char *subbeg;                                                   \
-       SV_SAVED_COPY   /* If non-NULL, SV which is COW from original */\
-       SSize_t sublen; /* Length of string pointed by subbeg */        \
-       SSize_t suboffset; /* byte offset of subbeg from logical start of str */ \
-       SSize_t subcoffset; /* suboffset equiv, but in chars (for @-/@+) */ \
-       /* Information about the match that isn't often used */         \
-        SSize_t maxlen;        /* mininum possible number of chars in string to match */\
-        /*--------------------------------------------------------*/    \
-       /* offset from wrapped to the start of precomp */               \
-       PERL_BITFIELD32 pre_prefix:4;                                   \
-        /* original flags used to compile the pattern, may differ */    \
-        /* from extflags in various ways */                             \
-        PERL_BITFIELD32 compflags:9;                                    \
-        /*--------------------------------------------------------*/    \
-       CV *qr_anoncv   /* the anon sub wrapped round qr/(?{..})/ */
-
 typedef struct regexp {
-       _XPV_HEAD;
-       _REGEXP_COMMON;
+    _XPV_HEAD;
+    const struct regexp_engine* engine; /* what engine created this regexp? */
+    REGEXP *mother_re; /* what re is this a lightweight copy of? */
+    HV *paren_names;   /* Optional hash of paren names */
+
+    /*----------------------------------------------------------------------
+     * Information about the match that the perl core uses to manage things
+     */
+
+    U32 extflags;      /* Flags used both externally and internally */
+    SSize_t minlen;    /* minimum possible number of chars in string to match */
+    SSize_t minlenret; /* mininum possible number of chars in $& */
+    STRLEN gofs;       /* chars left of pos that we search from */
+                       /* substring data about strings that must appear in
+                        * the final match, used for optimisations */
+    struct reg_substr_data *substrs;
+    U32 nparens;       /* number of capture buffers */
+
+    /* private engine specific data */
+
+    U32 intflags;      /* Engine Specific Internal flags */
+    void *pprivate;    /* Data private to the regex engine which
+                        * created this object. */
+
+    /*----------------------------------------------------------------------
+     * Data about the last/current match. These are modified during matching
+     */
+
+    U32 lastparen;           /* highest close paren matched ($+) */
+    U32 lastcloseparen;      /* last close paren matched ($^N) */
+    regexp_paren_pair *offs; /* Array of offsets for (@-) and (@+) */
+    char **recurse_locinput; /* used to detect infinite recursion, XXX: move to internal */
+
+    /*---------------------------------------------------------------------- */
+
+    char *subbeg;       /* saved or original string so \digit works forever. */
+    SV_SAVED_COPY       /* If non-NULL, SV which is COW from original */
+    SSize_t sublen;     /* Length of string pointed by subbeg */
+    SSize_t suboffset;  /* byte offset of subbeg from logical start of str */
+    SSize_t subcoffset; /* suboffset equiv, but in chars (for @-/@+) */
+
+    /* Information about the match that isn't often used */
+
+    SSize_t maxlen;  /* minimum possible number of chars in string to match */
+
+    /*---------------------------------------------------------------------- */
+
+    /* offset from wrapped to the start of precomp */
+    PERL_BITFIELD32 pre_prefix:4;
+
+    /* original flags used to compile the pattern, may differ from
+     * extflags in various ways */
+    PERL_BITFIELD32 compflags:9;
+
+    /*---------------------------------------------------------------------- */
+
+    CV *qr_anoncv;      /* the anon sub wrapped round qr/(?{..})/ */
 } regexp;
 
+
 #define RXp_PAREN_NAMES(rx)    ((rx)->paren_names)
 
 /* used for high speed searches */
@@ -464,6 +476,7 @@ and check for NULL.
 #  define RX_MATCH_TAINTED(rx_sv)       0
 #  define RXp_MATCH_TAINTED_on(prog)    NOOP
 #  define RX_MATCH_TAINTED_on(rx_sv)    NOOP
+#  define RXp_MATCH_TAINTED_off(prog)   NOOP
 #  define RX_MATCH_TAINTED_off(rx_sv)   NOOP
 #else
 #  define RX_ISTAINTED(rx_sv)           (RX_EXTFLAGS(rx_sv) & RXf_TAINTED)
@@ -562,12 +575,12 @@ and check for NULL.
            RXp_MATCH_COPIED_off(prog); \
        }} STMT_END
 #endif
-#define RX_MATCH_COPY_FREE(rx_sv)       (RXp_MATCH_COPY_FREE(ReANY(rx_sv)))
+#define RX_MATCH_COPY_FREE(rx_sv)       RXp_MATCH_COPY_FREE(ReANY(rx_sv))
 
 #define RXp_MATCH_UTF8(prog)            (RXp_EXTFLAGS(prog) & RXf_MATCH_UTF8)
 #define RX_MATCH_UTF8(rx_sv)            (RX_EXTFLAGS(rx_sv) & RXf_MATCH_UTF8)
 #define RXp_MATCH_UTF8_on(prog)         (RXp_EXTFLAGS(prog) |= RXf_MATCH_UTF8)
-#define RX_MATCH_UTF8_on(rx_sv)         (RXp_EXTFLAGS(ReANY(rx_sv)))
+#define RX_MATCH_UTF8_on(rx_sv)         (RXp_MATCH_UTF8_on(ReANY(rx_sv)))
 #define RXp_MATCH_UTF8_off(prog)        (RXp_EXTFLAGS(prog) &= ~RXf_MATCH_UTF8)
 #define RX_MATCH_UTF8_off(rx_sv)        (RXp_MATCH_UTF8_off(ReANY(rx_sv))
 #define RXp_MATCH_UTF8_set(prog, t)     ((t) \
@@ -701,6 +714,7 @@ typedef I32 CHECKPOINT;
 typedef struct regmatch_state {
     int resume_state;          /* where to jump to on return */
     char *locinput;            /* where to backtrack in string on failure */
+    char *loceol;
 
     union {
 
@@ -793,6 +807,9 @@ typedef struct regmatch_state {
            struct regmatch_state *prev_yes_state;
            I32 wanted;
            I32 logical;        /* saved copy of 'logical' var */
+            U8  count;          /* number of beginning positions */
+            char *start;
+            char *end;
            regnode  *me; /* the IFMATCH/SUSPEND/UNLESSM node  */
        } ifmatch; /* and SUSPEND/UNLESSM */