From dee96209bfbb957538c7adeb01a65f3830749179 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 6 Dec 1999 09:04:03 +0000 Subject: 19991206 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- regex.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'regex.c') diff --git a/regex.c b/regex.c index f77d635a0a..834d97b574 100644 --- a/regex.c +++ b/regex.c @@ -396,6 +396,7 @@ re_set_syntax(syntax) long syntax; { /* obsolete */ + return 0; } @@ -2272,9 +2273,9 @@ re_compile_pattern(pattern, size, bufp) } if (!(bufp->options & RE_OPTIMIZE_NO_BM)) { bufp->must_skip = (int *) xmalloc((1 << BYTEWIDTH)*sizeof(int)); - bm_init_skip(bufp->must_skip, bufp->must+1, + bm_init_skip(bufp->must_skip, (unsigned char*)bufp->must+1, (unsigned char)bufp->must[0], - MAY_TRANSLATE()?translate:0); + (unsigned char*)(MAY_TRANSLATE()?translate:0)); } } @@ -2626,6 +2627,7 @@ re_compile_fastmap(bufp) fastmap[translate[p[2]]] = 2; else fastmap[p[2]] = 2; + bufp->options |= RE_OPTIMIZE_BMATCH; } else if (TRANSLATE_P()) fastmap[translate[p[1]]] = 1; @@ -2828,8 +2830,10 @@ re_compile_fastmap(bufp) while (beg <= end) { /* NOTE: Charset for multi-byte chars might contain single-byte chars. We must reject them. */ - if (c < 0x100) + if (c < 0x100) { fastmap[beg] = 2; + bufp->options |= RE_OPTIMIZE_BMATCH; + } else if (ismbchar(beg)) fastmap[beg] = 1; beg++; @@ -2950,6 +2954,33 @@ re_search(bufp, string, size, startpos, range, regs) re_compile_fastmap(bufp); } + /* Adjust startpos for mbc string */ + if (current_mbctype && startpos>0 && !(bufp->options&RE_OPTIMIZE_BMATCH)) { + int i = 0; + + if (range > 0) { + while (iused>0) { -- cgit v1.2.3