8000 bm_search · jruby/ruby@de11b8d · GitHub
[go: up one dir, main page]

Skip to content

Commit de11b8d

Browse files
author
matz
committed
bm_search
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 831a096 commit de11b8d

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

regex.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,7 +2000,6 @@ re_compile_pattern(pattern, size, bufp)
20002000

20012001
/* set optimize flags */
20022002
laststart = bufp->buffer;
2003-
if (*laststart == exactn) bufp->options |= RE_OPTIMIZE_EXACTN;
20042003
if (*laststart == start_memory) laststart += 3;
20052004
if (*laststart == dummy_failure_jump) laststart += 3;
20062005
else if (*laststart == try_next) laststart += 3;
@@ -2025,18 +2024,25 @@ re_compile_pattern(pattern, size, bufp)
20252024

20262025
bufp->used = b - bufp->buffer;
20272026
bufp->re_nsub = regnum;
2028-
bufp->must = calculate_must_string(bufp->buffer, b);
2029-
if (current_mbctype) bufp->options |= RE_OPTIMIZE_NO_BM;
2027+
if (*bufp->buffer == exactn) {
2028+
bufp->options |= RE_OPTIMIZE_EXACTN;
2029+
bufp->must = bufp->buffer+1;
2030+
}
2031+
else {
2032+
bufp->must = calculate_must_string(bufp->buffer, b);
2033+
}
2034+
if (current_mbctype == MBCTYPE_SJIS) bufp->options |= RE_OPTIMIZE_NO_BM;
20302035
else if (bufp->must) {
2031-
int i;
2032-
int len = ((unsigned char)bufp->must[0]);
2036+
int i;
2037+
int len = (unsigned char)bufp->must[0];
20332038

2034-
for (i=1; i<len; i++) {
2035-
if ((unsigned char)bufp->must[i] == 0xff) {
2036-
bufp->options |= RE_OPTIMIZE_NO_BM;
2037-
break;
2038-
}
2039+
for (i=1; i<len; i++) {
2040+
if ((unsigned char)bufp->must[i] == 0xff ||
2041+
(current_mbctype == MBCTYPE_EUC && ismbchar(bufp->must[i]))) {
2042+
bufp->options |= RE_OPTIMIZE_NO_BM;
2043+
break;
20392044
}
2045+
}
20402046
}
20412047

20422048
FREE_AND_RETURN(stackb, 0);

0 commit comments

Comments
 (0)
0