summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-26 08:31:27 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-26 08:31:27 (GMT)
commit9ed1d63f41e67b1a2c50171ba9fc99a9b90e93c4 (patch)
treea55f5b8aff31a6765dd5c8514f523d420d3c12a1 /regexec.c
parent360b98355e08c455d627c31c5f63bdda75fe8de2 (diff)
* regcomp.c, regenc.c, regexec.c, regint.h, enc/unicode.c:
Merge Onigmo 58fa099ed1a34367de67fb3d06dd48d076839692 + https://github.com/k-takata/Onigmo/pull/52 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c722
1 files changed, 424 insertions, 298 deletions
diff --git a/regexec.c b/regexec.c
index 299c316..8c752e1 100644
--- a/regexec.c
+++ b/regexec.c
@@ -1401,34 +1401,224 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
best_len = ONIG_MISMATCH;
s = (UChar* )sstart;
pkeep = (UChar* )sstart;
- while (1) {
+
+
#ifdef ONIG_DEBUG_MATCH
- if (s) {
- UChar *q, *bp, buf[50];
- int len;
- fprintf(stderr, "%4"PRIdPTR"> \"", (*p == OP_FINISH) ? (ptrdiff_t )-1 : s - str);
- bp = buf;
- q = s;
- if (*p != OP_FINISH) { /* s may not be a valid pointer if OP_FINISH. */
- for (i = 0; i < 7 && q < end; i++) {
- len = enclen(encode, q, end);
- while (len-- > 0) *bp++ = *q++;
- }
- }
- if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; }
- else { xmemcpy(bp, "\"", 1); bp += 1; }
- *bp = 0;
- fputs((char* )buf, stderr);
- for (i = 0; i < 20 - (bp - buf); i++) fputc(' ', stderr);
- fprintf(stderr, "%4"PRIdPTR":", (p == FinishCode) ? (ptrdiff_t )-1 : p - reg->p);
- onig_print_compiled_byte_code(stderr, p, p + strlen((char *)p), NULL, encode);
- fprintf(stderr, "\n");
+#define OPCODE_EXEC_HOOK \
+ if (s) { \
+ UChar *q, *bp, buf[50]; \
+ int len; \
+ fprintf(stderr, "%4"PRIdPTR"> \"", (*p == OP_FINISH) ? (ptrdiff_t )-1 : s - str); \
+ bp = buf; \
+ q = s; \
+ if (*p != OP_FINISH) { /* s may not be a valid pointer if OP_FINISH. */ \
+ for (i = 0; i < 7 && q < end; i++) { \
+ len = enclen(encode, q, end); \
+ while (len-- > 0) *bp++ = *q++; \
+ } \
+ } \
+ if (q < end) { xmemcpy(bp, "...\"", 4); bp += 4; } \
+ else { xmemcpy(bp, "\"", 1); bp += 1; } \
+ *bp = 0; \
+ fputs((char* )buf, stderr); \
+ for (i = 0; i < 20 - (bp - buf); i++) fputc(' ', stderr); \
+ fprintf(stderr, "%4"PRIdPTR":", (p == FinishCode) ? (ptrdiff_t )-1 : p - reg->p); \
+ onig_print_compiled_byte_code(stderr, p, p + strlen((char *)p),NULL, encode); \
+ fprintf(stderr, "\n"); \
}
+#else
+#define OPCODE_EXEC_HOOK ((void) 0)
+#endif
+
+
+#if USE_DIRECT_THREADED_VM
+#define VM_LOOP JUMP;
+#define VM_LOOP_END
+#define CASE(x) L_##x: sbegin = s; OPCODE_EXEC_HOOK;
+#define DEFAULT L_DEFAULT:
+#define NEXT sprev = sbegin; JUMP
+#define JUMP goto *oplabels[*p++]
+
+static void *oplabels[] = {
+ &&L_OP_FINISH , /* matching process terminator (no more alternative) */
+ &&L_OP_END, /* pattern code terminator (success end) */
+
+ &&L_OP_EXACT1, /* single byte, N = 1 */
+ &&L_OP_EXACT2, /* single byte, N = 2 */
+ &&L_OP_EXACT3, /* single byte, N = 3 */
+ &&L_OP_EXACT4, /* single byte, N = 4 */
+ &&L_OP_EXACT5, /* single byte, N = 5 */
+ &&L_OP_EXACTN, /* single byte */
+ &&L_OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
+ &&L_OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
+ &&L_OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
+ &&L_OP_EXACTMB2N, /* mb-length = 2 */
+ &&L_OP_EXACTMB3N, /* mb-length = 3 */
+ &&L_OP_EXACTMBN, /* other length */
+
+ &&L_OP_EXACT1_IC, /* single byte, N = 1, ignore case */
+ &&L_OP_EXACTN_IC, /* single byte, ignore case */
+
+ &&L_OP_CCLASS,
+ &&L_OP_CCLASS_MB,
+ &&L_OP_CCLASS_MIX,
+ &&L_OP_CCLASS_NOT,
+ &&L_OP_CCLASS_MB_NOT,
+ &&L_OP_CCLASS_MIX_NOT,
+ &&L_OP_CCLASS_NODE, /* pointer to CClassNode node */
+
+ &&L_OP_ANYCHAR, /* "." */
+ &&L_OP_ANYCHAR_ML, /* "." multi-line */
+ &&L_OP_ANYCHAR_STAR, /* ".*" */
+ &&L_OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
+ &&L_OP_ANYCHAR_STAR_PEEK_NEXT,
+ &&L_OP_ANYCHAR_ML_STAR_PEEK_NEXT,
+
+ &&L_OP_WORD,
+ &&L_OP_NOT_WORD,
+ &&L_OP_WORD_BOUND,
+ &&L_OP_NOT_WORD_BOUND,
+#ifdef USE_WORD_BEGIN_END
+ &&L_OP_WORD_BEGIN,
+ &&L_OP_WORD_END,
+#else
+ &&L_DEFAULT,
+ &&L_DEFAULT,
+#endif
+ &&L_OP_ASCII_WORD,
+ &&L_OP_NOT_ASCII_WORD,
+ &&L_OP_ASCII_WORD_BOUND,
+ &&L_OP_NOT_ASCII_WORD_BOUND,
+#ifdef USE_WORD_BEGIN_END
+ &&L_OP_ASCII_WORD_BEGIN,
+ &&L_OP_ASCII_WORD_END,
+#else
+ &&L_DEFAULT,
+ &&L_DEFAULT,
#endif
- sbegin = s;
- switch (*p++) {
- case OP_END: MOP_IN(OP_END);
+ &&L_OP_BEGIN_BUF,
+ &&L_OP_END_BUF,
+ &&L_OP_BEGIN_LINE,
+ &&L_OP_END_LINE,
+ &&L_OP_SEMI_END_BUF,
+ &&L_OP_BEGIN_POSITION,
+ &&L_OP_BEGIN_POS_OR_LINE, /* used for implicit anchor optimization */
+
+ &&L_OP_BACKREF1,
+ &&L_OP_BACKREF2,
+ &&L_OP_BACKREFN,
+ &&L_OP_BACKREFN_IC,
+ &&L_OP_BACKREF_MULTI,
+ &&L_OP_BACKREF_MULTI_IC,
+#ifdef USE_BACKREF_WITH_LEVEL
+ &&L_OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
+#else
+ &&L_DEFAULT,
+#endif
+ &&L_OP_MEMORY_START,
+ &&L_OP_MEMORY_START_PUSH, /* push back-tracker to stack */
+ &&L_OP_MEMORY_END_PUSH, /* push back-tracker to stack */
+#ifdef USE_SUBEXP_CALL
+ &&L_OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
+#else
+ &&L_DEFAULT,
+#endif
+ &&L_OP_MEMORY_END,
+#ifdef USE_SUBEXP_CALL
+ &&L_OP_MEMORY_END_REC, /* push marker to stack */
+#else
+ &&L_DEFAULT,
+#endif
+
+ &&L_OP_KEEP,
+
+ &&L_OP_FAIL, /* pop stack and move */
+ &&L_OP_JUMP,
+ &&L_OP_PUSH,
+ &&L_OP_POP,
+ &&L_OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
+ &&L_OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
+ &&L_OP_REPEAT, /* {n,m} */
+ &&L_OP_REPEAT_NG, /* {n,m}? (non greedy) */
+ &&L_OP_REPEAT_INC,
+ &&L_OP_REPEAT_INC_NG, /* non greedy */
+ &&L_OP_REPEAT_INC_SG, /* search and get in stack */
+ &&L_OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
+ &&L_OP_NULL_CHECK_START, /* null loop checker start */
+ &&L_OP_NULL_CHECK_END, /* null loop checker end */
+#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
+ &&L_OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
+#else
+ &&L_DEFAULT,
+#endif
+#ifdef USE_SUBEXP_CALL
+ &&L_OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
+#else
+ &&L_DEFAULT,
+#endif
+
+ &&L_OP_PUSH_POS, /* (?=...) start */
+ &&L_OP_POP_POS, /* (?=...) end */
+ &&L_OP_PUSH_POS_NOT, /* (?!...) start */
+ &&L_OP_FAIL_POS, /* (?!...) end */
+ &&L_OP_PUSH_STOP_BT, /* (?>...) start */
+ &&L_OP_POP_STOP_BT, /* (?>...) end */
+ &&L_OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
+ &&L_OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
+ &&L_OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end */
+
+#ifdef USE_SUBEXP_CALL
+ &&L_OP_CALL, /* \g<name> */
+ &&L_OP_RETURN,
+#else
+ &&L_DEFAULT,
+ &&L_DEFAULT,
+#endif
+ &&L_OP_CONDITION,
+
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+ &&L_OP_STATE_CHECK_PUSH, /* combination explosion check and push */
+ &&L_OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */
+ &&L_OP_STATE_CHECK, /* check only */
+#else
+ &&L_DEFAULT,
+ &&L_DEFAULT,
+ &&L_DEFAULT,
+#endif
+#ifdef USE_COMBINATION_EXPLOSION_CHECK
+ &&L_OP_STATE_CHECK_ANYCHAR_STAR,
+ &&L_OP_STATE_CHECK_ANYCHAR_ML_STAR,
+#else
+ &&L_DEFAULT,
+ &&L_DEFAULT,
+#endif
+ /* no need: IS_DYNAMIC_OPTION() == 0 */
+#if 0 /* no need: IS_DYNAMIC_OPTION() == 0 */
+ &&L_OP_SET_OPTION_PUSH, /* set option and push recover option */
+ &&L_OP_SET_OPTION /* set option */
+#else
+ &&L_DEFAULT,
+ &&L_DEFAULT
+#endif
+ };
+#else
+
+#define VM_LOOP \
+ while (1) { \
+ OPCODE_EXEC_HOOK; \
+ sbegin = s; \
+ switch (*p++) {
+#define VM_LOOP_END } sprev = sbegin; }
+#define CASE(x) case x:
+#define DEFAULT default:
+#define NEXT break
+#define JUMP continue; break
+#endif
+
+
+ VM_LOOP {
+ CASE(OP_END) MOP_IN(OP_END);
n = s - sstart;
if (n > best_len) {
OnigRegion* region;
@@ -1537,9 +1727,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
/* default behavior: return first-matching result. */
goto finish;
- break;
+ NEXT;
- case OP_EXACT1: MOP_IN(OP_EXACT1);
+ CASE(OP_EXACT1) MOP_IN(OP_EXACT1);
#if 0
DATA_ENSURE(1);
if (*p != *s) goto fail;
@@ -1549,9 +1739,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
DATA_ENSURE(0);
p++;
MOP_OUT;
- break;
+ NEXT;
- case OP_EXACT1_IC: MOP_IN(OP_EXACT1_IC);
+ CASE(OP_EXACT1_IC) MOP_IN(OP_EXACT1_IC);
{
int len;
UChar *q, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
@@ -1571,9 +1761,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
}
MOP_OUT;
- break;
+ NEXT;
- case OP_EXACT2: MOP_IN(OP_EXACT2);
+ CASE(OP_EXACT2) MOP_IN(OP_EXACT2);
DATA_ENSURE(2);
if (*p != *s) goto fail;
p++; s++;
@@ -1581,10 +1771,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
sprev = s;
p++; s++;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACT3: MOP_IN(OP_EXACT3);
+ CASE(OP_EXACT3) MOP_IN(OP_EXACT3);
DATA_ENSURE(3);
if (*p != *s) goto fail;
p++; s++;
@@ -1594,10 +1783,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
sprev = s;
p++; s++;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACT4: MOP_IN(OP_EXACT4);
+ CASE(OP_EXACT4) MOP_IN(OP_EXACT4);
DATA_ENSURE(4);
if (*p != *s) goto fail;
p++; s++;
@@ -1609,10 +1797,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
sprev = s;
p++; s++;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACT5: MOP_IN(OP_EXACT5);
+ CASE(OP_EXACT5) MOP_IN(OP_EXACT5);
DATA_ENSURE(5);
if (*p != *s) goto fail;
p++; s++;
@@ -1626,10 +1813,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
sprev = s;
p++; s++;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACTN: MOP_IN(OP_EXACTN);
+ CASE(OP_EXACTN) MOP_IN(OP_EXACTN);
GET_LENGTH_INC(tlen, p);
DATA_ENSURE(tlen);
while (tlen-- > 0) {
@@ -1637,10 +1823,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
sprev = s - 1;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACTN_IC: MOP_IN(OP_EXACTN_IC);
+ CASE(OP_EXACTN_IC) MOP_IN(OP_EXACTN_IC);
{
int len;
UChar *q, *endp, lowbuf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
@@ -1665,19 +1850,18 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACTMB2N1: MOP_IN(OP_EXACTMB2N1);
+ CASE(OP_EXACTMB2N1) MOP_IN(OP_EXACTMB2N1);
DATA_ENSURE(2);
if (*p != *s) goto fail;
p++; s++;
if (*p != *s) goto fail;
p++; s++;
MOP_OUT;
- break;
+ NEXT;
- case OP_EXACTMB2N2: MOP_IN(OP_EXACTMB2N2);
+ CASE(OP_EXACTMB2N2) MOP_IN(OP_EXACTMB2N2);
DATA_ENSURE(4);
if (*p != *s) goto fail;
p++; s++;
@@ -1689,10 +1873,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (*p != *s) goto fail;
p++; s++;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACTMB2N3: MOP_IN(OP_EXACTMB2N3);
+ CASE(OP_EXACTMB2N3) MOP_IN(OP_EXACTMB2N3);
DATA_ENSURE(6);
if (*p != *s) goto fail;
p++; s++;
@@ -1708,10 +1891,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (*p != *s) goto fail;
p++; s++;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACTMB2N: MOP_IN(OP_EXACTMB2N);
+ CASE(OP_EXACTMB2N) MOP_IN(OP_EXACTMB2N);
GET_LENGTH_INC(tlen, p);
DATA_ENSURE(tlen * 2);
while (tlen-- > 0) {
@@ -1722,10 +1904,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
sprev = s - 2;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACTMB3N: MOP_IN(OP_EXACTMB3N);
+ CASE(OP_EXACTMB3N) MOP_IN(OP_EXACTMB3N);
GET_LENGTH_INC(tlen, p);
DATA_ENSURE(tlen * 3);
while (tlen-- > 0) {
@@ -1738,10 +1919,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
sprev = s - 3;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_EXACTMBN: MOP_IN(OP_EXACTMBN);
+ CASE(OP_EXACTMBN) MOP_IN(OP_EXACTMBN);
GET_LENGTH_INC(tlen, p); /* mb-len */
GET_LENGTH_INC(tlen2, p); /* string len */
tlen2 *= tlen;
@@ -1752,18 +1932,17 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
sprev = s - tlen;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_CCLASS: MOP_IN(OP_CCLASS);
+ CASE(OP_CCLASS) MOP_IN(OP_CCLASS);
DATA_ENSURE(1);
if (BITSET_AT(((BitSetRef )p), *s) == 0) goto fail;
p += SIZE_BITSET;
s += enclen(encode, s, end); /* OP_CCLASS can match mb-code. \D, \S */
MOP_OUT;
- break;
+ NEXT;
- case OP_CCLASS_MB: MOP_IN(OP_CCLASS_MB);
+ CASE(OP_CCLASS_MB) MOP_IN(OP_CCLASS_MB);
if (! ONIGENC_IS_MBC_HEAD(encode, s, end)) goto fail;
cclass_mb:
@@ -1790,9 +1969,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
p += tlen;
MOP_OUT;
- break;
+ NEXT;
- case OP_CCLASS_MIX: MOP_IN(OP_CCLASS_MIX);
+ CASE(OP_CCLASS_MIX) MOP_IN(OP_CCLASS_MIX);
DATA_ENSURE(1);
if (ONIGENC_IS_MBC_HEAD(encode, s, end)) {
p += SIZE_BITSET;
@@ -1808,17 +1987,17 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
s++;
}
MOP_OUT;
- break;
+ NEXT;
- case OP_CCLASS_NOT: MOP_IN(OP_CCLASS_NOT);
+ CASE(OP_CCLASS_NOT) MOP_IN(OP_CCLASS_NOT);
DATA_ENSURE(1);
if (BITSET_AT(((BitSetRef )p), *s) != 0) goto fail;
p += SIZE_BITSET;
s += enclen(encode, s, end);
MOP_OUT;
- break;
+ NEXT;
- case OP_CCLASS_MB_NOT: MOP_IN(OP_CCLASS_MB_NOT);
+ CASE(OP_CCLASS_MB_NOT) MOP_IN(OP_CCLASS_MB_NOT);
DATA_ENSURE(1);
if (! ONIGENC_IS_MBC_HEAD(encode, s, end)) {
s++;
@@ -1857,9 +2036,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
cc_mb_not_success:
MOP_OUT;
- break;
+ NEXT;
- case OP_CCLASS_MIX_NOT: MOP_IN(OP_CCLASS_MIX_NOT);
+ CASE(OP_CCLASS_MIX_NOT) MOP_IN(OP_CCLASS_MIX_NOT);
DATA_ENSURE(1);
if (ONIGENC_IS_MBC_HEAD(encode, s, end)) {
p += SIZE_BITSET;
@@ -1875,9 +2054,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
s++;
}
MOP_OUT;
- break;
+ NEXT;
- case OP_CCLASS_NODE: MOP_IN(OP_CCLASS_NODE);
+ CASE(OP_CCLASS_NODE) MOP_IN(OP_CCLASS_NODE);
{
OnigCodePoint code;
void *node;
@@ -1894,26 +2073,26 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
if (onig_is_code_in_cc_len(mb_len, code, node) == 0) goto fail;
}
MOP_OUT;
- break;
+ NEXT;
- case OP_ANYCHAR: MOP_IN(OP_ANYCHAR);
+ CASE(OP_ANYCHAR) MOP_IN(OP_ANYCHAR);
DATA_ENSURE(1);
n = enclen(encode, s, end);
DATA_ENSURE(n);
if (ONIGENC_IS_MBC_NEWLINE_EX(encode, s, str, end, option, 0)) goto fail;
s += n;
MOP_OUT;
- break;
+ NEXT;
- case OP_ANYCHAR_ML: MOP_IN(OP_ANYCHAR_ML);
+ CASE(OP_ANYCHAR_ML) MOP_IN(OP_ANYCHAR_ML);
DATA_ENSURE(1);
n = enclen(encode, s, end);
DATA_ENSURE(n);
s += n;
MOP_OUT;
- break;
+ NEXT;
- case OP_ANYCHAR_STAR: MOP_IN(OP_ANYCHAR_STAR);
+ CASE(OP_ANYCHAR_STAR) MOP_IN(OP_ANYCHAR_STAR);
while (DATA_ENSURE_CHECK1) {
STACK_PUSH_ALT(p, s, sprev, pkeep);
n = enclen(encode, s, end);
@@ -1923,9 +2102,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
s += n;
}
MOP_OUT;
- break;
+ NEXT;
- case OP_ANYCHAR_ML_STAR: MOP_IN(OP_ANYCHAR_ML_STAR);
+ CASE(OP_ANYCHAR_ML_STAR) MOP_IN(OP_ANYCHAR_ML_STAR);
while (DATA_ENSURE_CHECK1) {
STACK_PUSH_ALT(p, s, sprev, pkeep);
n = enclen(encode, s, end);
@@ -1940,9 +2119,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
}
MOP_OUT;
- break;
+ NEXT;
- case OP_ANYCHAR_STAR_PEEK_NEXT: MOP_IN(OP_ANYCHAR_STAR_PEEK_NEXT);
+ CASE(OP_ANYCHAR_STAR_PEEK_NEXT) MOP_IN(OP_ANYCHAR_STAR_PEEK_NEXT);
while (DATA_ENSURE_CHECK1) {
if (*p == *s) {
STACK_PUSH_ALT(p + 1, s, sprev, pkeep);
@@ -1955,9 +2134,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
p++;
MOP_OUT;
- break;
+ NEXT;
- case OP_ANYCHAR_ML_STAR_PEEK_NEXT:MOP_IN(OP_ANYCHAR_ML_STAR_PEEK_NEXT);
+ CASE(OP_ANYCHAR_ML_STAR_PEEK_NEXT)MOP_IN(OP_ANYCHAR_ML_STAR_PEEK_NEXT);
while (DATA_ENSURE_CHECK1) {
if (*p == *s) {
STACK_PUSH_ALT(p + 1, s, sprev, pkeep);
@@ -1975,10 +2154,10 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
p++;
MOP_OUT;
- break;
+ NEXT;
#ifdef USE_COMBINATION_EXPLOSION_CHECK
- case OP_STATE_CHECK_ANYCHAR_STAR: MOP_IN(OP_STATE_CHECK_ANYCHAR_STAR);
+ CASE(OP_STATE_CHECK_ANYCHAR_STAR) MOP_IN(OP_STATE_CHECK_ANYCHAR_STAR);
GET_STATE_CHECK_NUM_INC(mem, p);
while (DATA_ENSURE_CHECK1) {
STATE_CHECK_VAL(scv, mem);
@@ -1992,9 +2171,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
s += n;
}
MOP_OUT;
- break;
+ NEXT;
- case OP_STATE_CHECK_ANYCHAR_ML_STAR:
+ CASE(OP_STATE_CHECK_ANYCHAR_ML_STAR)
MOP_IN(OP_STATE_CHECK_ANYCHAR_ML_STAR);
GET_STATE_CHECK_NUM_INC(mem, p);
@@ -2015,46 +2194,46 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
}
MOP_OUT;
- break;
+ NEXT;
#endif /* USE_COMBINATION_EXPLOSION_CHECK */
- case OP_WORD: MOP_IN(OP_WORD);
+ CASE(OP_WORD) MOP_IN(OP_WORD);
DATA_ENSURE(1);
if (! ONIGENC_IS_MBC_WORD(encode, s, end))
goto fail;
s += enclen(encode, s, end);
MOP_OUT;
- break;
+ NEXT;
- case OP_ASCII_WORD: MOP_IN(OP_ASCII_WORD);
+ CASE(OP_ASCII_WORD) MOP_IN(OP_ASCII_WORD);
DATA_ENSURE(1);
if (! ONIGENC_IS_MBC_ASCII_WORD(encode, s, end))
goto fail;
s += enclen(encode, s, end);
MOP_OUT;
- break;
+ NEXT;
- case OP_NOT_WORD: MOP_IN(OP_NOT_WORD);
+ CASE(OP_NOT_WORD) MOP_IN(OP_NOT_WORD);
DATA_ENSURE(1);
if (ONIGENC_IS_MBC_WORD(encode, s, end))
goto fail;
s += enclen(encode, s, end);
MOP_OUT;
- break;
+ NEXT;
- case OP_NOT_ASCII_WORD: MOP_IN(OP_NOT_ASCII_WORD);
+ CASE(OP_NOT_ASCII_WORD) MOP_IN(OP_NOT_ASCII_WORD);
DATA_ENSURE(1);
if (ONIGENC_IS_MBC_ASCII_WORD(encode, s, end))
goto fail;
s += enclen(encode, s, end);
MOP_OUT;
- break;
+ NEXT;
- case OP_WORD_BOUND: MOP_IN(OP_WORD_BOUND);
+ CASE(OP_WORD_BOUND) MOP_IN(OP_WORD_BOUND);
if (ON_STR_BEGIN(s)) {
DATA_ENSURE(1);
if (! ONIGENC_IS_MBC_WORD(encode, s, end))
@@ -2070,10 +2249,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
goto fail;
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_ASCII_WORD_BOUND: MOP_IN(OP_ASCII_WORD_BOUND);
+ CASE(OP_ASCII_WORD_BOUND) MOP_IN(OP_ASCII_WORD_BOUND);
if (ON_STR_BEGIN(s)) {
DATA_ENSURE(1);
if (! ONIGENC_IS_MBC_ASCII_WORD(encode, s, end))
@@ -2089,10 +2267,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
goto fail;
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_NOT_WORD_BOUND: MOP_IN(OP_NOT_WORD_BOUND);
+ CASE(OP_NOT_WORD_BOUND) MOP_IN(OP_NOT_WORD_BOUND);
if (ON_STR_BEGIN(s)) {
if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD(encode, s, end))
goto fail;
@@ -2107,10 +2284,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
goto fail;
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_NOT_ASCII_WORD_BOUND: MOP_IN(OP_NOT_ASCII_WORD_BOUND);
+ CASE(OP_NOT_ASCII_WORD_BOUND) MOP_IN(OP_NOT_ASCII_WORD_BOUND);
if (ON_STR_BEGIN(s)) {
if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_ASCII_WORD(encode, s, end))
goto fail;
@@ -2125,73 +2301,70 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
goto fail;
}
MOP_OUT;
- continue;
- break;
+ JUMP;
#ifdef USE_WORD_BEGIN_END
- case OP_WORD_BEGIN: MOP_IN(OP_WORD_BEGIN);
+ CASE(OP_WORD_BEGIN) MOP_IN(OP_WORD_BEGIN);
if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD(encode, s, end)) {
if (ON_STR_BEGIN(s) || !ONIGENC_IS_MBC_WORD(encode, sprev, end)) {
MOP_OUT;
- continue;
+ JUMP;
}
}
goto fail;
- break;
+ NEXT;
- case OP_ASCII_WORD_BEGIN: MOP_IN(OP_ASCII_WORD_BEGIN);
+ CASE(OP_ASCII_WORD_BEGIN) MOP_IN(OP_ASCII_WORD_BEGIN);
if (DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_ASCII_WORD(encode, s, end)) {
if (ON_STR_BEGIN(s) || !ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end)) {
MOP_OUT;
- continue;
+ JUMP;
}
}
goto fail;
- break;
+ NEXT;
- case OP_WORD_END: MOP_IN(OP_WORD_END);
+ CASE(OP_WORD_END) MOP_IN(OP_WORD_END);
if (!ON_STR_BEGIN(s) && ONIGENC_IS_MBC_WORD(encode, sprev, end)) {
if (ON_STR_END(s) || !ONIGENC_IS_MBC_WORD(encode, s, end)) {
MOP_OUT;
- continue;
+ JUMP;
}
}
goto fail;
- break;
+ NEXT;
- case OP_ASCII_WORD_END: MOP_IN(OP_ASCII_WORD_END);
+ CASE(OP_ASCII_WORD_END) MOP_IN(OP_ASCII_WORD_END);
if (!ON_STR_BEGIN(s) && ONIGENC_IS_MBC_ASCII_WORD(encode, sprev, end)) {
if (ON_STR_END(s) || !ONIGENC_IS_MBC_ASCII_WORD(encode, s, end)) {
MOP_OUT;
- continue;
+ JUMP;
}
}
goto fail;
- break;
+ NEXT;
#endif
- case OP_BEGIN_BUF: MOP_IN(OP_BEGIN_BUF);
+ CASE(OP_BEGIN_BUF) MOP_IN(OP_BEGIN_BUF);
if (! ON_STR_BEGIN(s)) goto fail;
if (IS_NOTBOS(msa->options)) goto fail;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_END_BUF: MOP_IN(OP_END_BUF);
+ CASE(OP_END_BUF) MOP_IN(OP_END_BUF);
if (! ON_STR_END(s)) goto fail;
if (IS_NOTEOS(msa->options)) goto fail;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_BEGIN_LINE: MOP_IN(OP_BEGIN_LINE);
+ CASE(OP_BEGIN_LINE) MOP_IN(OP_BEGIN_LINE);
op_begin_line:
if (ON_STR_BEGIN(s)) {
if (IS_NOTBOL(msa->options)) goto fail;
MOP_OUT;
- continue;
+ JUMP;
}
else if (ONIGENC_IS_MBC_NEWLINE(encode, sprev, end)
#ifdef USE_CRNL_AS_LINE_TERMINATOR
@@ -2200,38 +2373,38 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
#endif
&& !ON_STR_END(s)) {
MOP_OUT;
- continue;
+ JUMP;
}
goto fail;
- break;
+ NEXT;
- case OP_END_LINE: MOP_IN(OP_END_LINE);
+ CASE(OP_END_LINE) MOP_IN(OP_END_LINE);
if (ON_STR_END(s)) {
#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
if (IS_EMPTY_STR || !ONIGENC_IS_MBC_NEWLINE_EX(encode, sprev, str, end, option, 1)) {
#endif
if (IS_NOTEOL(msa->options)) goto fail;
MOP_OUT;
- continue;
+ JUMP;
#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
}
#endif
}
else if (ONIGENC_IS_MBC_NEWLINE_EX(encode, s, str, end, option, 1)) {
MOP_OUT;
- continue;
+ JUMP;
}
goto fail;
- break;
+ NEXT;
- case OP_SEMI_END_BUF: MOP_IN(OP_SEMI_END_BUF);
+ CASE(OP_SEMI_END_BUF) MOP_IN(OP_SEMI_END_BUF);
if (ON_STR_END(s)) {
#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
if (IS_EMPTY_STR || !ONIGENC_IS_MBC_NEWLINE_EX(encode, sprev, str, end, option, 1)) {
#endif
if (IS_NOTEOL(msa->options)) goto fail;
MOP_OUT;
- continue;
+ JUMP;
#ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
}
#endif
@@ -2240,7 +2413,7 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
UChar* ss = s + enclen(encode, s, end);
if (ON_STR_END(ss)) {
MOP_OUT;
- continue;
+ JUMP;
}
#ifdef USE_CRNL_AS_LINE_TERMINATOR
else if (IS_NEWLINE_CRLF(option)
@@ -2248,75 +2421,67 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
ss += enclen(encode, ss, end);
if (ON_STR_END(ss)) {
MOP_OUT;
- continue;
+ JUMP;
}
}
#endif
}
goto fail;
- break;
+ NEXT;
- case OP_BEGIN_POSITION: MOP_IN(OP_BEGIN_POSITION);
+ CASE(OP_BEGIN_POSITION) MOP_IN(OP_BEGIN_POSITION);
if (s != msa->gpos)
goto fail;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_BEGIN_POS_OR_LINE: MOP_IN(OP_BEGIN_POS_OR_LINE);
+ CASE(OP_BEGIN_POS_OR_LINE) MOP_IN(OP_BEGIN_POS_OR_LINE);
if (s != msa->gpos)
goto op_begin_line;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_MEMORY_START_PUSH: MOP_IN(OP_MEMORY_START_PUSH);
+ CASE(OP_MEMORY_START_PUSH) MOP_IN(OP_MEMORY_START_PUSH);
GET_MEMNUM_INC(mem, p);
STACK_PUSH_MEM_START(mem, s);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_MEMORY_START: MOP_IN(OP_MEMORY_START);
+ CASE(OP_MEMORY_START) MOP_IN(OP_MEMORY_START);
GET_MEMNUM_INC(mem, p);
mem_start_stk[mem] = (OnigStackIndex )((void* )s);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_MEMORY_END_PUSH: MOP_IN(OP_MEMORY_END_PUSH);
+ CASE(OP_MEMORY_END_PUSH) MOP_IN(OP_MEMORY_END_PUSH);
GET_MEMNUM_INC(mem, p);
STACK_PUSH_MEM_END(mem, s);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_MEMORY_END: MOP_IN(OP_MEMORY_END);
+ CASE(OP_MEMORY_END) MOP_IN(OP_MEMORY_END);
GET_MEMNUM_INC(mem, p);
mem_end_stk[mem] = (OnigStackIndex )((void* )s);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_KEEP: MOP_IN(OP_KEEP);
+ CASE(OP_KEEP) MOP_IN(OP_KEEP);
pkeep = s;
MOP_OUT;
- continue;
- break;
+ JUMP;
#ifdef USE_SUBEXP_CALL
- case OP_MEMORY_END_PUSH_REC: MOP_IN(OP_MEMORY_END_PUSH_REC);
+ CASE(OP_MEMORY_END_PUSH_REC) MOP_IN(OP_MEMORY_END_PUSH_REC);
GET_MEMNUM_INC(mem, p);
STACK_GET_MEM_START(mem, stkp); /* should be before push mem-end. */
STACK_PUSH_MEM_END(mem, s);
mem_start_stk[mem] = GET_STACK_INDEX(stkp);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_MEMORY_END_REC: MOP_IN(OP_MEMORY_END_REC);
+ CASE(OP_MEMORY_END_REC) MOP_IN(OP_MEMORY_END_REC);
GET_MEMNUM_INC(mem, p);
mem_end_stk[mem] = (OnigStackIndex )((void* )s);
STACK_GET_MEM_START(mem, stkp);
@@ -2328,21 +2493,20 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
STACK_PUSH_MEM_END_MARK(mem);
MOP_OUT;
- continue;
- break;
+ JUMP;
#endif
- case OP_BACKREF1: MOP_IN(OP_BACKREF1);
+ CASE(OP_BACKREF1) MOP_IN(OP_BACKREF1);
mem = 1;
goto backref;
- break;
+ NEXT;
- case OP_BACKREF2: MOP_IN(OP_BACKREF2);
+ CASE(OP_BACKREF2) MOP_IN(OP_BACKREF2);
mem = 2;
goto backref;
- break;
+ NEXT;
- case OP_BACKREFN: MOP_IN(OP_BACKREFN);
+ CASE(OP_BACKREFN) MOP_IN(OP_BACKREFN);
GET_MEMNUM_INC(mem, p);
backref:
{
@@ -2371,11 +2535,10 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
sprev += len;
MOP_OUT;
- continue;
+ JUMP;
}
- break;
- case OP_BACKREFN_IC: MOP_IN(OP_BACKREFN_IC);
+ CASE(OP_BACKREFN_IC) MOP_IN(OP_BACKREFN_IC);
GET_MEMNUM_INC(mem, p);
{
int len;
@@ -2403,11 +2566,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
sprev += len;
MOP_OUT;
- continue;
+ JUMP;
}
- break;
+ NEXT;
- case OP_BACKREF_MULTI: MOP_IN(OP_BACKREF_MULTI);
+ CASE(OP_BACKREF_MULTI) MOP_IN(OP_BACKREF_MULTI);
{
int len, is_fail;
UChar *pstart, *pend, *swork;
@@ -2442,11 +2605,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
if (i == tlen) goto fail;
MOP_OUT;
- continue;
+ JUMP;
}
- break;
+ NEXT;
- case OP_BACKREF_MULTI_IC: MOP_IN(OP_BACKREF_MULTI_IC);
+ CASE(OP_BACKREF_MULTI_IC) MOP_IN(OP_BACKREF_MULTI_IC);
{
int len, is_fail;
UChar *pstart, *pend, *swork;
@@ -2481,12 +2644,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
if (i == tlen) goto fail;
MOP_OUT;
- continue;
+ JUMP;
}
- break;
#ifdef USE_BACKREF_WITH_LEVEL
- case OP_BACKREF_WITH_LEVEL:
+ CASE(OP_BACKREF_WITH_LEVEL)
{
int len;
OnigOptionType ic;
@@ -2508,36 +2670,32 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
goto fail;
MOP_OUT;
- continue;
+ JUMP;
}
- break;
#endif
#if 0 /* no need: IS_DYNAMIC_OPTION() == 0 */
- case OP_SET_OPTION_PUSH: MOP_IN(OP_SET_OPTION_PUSH);
+ CASE(OP_SET_OPTION_PUSH) MOP_IN(OP_SET_OPTION_PUSH);
GET_OPTION_INC(option, p);
STACK_PUSH_ALT(p, s, sprev, pkeep);
p += SIZE_OP_SET_OPTION + SIZE_OP_FAIL;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_SET_OPTION: MOP_IN(OP_SET_OPTION);
+ CASE(OP_SET_OPTION) MOP_IN(OP_SET_OPTION);
GET_OPTION_INC(option, p);
MOP_OUT;
- continue;
- break;
+ JUMP;
#endif
- case OP_NULL_CHECK_START: MOP_IN(OP_NULL_CHECK_START);
+ CASE(OP_NULL_CHECK_START) MOP_IN(OP_NULL_CHECK_START);
GET_MEMNUM_INC(mem, p); /* mem: null check id */
STACK_PUSH_NULL_CHECK_START(mem, s);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_NULL_CHECK_END: MOP_IN(OP_NULL_CHECK_END);
+ CASE(OP_NULL_CHECK_END) MOP_IN(OP_NULL_CHECK_END);
{
int isnull;
@@ -2568,11 +2726,10 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
}
MOP_OUT;
- continue;
- break;
+ JUMP;
#ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
- case OP_NULL_CHECK_END_MEMST: MOP_IN(OP_NULL_CHECK_END_MEMST);
+ CASE(OP_NULL_CHECK_END_MEMST) MOP_IN(OP_NULL_CHECK_END_MEMST);
{
int isnull;
@@ -2588,12 +2745,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
}
MOP_OUT;
- continue;
- break;
+ JUMP;
#endif
#ifdef USE_SUBEXP_CALL
- case OP_NULL_CHECK_END_MEMST_PUSH:
+ CASE(OP_NULL_CHECK_END_MEMST_PUSH)
MOP_IN(OP_NULL_CHECK_END_MEMST_PUSH);
{
int isnull;
@@ -2617,27 +2773,24 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
}
MOP_OUT;
- continue;
- break;
+ JUMP;
#endif
- case OP_JUMP: MOP_IN(OP_JUMP);
+ CASE(OP_JUMP) MOP_IN(OP_JUMP);
GET_RELADDR_INC(addr, p);
p += addr;
MOP_OUT;
CHECK_INTERRUPT_IN_MATCH_AT;
- continue;
- break;
+ JUMP;
- case OP_PUSH: MOP_IN(OP_PUSH);
+ CASE(OP_PUSH) MOP_IN(OP_PUSH);
GET_RELADDR_INC(addr, p);
STACK_PUSH_ALT(p + addr, s, sprev, pkeep);
MOP_OUT;
- continue;
- break;
+ JUMP;
#ifdef USE_COMBINATION_EXPLOSION_CHECK
- case OP_STATE_CHECK_PUSH: MOP_IN(OP_STATE_CHECK_PUSH);
+ CASE(OP_STATE_CHECK_PUSH) MOP_IN(OP_STATE_CHECK_PUSH);
GET_STATE_CHECK_NUM_INC(mem, p);
STATE_CHECK_VAL(scv, mem);
if (scv) goto fail;
@@ -2645,10 +2798,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
GET_RELADDR_INC(addr, p);
STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem, pkeep);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_STATE_CHECK_PUSH_OR_JUMP: MOP_IN(OP_STATE_CHECK_PUSH_OR_JUMP);
+ CASE(OP_STATE_CHECK_PUSH_OR_JUMP) MOP_IN(OP_STATE_CHECK_PUSH_OR_JUMP);
GET_STATE_CHECK_NUM_INC(mem, p);
GET_RELADDR_INC(addr, p);
STATE_CHECK_VAL(scv, mem);
@@ -2659,53 +2811,48 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
STACK_PUSH_ALT_WITH_STATE_CHECK(p + addr, s, sprev, mem, pkeep);
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_STATE_CHECK: MOP_IN(OP_STATE_CHECK);
+ CASE(OP_STATE_CHECK) MOP_IN(OP_STATE_CHECK);
GET_STATE_CHECK_NUM_INC(mem, p);
STATE_CHECK_VAL(scv, mem);
if (scv) goto fail;
STACK_PUSH_STATE_CHECK(s, mem);
MOP_OUT;
- continue;
- break;
+ JUMP;
#endif /* USE_COMBINATION_EXPLOSION_CHECK */
- case OP_POP: MOP_IN(OP_POP);
+ CASE(OP_POP) MOP_IN(OP_POP);
STACK_POP_ONE;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_PUSH_OR_JUMP_EXACT1: MOP_IN(OP_PUSH_OR_JUMP_EXACT1);
+ CASE(OP_PUSH_OR_JUMP_EXACT1) MOP_IN(OP_PUSH_OR_JUMP_EXACT1);
GET_RELADDR_INC(addr, p);
if (*p == *s && DATA_ENSURE_CHECK1) {
p++;
STACK_PUSH_ALT(p + addr, s, sprev, pkeep);
MOP_OUT;
- continue;
+ JUMP;
}
p += (addr + 1);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_PUSH_IF_PEEK_NEXT: MOP_IN(OP_PUSH_IF_PEEK_NEXT);
+ CASE(OP_PUSH_IF_PEEK_NEXT) MOP_IN(OP_PUSH_IF_PEEK_NEXT);
GET_RELADDR_INC(addr, p);
if (*p == *s) {
p++;
STACK_PUSH_ALT(p + addr, s, sprev, pkeep);
MOP_OUT;
- continue;
+ JUMP;
}
p++;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_REPEAT: MOP_IN(OP_REPEAT);
+ CASE(OP_REPEAT) MOP_IN(OP_REPEAT);
{
GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
GET_RELADDR_INC(addr, p);
@@ -2719,10 +2866,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_REPEAT_NG: MOP_IN(OP_REPEAT_NG);
+ CASE(OP_REPEAT_NG) MOP_IN(OP_REPEAT_NG);
{
GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
GET_RELADDR_INC(addr, p);
@@ -2737,10 +2883,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_REPEAT_INC: MOP_IN(OP_REPEAT_INC);
+ CASE(OP_REPEAT_INC) MOP_IN(OP_REPEAT_INC);
GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
si = repeat_stk[mem];
stkp = STACK_AT(si);
@@ -2760,17 +2905,16 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
STACK_PUSH_REPEAT_INC(si);
MOP_OUT;
CHECK_INTERRUPT_IN_MATCH_AT;
- continue;
- break;
+ JUMP;
- case OP_REPEAT_INC_SG: MOP_IN(OP_REPEAT_INC_SG);
+ CASE(OP_REPEAT_INC_SG) MOP_IN(OP_REPEAT_INC_SG);
GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
STACK_GET_REPEAT(mem, stkp);
si = GET_STACK_INDEX(stkp);
goto repeat_inc;
- break;
+ NEXT;
- case OP_REPEAT_INC_NG: MOP_IN(OP_REPEAT_INC_NG);
+ CASE(OP_REPEAT_INC_NG) MOP_IN(OP_REPEAT_INC_NG);
GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
si = repeat_stk[mem];
stkp = STACK_AT(si);
@@ -2794,66 +2938,59 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
}
MOP_OUT;
CHECK_INTERRUPT_IN_MATCH_AT;
- continue;
- break;
+ JUMP;
- case OP_REPEAT_INC_NG_SG: MOP_IN(OP_REPEAT_INC_NG_SG);
+ CASE(OP_REPEAT_INC_NG_SG) MOP_IN(OP_REPEAT_INC_NG_SG);
GET_MEMNUM_INC(mem, p); /* mem: OP_REPEAT ID */
STACK_GET_REPEAT(mem, stkp);
si = GET_STACK_INDEX(stkp);
goto repeat_inc_ng;
- break;
+ NEXT;
- case OP_PUSH_POS: MOP_IN(OP_PUSH_POS);
+ CASE(OP_PUSH_POS) MOP_IN(OP_PUSH_POS);
STACK_PUSH_POS(s, sprev, pkeep);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_POP_POS: MOP_IN(OP_POP_POS);
+ CASE(OP_POP_POS) MOP_IN(OP_POP_POS);
{
STACK_POS_END(stkp);
s = stkp->u.state.pstr;
sprev = stkp->u.state.pstr_prev;
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_PUSH_POS_NOT: MOP_IN(OP_PUSH_POS_NOT);
+ CASE(OP_PUSH_POS_NOT) MOP_IN(OP_PUSH_POS_NOT);
GET_RELADDR_INC(addr, p);
STACK_PUSH_POS_NOT(p + addr, s, sprev, pkeep);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_FAIL_POS: MOP_IN(OP_FAIL_POS);
+ CASE(OP_FAIL_POS) MOP_IN(OP_FAIL_POS);
STACK_POP_TIL_POS_NOT;
goto fail;
- break;
+ NEXT;
- case OP_PUSH_STOP_BT: MOP_IN(OP_PUSH_STOP_BT);
+ CASE(OP_PUSH_STOP_BT) MOP_IN(OP_PUSH_STOP_BT);
STACK_PUSH_STOP_BT;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_POP_STOP_BT: MOP_IN(OP_POP_STOP_BT);
+ CASE(OP_POP_STOP_BT) MOP_IN(OP_POP_STOP_BT);
STACK_STOP_BT_END;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_LOOK_BEHIND: MOP_IN(OP_LOOK_BEHIND);
+ CASE(OP_LOOK_BEHIND) MOP_IN(OP_LOOK_BEHIND);
GET_LENGTH_INC(tlen, p);
s = (UChar* )ONIGENC_STEP_BACK(encode, str, s, end, (int )tlen);
if (IS_NULL(s)) goto fail;
sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s, end);
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_PUSH_LOOK_BEHIND_NOT: MOP_IN(OP_PUSH_LOOK_BEHIND_NOT);
+ CASE(OP_PUSH_LOOK_BEHIND_NOT) MOP_IN(OP_PUSH_LOOK_BEHIND_NOT);
GET_RELADDR_INC(addr, p);
GET_LENGTH_INC(tlen, p);
q = (UChar* )ONIGENC_STEP_BACK(encode, str, s, end, (int )tlen);
@@ -2869,32 +3006,29 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
sprev = (UChar* )onigenc_get_prev_char_head(encode, str, s, end);
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_FAIL_LOOK_BEHIND_NOT: MOP_IN(OP_FAIL_LOOK_BEHIND_NOT);
+ CASE(OP_FAIL_LOOK_BEHIND_NOT) MOP_IN(OP_FAIL_LOOK_BEHIND_NOT);
STACK_POP_TIL_LOOK_BEHIND_NOT;
goto fail;
- break;
+ NEXT;
#ifdef USE_SUBEXP_CALL
- case OP_CALL: MOP_IN(OP_CALL);
+ CASE(OP_CALL) MOP_IN(OP_CALL);
GET_ABSADDR_INC(addr, p);
STACK_PUSH_CALL_FRAME(p);
p = reg->p + addr;
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_RETURN: MOP_IN(OP_RETURN);
+ CASE(OP_RETURN) MOP_IN(OP_RETURN);
STACK_RETURN(p);
STACK_PUSH_RETURN;
MOP_OUT;
- continue;
- break;
+ JUMP;
#endif
- case OP_CONDITION: MOP_IN(OP_CONDITION);
+ CASE(OP_CONDITION) MOP_IN(OP_CONDITION);
GET_MEMNUM_INC(mem, p);
GET_RELADDR_INC(addr, p);
if ((mem > num_mem) ||
@@ -2903,17 +3037,16 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
p += addr;
}
MOP_OUT;
- continue;
- break;
+ JUMP;
- case OP_FINISH:
+ CASE(OP_FINISH)
goto finish;
- break;
+ NEXT;
fail:
MOP_OUT;
/* fall */
- case OP_FAIL: MOP_IN(OP_FAIL);
+ CASE(OP_FAIL) MOP_IN(OP_FAIL);
STACK_POP;
p = stk->u.state.pcode;
s = stk->u.state.pstr;
@@ -2928,15 +3061,11 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
#endif
MOP_OUT;
- continue;
- break;
+ JUMP;
- default:
+ DEFAULT
goto bytecode_error;
-
- } /* end of switch */
- sprev = sbegin;
- } /* end of while(1) */
+ } VM_LOOP_END
finish:
STACK_SAVE;
@@ -3791,9 +3920,6 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
return 0; /* fail */
}
-static int set_bm_backward_skip P_((UChar* s, UChar* end, OnigEncoding enc,
- int** skip));
-
#define BM_BACKWARD_SEARCH_LENGTH_THRESHOLD 100
static int