This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pod/perlfunc: Tweak new kill() wording
[perl5.git] / regexp.h
index a462001..51630e4 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -46,7 +46,7 @@ struct reg_substr_data {
     struct reg_substr_datum data[3];   /* Actual array */
 };
 
-#ifdef PERL_OLD_COPY_ON_WRITE
+#ifdef PERL_ANY_COW
 #define SV_SAVED_COPY   SV *saved_copy; /* If non-NULL, SV which is COW from original */
 #else
 #define SV_SAVED_COPY
@@ -119,7 +119,6 @@ struct reg_code_block {
        /* during matching */                                           \
        U32 lastparen;                  /* last open paren matched */   \
        U32 lastcloseparen;             /* last close paren matched */  \
-       regexp_paren_pair *swap;        /* Unused: 5.10.1 and later */  \
        /* Array of offsets for (@-) and (@+) */                        \
        regexp_paren_pair *offs;                                        \
        /* saved or original string so \digit works forever. */         \
@@ -435,11 +434,25 @@ get_regex_charset_name(const U32 flags, STRLEN* const lenp)
  *
  */
 
+#if NO_TAINT_SUPPORT
+#   define RX_ISTAINTED(prog)    0
+#   define RX_TAINT_on(prog)     NOOP
+#   define RXp_MATCH_TAINTED(prog) 0
+#   define RX_MATCH_TAINTED(prog)  0
+#   define RXp_MATCH_TAINTED_on(prog) NOOP
+#   define RX_MATCH_TAINTED_on(prog)  NOOP
+#   define RX_MATCH_TAINTED_off(prog) NOOP
+#else
+#   define RX_ISTAINTED(prog)    (RX_EXTFLAGS(prog) & RXf_TAINTED)
+#   define RX_TAINT_on(prog)     (RX_EXTFLAGS(prog) |= RXf_TAINTED)
+#   define RXp_MATCH_TAINTED(prog)    (RXp_EXTFLAGS(prog) & RXf_TAINTED_SEEN)
+#   define RX_MATCH_TAINTED(prog)     (RX_EXTFLAGS(prog)  & RXf_TAINTED_SEEN)
+#   define RXp_MATCH_TAINTED_on(prog) (RXp_EXTFLAGS(prog) |= RXf_TAINTED_SEEN)
+#   define RX_MATCH_TAINTED_on(prog)  (RX_EXTFLAGS(prog)  |= RXf_TAINTED_SEEN)
+#   define RX_MATCH_TAINTED_off(prog) (RX_EXTFLAGS(prog)  &= ~RXf_TAINTED_SEEN)
+#endif
+
 #define RX_HAS_CUTGROUP(prog) ((prog)->intflags & PREGf_CUTGROUP_SEEN)
-#define RXp_MATCH_TAINTED(prog)        (RXp_EXTFLAGS(prog) & RXf_TAINTED_SEEN)
-#define RX_MATCH_TAINTED(prog) (RX_EXTFLAGS(prog) & RXf_TAINTED_SEEN)
-#define RX_MATCH_TAINTED_on(prog) (RX_EXTFLAGS(prog) |= RXf_TAINTED_SEEN)
-#define RX_MATCH_TAINTED_off(prog) (RX_EXTFLAGS(prog) &= ~RXf_TAINTED_SEEN)
 #define RX_MATCH_TAINTED_set(prog, t) ((t) \
                                       ? RX_MATCH_TAINTED_on(prog) \
                                       : RX_MATCH_TAINTED_off(prog))
@@ -487,7 +500,7 @@ get_regex_charset_name(const U32 flags, STRLEN* const lenp)
 
 /* Stuff that needs to be included in the pluggable extension goes below here */
 
-#ifdef PERL_OLD_COPY_ON_WRITE
+#ifdef PERL_ANY_COW
 #define RX_MATCH_COPY_FREE(rx) \
        STMT_START {if (RX_SAVED_COPY(rx)) { \
            SV_CHECK_THINKFIRST_COW_DROP(RX_SAVED_COPY(rx)); \
@@ -567,6 +580,8 @@ typedef struct {
     SV *sv;
     char *ganch;
     char *cutpoint;
+    bool is_utf8_pat;
+    bool warned; /* we have issued a recursion warning; no need for more */
 } regmatch_info;
  
 
@@ -638,9 +653,7 @@ typedef struct regmatch_state {
            struct regmatch_state *prev_eval;
            struct regmatch_state *prev_curlyx;
            REGEXP      *prev_rex;
-           U32         toggle_reg_flags; /* what bits in PL_reg_flags to
-                                           flip when transitioning between
-                                           inner and outer rexen */
+           bool        saved_utf8_pat; /* saved copy of is_utf8_pat */
            CHECKPOINT  cp;     /* remember current savestack indexes */
            CHECKPOINT  lastcp;
            U32        close_paren; /* which close bracket is our end */
@@ -741,7 +754,6 @@ typedef struct regmatch_slab {
     struct regmatch_slab *prev, *next;
 } regmatch_slab;
 
-#define PL_reg_flags           PL_reg_state.re_state_reg_flags
 #define PL_bostr               PL_reg_state.re_state_bostr
 #define PL_regeol              PL_reg_state.re_state_regeol
 #define PL_reg_match_utf8      PL_reg_state.re_state_reg_match_utf8
@@ -757,15 +769,17 @@ typedef struct regmatch_slab {
 #define PL_reg_leftiter                PL_reg_state.re_state_reg_leftiter
 #define PL_reg_poscache                PL_reg_state.re_state_reg_poscache
 #define PL_reg_poscache_size   PL_reg_state.re_state_reg_poscache_size
-#define PL_regsize             PL_reg_state.re_state_regsize
 #define PL_reg_starttry                PL_reg_state.re_state_reg_starttry
 #define PL_nrs                 PL_reg_state.re_state_nrs
 
 struct re_save_state {
-    U32 re_state_reg_flags;            /* from regexec.c */
     bool re_state_eval_setup_done;     /* from regexec.c */
     bool re_state_reg_match_utf8;      /* from regexec.c */
     bool re_reparsing;                 /* runtime (?{}) fed back into parser */
+    /* Space for U8 */
+    I32 re_state_reg_oldpos;           /* from regexec.c */
+    I32 re_state_reg_maxiter;          /* max wait until caching pos */
+    I32 re_state_reg_leftiter;         /* wait until caching pos */
     char *re_state_bostr;
     char *re_state_regeol;             /* End of input, for $ check. */
     MAGIC *re_state_reg_magic;         /* from regexec.c */
@@ -776,13 +790,9 @@ struct re_save_state {
     STRLEN re_state_reg_oldsavedoffset;        /* old offset of saved substr during match */
     STRLEN re_state_reg_oldsavedcoffset;/* old coffset of saved substr during match */
     STRLEN re_state_reg_poscache_size; /* size of pos cache of WHILEM */
-    I32 re_state_reg_oldpos;           /* from regexec.c */
-    I32 re_state_reg_maxiter;          /* max wait until caching pos */
-    I32 re_state_reg_leftiter;         /* wait until caching pos */
-    U32 re_state_regsize;              /* from regexec.c */
     char *re_state_reg_poscache;       /* cache of pos of WHILEM */
     char *re_state_reg_starttry;       /* from regexec.c */
-#ifdef PERL_OLD_COPY_ON_WRITE
+#ifdef PERL_ANY_COW
     SV *re_state_nrs;                  /* was placeholder: unused since 5.8.0 (5.7.2 patch #12027 for bug ID 20010815.012). Used to save rx->saved_copy */
 #endif
 };