diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-11-09 09:11:52 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-11-09 09:11:52 +0000 |
commit | ee5ab9cc136baf18756abc6bd5d136a0231f973e (patch) | |
tree | abdc351cbffd7b67f63f41ea08f544819af0a28b /regex.c | |
parent | dc8da69e7cbc54f020ef1182fd28e57bbaa40fc3 (diff) |
1.1c7
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r-- | regex.c | 55 |
1 files changed, 30 insertions, 25 deletions
@@ -567,8 +567,8 @@ set_list_bits(c1, c2, b) if (beg != end) { if (c1 > EXTRACT_MBC(&b[beg*4])) c1 = EXTRACT_MBC(&b[beg*4]); - if (c2 < EXTRACT_MBC(&b[(end - 1)*4])) - c2 = EXTRACT_MBC(&b[(end - 1)*4]); + if (c2 < EXTRACT_MBC(&b[(end - 1)*4+2])) + c2 = EXTRACT_MBC(&b[(end - 1)*4+2]); } if (end < mbc_size && end != beg + 1) /* NOTE: memcpy() would not work here. */ @@ -2021,25 +2021,27 @@ re_compile_pattern(pattern, size, bufp) /* set optimize flags */ laststart = bufp->buffer; - if (*laststart == start_memory) laststart += 3; - if (*laststart == dummy_failure_jump) laststart += 3; - else if (*laststart == try_next) laststart += 3; - if (*laststart == on_failure_jump) { - int mcnt; - - laststart++; - EXTRACT_NUMBER_AND_INCR(mcnt, laststart); - if (mcnt == 4 && *laststart == anychar) { - bufp->options |= RE_OPTIMIZE_ANCHOR; - } - else if (*laststart == charset || *laststart == charset_not) { - p0 = laststart; - mcnt = *++p0 ; - p0 += mcnt+1; - mcnt = EXTRACT_UNSIGNED_AND_INCR(p0); - p0 += 4*mcnt; - if (*p0 == maybe_finalize_jump) { - bufp->stclass = laststart; + if (laststart != b) { + if (*laststart == start_memory) laststart += 3; + if (*laststart == dummy_failure_jump) laststart += 3; + else if (*laststart == try_next) laststart += 3; + if (*laststart == on_failure_jump) { + int mcnt; + + laststart++; + EXTRACT_NUMBER_AND_INCR(mcnt, laststart); + if (mcnt == 4 && *laststart == anychar) { + bufp->options |= RE_OPTIMIZE_ANCHOR; + } + else if (*laststart == charset || *laststart == charset_not) { + p0 = laststart; + mcnt = *++p0 ; + p0 += mcnt+1; + mcnt = EXTRACT_UNSIGNED_AND_INCR(p0); + p0 += 4*mcnt; + if (*p0 == maybe_finalize_jump) { + bufp->stclass = laststart; + } } } } @@ -2047,10 +2049,12 @@ re_compile_pattern(pattern, size, bufp) bufp->used = b - bufp->buffer; bufp->re_nsub = regnum; laststart = bufp->buffer; - if (*laststart == start_memory) laststart += 3; - if (*laststart == exactn) { - bufp->options |= RE_OPTIMIZE_EXACTN; - bufp->must = laststart+1; + if (laststart != b) { + if (*laststart == start_memory) laststart += 3; + if (*laststart == exactn) { + bufp->options |= RE_OPTIMIZE_EXACTN; + bufp->must = laststart+1; + } } else { bufp->must = calculate_must_string(bufp->buffer, b); @@ -3917,6 +3921,7 @@ re_match(bufp, string_arg, size, pos, regs) EXTRACT_NUMBER_AND_INCR (mcnt, p1); p1 += mcnt; + if (p1 >= pend) break; if ((is_a_jump_n && (enum regexpcode) *p1 == succeed_n) || (!is_a_jump_n && (enum regexpcode) *p1 == on_failure_jump)) |