summaryrefslogtreecommitdiff
path: root/regex.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-05 10:27:34 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-05 10:27:34 +0000
commit9b64dfe3b8f0343ebf97ae80d3a4ec3f4bd115b3 (patch)
tree7acd7b77321fdbc63149b47fde3bace6f7733614 /regex.c
parent06d4e3b42d836b762c29cdc9dc7181caf14dcdec (diff)
990205
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/regex.c b/regex.c
index d2a0fd9..f504ff8 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;
}