This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regexec.c: Change MiXeD cAsE formal macro parameters
[perl5.git] / regexec.c
index 39a8a06..187c39a 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -288,7 +288,6 @@ static regmatch_state * S_push_slab(pTHX);
 STATIC CHECKPOINT
 S_regcppush(pTHX_ const regexp *rex, I32 parenfloor, U32 maxopenparen)
 {
-    dVAR;
     const int retval = PL_savestack_ix;
     const int paren_elems_to_push =
                 (maxopenparen - parenfloor) * REGCP_PAREN_ELEMS;
@@ -369,7 +368,6 @@ S_regcppush(pTHX_ const regexp *rex, I32 parenfloor, U32 maxopenparen)
 STATIC void
 S_regcppop(pTHX_ regexp *rex, U32 *maxopenparen_p)
 {
-    dVAR;
     UV i;
     U32 paren;
     GET_RE_DEBUG_FLAGS_DECL;
@@ -487,8 +485,7 @@ S_isFOO_lc(pTHX_ const U8 classnum, const U8 character)
             Perl_croak(aTHX_ "panic: isFOO_lc() has an unexpected character class '%d'", classnum);
     }
 
-    /* NOTREACHED */
-    assert(0);
+    assert(0); /* NOTREACHED */
     return FALSE;
 }
 
@@ -543,8 +540,7 @@ S_isFOO_utf8_lc(pTHX_ const U8 classnum, const U8* character)
                                                below 256 */
     }
 
-    /* NOTREACHED */
-    assert(0);
+    assert(0); /* NOTREACHED */
     return FALSE;
 }
 
@@ -651,7 +647,6 @@ Perl_re_intuit_start(pTHX_
                     const U32 flags,
                     re_scream_pos_data *data)
 {
-    dVAR;
     struct regexp *const prog = ReANY(rx);
     SSize_t start_shift = prog->check_offset_min;
     /* Should be nonnegative! */
@@ -1507,10 +1502,10 @@ STMT_START {
     }                                                                               \
 } STMT_END
 
-#define REXEC_FBC_EXACTISH_SCAN(CoNd)                     \
+#define REXEC_FBC_EXACTISH_SCAN(COND)                     \
 STMT_START {                                              \
     while (s <= e) {                                      \
-       if ( (CoNd)                                       \
+       if ( (COND)                                       \
             && (ln == 1 || folder(s, pat_string, ln))    \
             && (reginfo->intuit || regtry(reginfo, &s)) )\
            goto got_it;                                  \
@@ -1518,25 +1513,25 @@ STMT_START {                                              \
     }                                                     \
 } STMT_END
 
-#define REXEC_FBC_UTF8_SCAN(CoDe)                     \
+#define REXEC_FBC_UTF8_SCAN(CODE)                     \
 STMT_START {                                          \
     while (s < strend) {                              \
-       CoDe                                          \
+       CODE                                          \
        s += UTF8SKIP(s);                             \
     }                                                 \
 } STMT_END
 
-#define REXEC_FBC_SCAN(CoDe)                          \
+#define REXEC_FBC_SCAN(CODE)                          \
 STMT_START {                                          \
     while (s < strend) {                              \
-       CoDe                                          \
+       CODE                                          \
        s++;                                          \
     }                                                 \
 } STMT_END
 
-#define REXEC_FBC_UTF8_CLASS_SCAN(CoNd)               \
+#define REXEC_FBC_UTF8_CLASS_SCAN(COND)               \
 REXEC_FBC_UTF8_SCAN(                                  \
-    if (CoNd) {                                       \
+    if (COND) {                                       \
        if (tmp && (reginfo->intuit || regtry(reginfo, &s))) \
            goto got_it;                              \
        else                                          \
@@ -1546,9 +1541,9 @@ REXEC_FBC_UTF8_SCAN(                                  \
        tmp = 1;                                      \
 )
 
-#define REXEC_FBC_CLASS_SCAN(CoNd)                    \
+#define REXEC_FBC_CLASS_SCAN(COND)                    \
 REXEC_FBC_SCAN(                                       \
-    if (CoNd) {                                       \
+    if (COND) {                                       \
        if (tmp && (reginfo->intuit || regtry(reginfo, &s)))  \
            goto got_it;                              \
        else                                          \
@@ -1562,12 +1557,12 @@ REXEC_FBC_SCAN(                                       \
 if ((reginfo->intuit || regtry(reginfo, &s))) \
     goto got_it
 
-#define REXEC_FBC_CSCAN(CoNdUtF8,CoNd)                         \
+#define REXEC_FBC_CSCAN(CONDUTF8,COND)                         \
     if (utf8_target) {                                         \
-       REXEC_FBC_UTF8_CLASS_SCAN(CoNdUtF8);                   \
+       REXEC_FBC_UTF8_CLASS_SCAN(CONDUTF8);                   \
     }                                                          \
     else {                                                     \
-       REXEC_FBC_CLASS_SCAN(CoNd);                            \
+       REXEC_FBC_CLASS_SCAN(COND);                            \
     }
     
 #define DUMP_EXEC_POS(li,s,doutf8)                          \
@@ -1588,7 +1583,7 @@ if ((reginfo->intuit || regtry(reginfo, &s))) \
            }                                                                  \
        );                                                                     \
 
-#define UTF8_LOAD(TeSt1_UtF8, TeSt2_UtF8, IF_SUCCESS, IF_FAIL)                 \
+#define UTF8_LOAD(TEST1_UTF8, TEST2_UTF8, IF_SUCCESS, IF_FAIL)                 \
        if (s == reginfo->strbeg) {                                            \
            tmp = '\n';                                                        \
        }                                                                      \
@@ -1597,10 +1592,10 @@ if ((reginfo->intuit || regtry(reginfo, &s))) \
            tmp = utf8n_to_uvchr(r, (U8*) reginfo->strend - r,                 \
                                                        0, UTF8_ALLOW_DEFAULT); \
        }                                                                      \
-       tmp = TeSt1_UtF8;                                                      \
+       tmp = TEST1_UTF8;                                                      \
        LOAD_UTF8_CHARCLASS_ALNUM();                                           \
        REXEC_FBC_UTF8_SCAN(                                                   \
-           if (tmp == ! (TeSt2_UtF8)) {                                       \
+           if (tmp == ! (TEST2_UTF8)) {                                       \
                tmp = !tmp;                                                    \
                IF_SUCCESS;                                                    \
            }                                                                  \
@@ -2013,8 +2008,7 @@ S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
 
                 default:
                     Perl_croak(aTHX_ "panic: find_byclass() node %d='%s' has an unexpected character class '%d'", OP(c), PL_reg_name[OP(c)], classnum);
-                    /* NOTREACHED */
-                    assert(0);
+                    assert(0); /* NOTREACHED */
             }
         }
         break;
@@ -2436,7 +2430,6 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
 /* flags:     For optimizations. See REXEC_* in regexp.h */
 
 {
-    dVAR;
     struct regexp *const prog = ReANY(rx);
     char *s;
     regnode *c;
@@ -3157,7 +3150,6 @@ phooey:
 STATIC I32                     /* 0 failure, 1 success */
 S_regtry(pTHX_ regmatch_info *reginfo, char **startposp)
 {
-    dVAR;
     CHECKPOINT lastcp;
     REGEXP *const rx = reginfo->prog;
     regexp *const prog = ReANY(rx);
@@ -3814,8 +3806,7 @@ S_setup_EXACTISH_ST_c1_c2(pTHX_ const regnode * const text_node, int *c1p,
 
                     default:
                         Perl_croak(aTHX_ "panic: Unexpected op %u", OP(text_node));
-                        /* NOTREACHED */
-                        assert(0);
+                        assert(0); /* NOTREACHED */
                 }
             }
         }
@@ -4064,8 +4055,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
                               REPORT_CODE_OFF+depth*2, "", PL_colors[4], PL_colors[5])
                 );
                 sayNO_SILENT;
-                /* NOTREACHED */
-                assert(0);
+                assert(0); /* NOTREACHED */
             }
             /* FALLTHROUGH */
        case TRIE:  /* (ab|cd)  */
@@ -4252,8 +4242,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
                );
                goto trie_first_try; /* jump into the fail handler */
            }}
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
        case TRIE_next_fail: /* we failed - try next alternative */
         {
@@ -4367,8 +4356,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
 
            if (ST.accepted > 1 || has_cutgroup) {
                PUSH_STATE_GOTO(TRIE_next, scan, (char*)uc);
-               /* NOTREACHED */
-               assert(0);
+               assert(0); /* NOTREACHED */
            }
            /* only one choice left - just continue */
            DEBUG_EXECUTE_r({
@@ -4392,8 +4380,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
 
            locinput = (char*)uc;
            continue; /* execute rest of RE */
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
         }
 #undef  ST
 
@@ -5202,8 +5189,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
             /* and then jump to the code we share with EVAL */
             goto eval_recurse_doit;
 
-            /* NOTREACHED */
-            assert(0);
+            assert(0); /* NOTREACHED */
 
         case EVAL:  /*   /(?{A})B/   /(??{A})B/  and /(?(?{A})X|Y)B/   */        
             if (cur_eval && cur_eval->locinput==locinput) {
@@ -5484,8 +5470,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
                cur_eval = st;
                /* now continue from first node in postoned RE */
                PUSH_YES_STATE_GOTO(EVAL_AB, startpoint, locinput);
-               /* NOTREACHED */
-               assert(0);
+               assert(0); /* NOTREACHED */
        }
 
        case EVAL_AB: /* cleanup after a successful (??{A})B */
@@ -5744,22 +5729,19 @@ NULL
            ST.lastloc = NULL;  /* this will be updated by WHILEM */
 
            PUSH_YES_STATE_GOTO(CURLYX_end, PREVOPER(next), locinput);
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
        }
 
        case CURLYX_end: /* just finished matching all of A*B */
            cur_curlyx = ST.prev_curlyx;
            sayYES;
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
        case CURLYX_end_fail: /* just failed to match all of A*B */
            regcpblow(ST.cp);
            cur_curlyx = ST.prev_curlyx;
            sayNO;
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
 
 #undef ST
@@ -5794,8 +5776,7 @@ NULL
                REGCP_SET(ST.lastcp);
 
                PUSH_STATE_GOTO(WHILEM_A_pre, A, locinput);
-               /* NOTREACHED */
-               assert(0);
+               assert(0); /* NOTREACHED */
            }
 
            /* If degenerate A matches "", assume A done. */
@@ -5907,8 +5888,7 @@ NULL
                REGCP_SET(ST.lastcp);
                PUSH_YES_STATE_GOTO(WHILEM_B_min, ST.save_curlyx->u.curlyx.B,
                                     locinput);
-               /* NOTREACHED */
-               assert(0);
+               assert(0); /* NOTREACHED */
            }
 
            /* Prefer A over B for maximal matching. */
@@ -5919,28 +5899,24 @@ NULL
                cur_curlyx->u.curlyx.lastloc = locinput;
                REGCP_SET(ST.lastcp);
                PUSH_STATE_GOTO(WHILEM_A_max, A, locinput);
-               /* NOTREACHED */
-               assert(0);
+               assert(0); /* NOTREACHED */
            }
            goto do_whilem_B_max;
        }
-       /* NOTREACHED */
-       assert(0);
+       assert(0); /* NOTREACHED */
 
        case WHILEM_B_min: /* just matched B in a minimal match */
        case WHILEM_B_max: /* just matched B in a maximal match */
            cur_curlyx = ST.save_curlyx;
            sayYES;
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
        case WHILEM_B_max_fail: /* just failed to match B in a maximal match */
            cur_curlyx = ST.save_curlyx;
            cur_curlyx->u.curlyx.lastloc = ST.save_lastloc;
            cur_curlyx->u.curlyx.count--;
            CACHEsayNO;
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
        case WHILEM_A_min_fail: /* just failed to match A in a minimal match */
            /* FALLTHROUGH */
@@ -5950,8 +5926,7 @@ NULL
            cur_curlyx->u.curlyx.lastloc = ST.save_lastloc;
            cur_curlyx->u.curlyx.count--;
            CACHEsayNO;
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
        case WHILEM_A_max_fail: /* just failed to match A in a maximal match */
            REGCP_UNWIND(ST.lastcp);
@@ -5977,8 +5952,7 @@ NULL
            cur_curlyx = cur_curlyx->u.curlyx.prev_curlyx;
            PUSH_YES_STATE_GOTO(WHILEM_B_max, ST.save_curlyx->u.curlyx.B,
                                 locinput);
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
        case WHILEM_B_min_fail: /* just failed to match B in a minimal match */
            cur_curlyx = ST.save_curlyx;
@@ -6012,8 +5986,7 @@ NULL
            PUSH_STATE_GOTO(WHILEM_A_min,
                /*A*/ NEXTOPER(ST.save_curlyx->u.curlyx.me) + EXTRA_STEP_2ARGS,
                 locinput);
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
 #undef  ST
 #define ST st->u.branch
@@ -6038,15 +6011,13 @@ NULL
            } else {
                PUSH_STATE_GOTO(BRANCH_next, scan, locinput);
            }
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
         case CUTGROUP:  /*  /(*THEN)/  */
             sv_yes_mark = st->u.mark.mark_name = scan->flags ? NULL :
                 MUTABLE_SV(rexi->data->data[ ARG( scan ) ]);
             PUSH_STATE_GOTO(CUTGROUP_next, next, locinput);
-            /* NOTREACHED */
-            assert(0);
+            assert(0); /* NOTREACHED */
 
         case CUTGROUP_next_fail:
             do_cutgroup = 1;
@@ -6054,13 +6025,11 @@ NULL
             if (st->u.mark.mark_name)
                 sv_commit = st->u.mark.mark_name;
             sayNO;         
-            /* NOTREACHED */
-            assert(0);
+            assert(0); /* NOTREACHED */
 
         case BRANCH_next:
             sayYES;
-            /* NOTREACHED */
-            assert(0);
+            assert(0); /* NOTREACHED */
 
        case BRANCH_next_fail: /* that branch failed; try the next, if any */
            if (do_cutgroup) {
@@ -6082,8 +6051,7 @@ NULL
                sayNO_SILENT;
             }
            continue; /* execute next BRANCH[J] op */
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
     
        case MINMOD: /* next op will be non-greedy, e.g. A*?  */
            minmod = 1;
@@ -6127,8 +6095,7 @@ NULL
 
          curlym_do_A: /* execute the A in /A{m,n}B/  */
            PUSH_YES_STATE_GOTO(CURLYM_A, ST.A, locinput); /* match A */
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
        case CURLYM_A: /* we've just matched an A */
            ST.count++;
@@ -6263,8 +6230,7 @@ NULL
            }
            
            PUSH_STATE_GOTO(CURLYM_B, ST.B, locinput); /* match B */
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
        case CURLYM_B_fail: /* just failed to match a B */
            REGCP_UNWIND(ST.cp);
@@ -6442,8 +6408,7 @@ NULL
                REGCP_SET(ST.cp);
                goto curly_try_B_max;
            }
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
 
        case CURLY_B_min_known_fail:
@@ -6519,8 +6484,7 @@ NULL
                }
                PUSH_STATE_GOTO(CURLY_B_min_known, ST.B, locinput);
            }
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
 
        case CURLY_B_min_fail:
@@ -6553,8 +6517,7 @@ NULL
                }
            }
             sayNO;
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
 
        curly_try_B_max:
@@ -6585,8 +6548,7 @@ NULL
                 if (ST.c1 == CHRTEST_VOID || could_match) {
                    CURLY_SETPAREN(ST.paren, ST.count);
                    PUSH_STATE_GOTO(CURLY_B_max, ST.B, locinput);
-                   /* NOTREACHED */
-                   assert(0);
+                   assert(0); /* NOTREACHED */
                }
            }
            /* FALLTHROUGH */
@@ -6705,8 +6667,7 @@ NULL
            
            /* execute body of (?...A) */
            PUSH_YES_STATE_GOTO(IFMATCH_A, NEXTOPER(NEXTOPER(scan)), newstart);
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
         }
 
        case IFMATCH_A_fail: /* body of (?...A) failed */
@@ -6746,8 +6707,7 @@ NULL
            if (!scan->flags)
                sv_yes_mark = sv_commit = MUTABLE_SV(rexi->data->data[ ARG( scan ) ]);
            PUSH_STATE_GOTO(COMMIT_next, next, locinput);
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
        case COMMIT_next_fail:
            no_final = 1;    
@@ -6755,8 +6715,7 @@ NULL
 
        case OPFAIL:   /* (*FAIL)  */
            sayNO;
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
 
 #define ST st->u.mark
         case MARKPOINT: /*  (*MARK:foo)  */
@@ -6766,14 +6725,12 @@ NULL
             mark_state = st;
             ST.mark_loc = locinput;
             PUSH_YES_STATE_GOTO(MARKPOINT_next, next, locinput);
-            /* NOTREACHED */
-            assert(0);
+            assert(0); /* NOTREACHED */
 
         case MARKPOINT_next:
             mark_state = ST.prev_mark;
             sayYES;
-            /* NOTREACHED */
-            assert(0);
+            assert(0); /* NOTREACHED */
 
         case MARKPOINT_next_fail:
             if (popmark && sv_eq(ST.mark_name,popmark)) 
@@ -6794,8 +6751,7 @@ NULL
             sv_yes_mark = mark_state ? 
                 mark_state->u.mark.mark_name : NULL;
             sayNO;
-            /* NOTREACHED */
-            assert(0);
+            assert(0); /* NOTREACHED */
 
         case SKIP:  /*  (*SKIP)  */
             if (scan->flags) {
@@ -6840,8 +6796,7 @@ NULL
             } 
             no_final = 1; 
             sayNO;
-            /* NOTREACHED */
-            assert(0);
+            assert(0); /* NOTREACHED */
 #undef ST
 
         case LNBREAK: /* \R */
@@ -6875,8 +6830,7 @@ NULL
         /* switch break jumps here */
        scan = next; /* prepare to execute the next op and ... */
        continue;    /* ... jump back to the top, reusing st */
-       /* NOTREACHED */
-       assert(0);
+       assert(0); /* NOTREACHED */
 
       push_yes_state:
        /* push a state that backtracks on success */
@@ -6919,8 +6873,7 @@ NULL
            locinput = pushinput;
            st = newst;
            continue;
-           /* NOTREACHED */
-           assert(0);
+           assert(0); /* NOTREACHED */
        }
     }
 
@@ -7077,7 +7030,6 @@ STATIC I32
 S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p,
             regmatch_info *const reginfo, I32 max, int depth)
 {
-    dVAR;
     char *scan;     /* Pointer to current position in target string */
     I32 c;
     char *loceol = reginfo->strend;   /* local version */
@@ -7557,8 +7509,7 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p,
 
     default:
         Perl_croak(aTHX_ "panic: regrepeat() called with unrecognized node type %d='%s'", OP(p), PL_reg_name[OP(p)]);
-        /* NOTREACHED */
-        assert(0);
+        assert(0); /* NOTREACHED */
 
     }
 
@@ -7619,7 +7570,6 @@ Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog,
      *    swash are returned  (in a printable form).
      * Tied intimately to how regcomp.c sets up the data structure */
 
-    dVAR;
     SV *sw  = NULL;
     SV *si  = NULL;         /* Input swash initialization string */
     SV*  invlist = NULL;
@@ -7882,8 +7832,6 @@ S_reghop3(U8 *s, SSize_t off, const U8* lim)
      * 'off' >= 0, backwards if negative.  But don't go outside of position
      * 'lim', which better be < s  if off < 0 */
 
-    dVAR;
-
     PERL_ARGS_ASSERT_REGHOP3;
 
     if (off >= 0) {
@@ -7908,8 +7856,6 @@ S_reghop3(U8 *s, SSize_t off, const U8* lim)
 STATIC U8 *
 S_reghop4(U8 *s, SSize_t off, const U8* llim, const U8* rlim)
 {
-    dVAR;
-
     PERL_ARGS_ASSERT_REGHOP4;
 
     if (off >= 0) {
@@ -7937,8 +7883,6 @@ S_reghop4(U8 *s, SSize_t off, const U8* llim, const U8* rlim)
 STATIC U8 *
 S_reghopmaybe3(U8* s, SSize_t off, const U8* lim)
 {
-    dVAR;
-
     PERL_ARGS_ASSERT_REGHOPMAYBE3;
 
     if (off >= 0) {
@@ -8055,7 +7999,6 @@ S_setup_eval_state(pTHX_ regmatch_info *const reginfo)
 static void
 S_cleanup_regmatch_info_aux(pTHX_ void *arg)
 {
-    dVAR;
     regmatch_info_aux *aux = (regmatch_info_aux *) arg;
     regmatch_info_aux_eval *eval_state =  aux->info_aux_eval;
     regmatch_slab *s;
@@ -8147,7 +8090,6 @@ S_to_byte_substr(pTHX_ regexp *prog)
     /* Converts substr fields in prog from UTF-8 to bytes, calling fbm_compile
      * on the converted value; returns FALSE if can't be converted. */
 
-    dVAR;
     int i = 1;
 
     PERL_ARGS_ASSERT_TO_BYTE_SUBSTR;