summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorLukas Mai <l.mai@web.de>2014-11-29 12:37:50 +0100
committerFather Chrysostomos <sprout@cpan.org>2014-11-29 06:05:16 -0800
commite59642234eb8b658c16fed728636bfbbc49c4514 (patch)
tree3387394bff0e7e2f7ac09564be7493e6a71619d2 /regexec.c
parentb7bea5dafa8e0cb5ca70b7525fbd6b51eb723815 (diff)
downloadperl-e59642234eb8b658c16fed728636bfbbc49c4514.tar.gz
make more use of NOT_REACHED
In particular, remove all instances of 'assert(0);'.
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c85
1 files changed, 40 insertions, 45 deletions
diff --git a/regexec.c b/regexec.c
index e74ca18e4c..b7b1d293d4 100644
--- a/regexec.c
+++ b/regexec.c
@@ -485,7 +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);
}
- assert(0); /* NOTREACHED */
+ NOT_REACHED; /* NOTREACHED */
return FALSE;
}
@@ -2047,7 +2047,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);
- assert(0); /* NOTREACHED */
+ NOT_REACHED; /* NOTREACHED */
}
}
break;
@@ -3844,7 +3844,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));
- assert(0); /* NOTREACHED */
+ NOT_REACHED; /* NOTREACHED */
}
}
}
@@ -4037,14 +4037,14 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
rex->offs[0].start = locinput - reginfo->strbeg;
PUSH_STATE_GOTO(KEEPS_next, next, locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case KEEPS_next_fail:
/* rollback the start point change */
rex->offs[0].start = st->u.keeper.val;
sayNO_SILENT;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case MEOL: /* /..$/m */
if (!NEXTCHR_IS_EOS && nextchr != '\n')
@@ -4094,7 +4094,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
);
sayNO_SILENT;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
}
/* FALLTHROUGH */
case TRIE: /* (ab|cd) */
@@ -4282,7 +4282,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
goto trie_first_try; /* jump into the fail handler */
}}
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case TRIE_next_fail: /* we failed - try next alternative */
{
@@ -4397,7 +4397,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);
+ NOT_REACHED;
}
/* only one choice left - just continue */
DEBUG_EXECUTE_r({
@@ -4422,7 +4422,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
locinput = (char*)uc;
continue; /* execute rest of RE */
/* NOTREACHED */
- assert(0);
}
#undef ST
@@ -5227,9 +5226,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);
case EVAL: /* /(?{A})B/ /(??{A})B/ and /(?(?{A})X|Y)B/ */
if (cur_eval && cur_eval->locinput==locinput) {
@@ -5511,7 +5508,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, char *startpos, regnode *prog)
/* now continue from first node in postoned RE */
PUSH_YES_STATE_GOTO(EVAL_AB, startpoint, locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
}
case EVAL_AB: /* cleanup after a successful (??{A})B */
@@ -5771,21 +5768,21 @@ NULL
PUSH_YES_STATE_GOTO(CURLYX_end, PREVOPER(next), locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
}
case CURLYX_end: /* just finished matching all of A*B */
cur_curlyx = ST.prev_curlyx;
sayYES;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case CURLYX_end_fail: /* just failed to match all of A*B */
regcpblow(ST.cp);
cur_curlyx = ST.prev_curlyx;
sayNO;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
#undef ST
@@ -5824,7 +5821,7 @@ NULL
PUSH_STATE_GOTO(WHILEM_A_pre, A, locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
}
/* If degenerate A matches "", assume A done. */
@@ -5937,7 +5934,7 @@ NULL
PUSH_YES_STATE_GOTO(WHILEM_B_min, ST.save_curlyx->u.curlyx.B,
locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
}
/* Prefer A over B for maximal matching. */
@@ -5949,19 +5946,19 @@ NULL
REGCP_SET(ST.lastcp);
PUSH_STATE_GOTO(WHILEM_A_max, A, locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
}
goto do_whilem_B_max;
}
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
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);
+ NOT_REACHED;
case WHILEM_B_max_fail: /* just failed to match B in a maximal match */
cur_curlyx = ST.save_curlyx;
@@ -5969,7 +5966,7 @@ NULL
cur_curlyx->u.curlyx.count--;
CACHEsayNO;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case WHILEM_A_min_fail: /* just failed to match A in a minimal match */
/* FALLTHROUGH */
@@ -5980,7 +5977,7 @@ NULL
cur_curlyx->u.curlyx.count--;
CACHEsayNO;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case WHILEM_A_max_fail: /* just failed to match A in a maximal match */
REGCP_UNWIND(ST.lastcp);
@@ -6007,7 +6004,7 @@ NULL
PUSH_YES_STATE_GOTO(WHILEM_B_max, ST.save_curlyx->u.curlyx.B,
locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case WHILEM_B_min_fail: /* just failed to match B in a minimal match */
cur_curlyx = ST.save_curlyx;
@@ -6042,7 +6039,7 @@ NULL
/*A*/ NEXTOPER(ST.save_curlyx->u.curlyx.me) + EXTRA_STEP_2ARGS,
locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
#undef ST
#define ST st->u.branch
@@ -6068,14 +6065,14 @@ NULL
PUSH_STATE_GOTO(BRANCH_next, scan, locinput);
}
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
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);
+ NOT_REACHED;
case CUTGROUP_next_fail:
do_cutgroup = 1;
@@ -6084,12 +6081,12 @@ NULL
sv_commit = st->u.mark.mark_name;
sayNO;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case BRANCH_next:
sayYES;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case BRANCH_next_fail: /* that branch failed; try the next, if any */
if (do_cutgroup) {
@@ -6112,7 +6109,6 @@ NULL
}
continue; /* execute next BRANCH[J] op */
/* NOTREACHED */
- assert(0);
case MINMOD: /* next op will be non-greedy, e.g. A*? */
minmod = 1;
@@ -6157,7 +6153,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);
+ NOT_REACHED;
case CURLYM_A: /* we've just matched an A */
ST.count++;
@@ -6294,7 +6290,7 @@ NULL
PUSH_STATE_GOTO(CURLYM_B, ST.B, locinput); /* match B */
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case CURLYM_B_fail: /* just failed to match a B */
REGCP_UNWIND(ST.cp);
@@ -6473,7 +6469,7 @@ NULL
goto curly_try_B_max;
}
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case CURLY_B_min_known_fail:
/* failed to find B in a non-greedy match where c1,c2 valid */
@@ -6549,7 +6545,7 @@ NULL
PUSH_STATE_GOTO(CURLY_B_min_known, ST.B, locinput);
}
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case CURLY_B_min_fail:
/* failed to find B in a non-greedy match where c1,c2 invalid */
@@ -6582,7 +6578,7 @@ NULL
}
sayNO;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
curly_try_B_max:
/* a successful greedy match: now try to match B */
@@ -6613,7 +6609,7 @@ NULL
CURLY_SETPAREN(ST.paren, ST.count);
PUSH_STATE_GOTO(CURLY_B_max, ST.B, locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
}
}
/* FALLTHROUGH */
@@ -6733,7 +6729,7 @@ NULL
/* execute body of (?...A) */
PUSH_YES_STATE_GOTO(IFMATCH_A, NEXTOPER(NEXTOPER(scan)), newstart);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
}
case IFMATCH_A_fail: /* body of (?...A) failed */
@@ -6774,7 +6770,7 @@ NULL
sv_yes_mark = sv_commit = MUTABLE_SV(rexi->data->data[ ARG( scan ) ]);
PUSH_STATE_GOTO(COMMIT_next, next, locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case COMMIT_next_fail:
no_final = 1;
@@ -6783,7 +6779,7 @@ NULL
case OPFAIL: /* (*FAIL) */
sayNO;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
#define ST st->u.mark
case MARKPOINT: /* (*MARK:foo) */
@@ -6794,13 +6790,13 @@ NULL
ST.mark_loc = locinput;
PUSH_YES_STATE_GOTO(MARKPOINT_next, next, locinput);
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case MARKPOINT_next:
mark_state = ST.prev_mark;
sayYES;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case MARKPOINT_next_fail:
if (popmark && sv_eq(ST.mark_name,popmark))
@@ -6822,7 +6818,7 @@ NULL
mark_state->u.mark.mark_name : NULL;
sayNO;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
case SKIP: /* (*SKIP) */
if (scan->flags) {
@@ -6868,7 +6864,7 @@ NULL
no_final = 1;
sayNO;
/* NOTREACHED */
- assert(0);
+ NOT_REACHED;
#undef ST
case LNBREAK: /* \R */
@@ -6903,7 +6899,6 @@ NULL
scan = next; /* prepare to execute the next op and ... */
continue; /* ... jump back to the top, reusing st */
/* NOTREACHED */
- assert(0);
push_yes_state:
/* push a state that backtracks on success */
@@ -6947,7 +6942,6 @@ NULL
st = newst;
continue;
/* NOTREACHED */
- assert(0);
}
}
@@ -6958,6 +6952,7 @@ NULL
Perl_croak(aTHX_ "corrupted regexp pointers");
/* NOTREACHED */
sayNO;
+ NOT_REACHED;
yes:
if (yes_state) {
@@ -7584,7 +7579,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);
+ NOT_REACHED;
}