diff --git a/ChangeLog b/ChangeLog index dcb5c56f15..b937b5fd65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Oct 4 05:53:11 2016 NARUSE, Yui + + * 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. + Mon Oct 3 21:24:41 2016 Kazuhiro NISHIYAMA * NEWS: mention Readline.quoting_detection_proc{,=}. diff --git a/regexec.c b/regexec.c index 480017ae54..f8813875dc 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;