summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-03 21:06:50 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-03 21:06:50 (GMT)
commite342418e465844a38546ebc7d69e23405dc9eb42 (patch)
tree8c15ccc3c917ffe724580a8465004f24ac497347 /regexec.c
parent011e45c6ec2815bd3a481b4ffc5ecd501c051b1f (diff)
* regexec.c (OPCODE_EXEC_HOOK): op is p-1 because p is already
incremented. * regexec.c (OPCODE_EXEC_HOOK): use the exact end address. * regexec.c (match_at): don't call OPCODE_EXEC_HOOK in CASE() when it comes from goto fail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/regexec.c b/regexec.c
index 480017a..f881387 100644
--- a/regexec.c
+++ b/regexec.c
@@ -1613,12 +1613,13 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
#ifdef ONIG_DEBUG_MATCH
#define OPCODE_EXEC_HOOK \
if (s) { \
- UChar *q, *bp, buf[50]; \
+ UChar *op, *q, *bp, buf[50]; \
int len; \
- fprintf(stderr, "%4"PRIdPTR"> \"", (*p == OP_FINISH) ? (ptrdiff_t )-1 : s - str); \
+ op = p - 1; \
+ fprintf(stderr, "%4"PRIdPTR"> \"", (*op == 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. */ \
+ if (*op != 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++; \
@@ -1629,8 +1630,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
*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, "%4"PRIdPTR":", (op == FinishCode) ? (ptrdiff_t )-1 : op - reg->p); \
+ onig_print_compiled_byte_code(stderr, op, reg->p+reg->used, NULL, encode); \
fprintf(stderr, "\n"); \
}
#else
@@ -3064,10 +3065,13 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
goto finish;
NEXT;
- fail:
- MOP_OUT;
- /* fall */
- CASE(OP_FAIL) MOP_IN(OP_FAIL);
+ CASE(OP_FAIL)
+ if (0) {
+ /* fall */
+ fail:
+ MOP_OUT;
+ }
+ MOP_IN(OP_FAIL);
STACK_POP;
p = stk->u.state.pcode;
s = stk->u.state.pstr;