This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
eliminate RF_warned flag from PL_reg_flags
authorDavid Mitchell <davem@iabyn.com>
Tue, 25 Dec 2012 18:24:50 +0000 (18:24 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 25 Dec 2012 18:24:50 +0000 (18:24 +0000)
This global flag indicates whether the currently executing regex has
issued a recursion limit warning yet.
Replace it with a boolean var local to the regmatch_info struct.

This is a second step to eliminating PL_reg_flags.

regexec.c
regexp.h

index 4ca4821..104e1d2 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -94,7 +94,6 @@ static const char* const non_utf8_target_but_utf8_required
 #include "unicode_constants.h"
 
 #define RF_tainted     1       /* tainted information used? e.g. locale */
-#define RF_warned      2               /* warned about big count? */
 
 #define HAS_NONLATIN1_FOLD_CLOSURE(i) _HAS_NONLATIN1_FOLD_CLOSURE_ONLY_FOR_USE_BY_REGCOMP_DOT_C_AND_REGEXEC_DOT_C(i)
 
@@ -2110,6 +2109,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
     PL_reg_maxiter = 0;
 
     reginfo.is_utf8_pat = cBOOL(RX_UTF8(rx));
+    reginfo.warned = FALSE;
     /* Mark beginning of line for ^ and lookbehind. */
     reginfo.bol = startpos; /* XXX not used ??? */
     PL_bostr  = strbeg;
@@ -5552,9 +5552,9 @@ NULL
          do_whilem_B_max:
            if (cur_curlyx->u.curlyx.count >= REG_INFTY
                && ckWARN(WARN_REGEXP)
-               && !(PL_reg_flags & RF_warned))
+               && !reginfo->warned)
            {
-               PL_reg_flags |= RF_warned;
+                reginfo->warned        = TRUE;
                Perl_warner(aTHX_ packWARN(WARN_REGEXP),
                     "Complex regular subexpression recursion limit (%d) "
                     "exceeded",
@@ -5577,9 +5577,9 @@ NULL
                /* Maximum greed exceeded */
                if (cur_curlyx->u.curlyx.count >= REG_INFTY
                    && ckWARN(WARN_REGEXP)
-                   && !(PL_reg_flags & RF_warned))
+                    && !reginfo->warned)
                {
-                   PL_reg_flags |= RF_warned;
+                    reginfo->warned    = TRUE;
                    Perl_warner(aTHX_ packWARN(WARN_REGEXP),
                        "Complex regular subexpression recursion "
                        "limit (%d) exceeded",
index 035e2ba..3863308 100644 (file)
--- a/regexp.h
+++ b/regexp.h
@@ -576,6 +576,7 @@ typedef struct {
     char *ganch;
     char *cutpoint;
     bool is_utf8_pat;
+    bool warned; /* we have issued a recursion warning; no need for more */
 } regmatch_info;