From 9b64dfe3b8f0343ebf97ae80d3a4ec3f4bd115b3 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 5 Feb 1999 10:27:34 +0000 Subject: 990205 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- regex.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'regex.c') diff --git a/regex.c b/regex.c index d2a0fd95c2..f504ff8a0f 100644 --- a/regex.c +++ b/regex.c @@ -1025,6 +1025,7 @@ re_compile_pattern(pattern, size, bufp) { register char *b = bufp->buffer; register char *p = pattern; + char *nextp; char *pend = pattern + size; register unsigned c, c1; char *p0; @@ -2018,15 +2019,16 @@ re_compile_pattern(pattern, size, bufp) normal_char: /* Expects the character in `c'. */ had_mbchar = 0; if (ismbchar(c)) { - had_mbchar = 0; + had_mbchar = 1; c1 = p - pattern; } numeric_char: + nextp = p + ismbchar(c); if (!pending_exact || pending_exact + *pending_exact + 1 != b || *pending_exact >= (c1 ? 0176 : 0177) - || *p == '+' || *p == '?' - || *p == '*' || *p == '^' - || *p == '{') { + || *nextp == '+' || *nextp == '?' + || *nextp == '*' || *nextp == '^' + || *nextp == '{') { laststart = b; BUFPUSH(exactn); pending_exact = b; @@ -2637,7 +2639,7 @@ re_compile_fastmap(bufp) { if (TRANSLATE_P()) j = translate[j]; - fastmap[j] = (j>0x7f?2:1); + fastmap[j] = (j>0x7f?(ismbchar(j)?0:2):1); } { unsigned short size; @@ -2846,15 +2848,17 @@ re_search(bufp, string, size, startpos, range, regs) int len = ismbchar(c); if (fastmap[c]) break; - c = *p++; - range -= len; + p += len; + range -= len + 1; + c = *p; if (fastmap[c] == 2) break; } - else + else { if (fastmap[MAY_TRANSLATE() ? translate[c] : c]) break; - range--; + range--; + } } startpos += irange - range; } -- cgit v1.2.3