summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-08-31 09:52:20 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1998-08-31 09:52:20 +0000
commitde11b8dc8a567f0dcb3961d4e712d63df97eaabb (patch)
tree2b8aba5e64384e438ef1d4932d7dc846e52fbdc4
parent831a09696e25eee391a82dd32da4d6e81d459c71 (diff)
bm_search
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--regex.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/regex.c b/regex.c
index 04831233316..23443b927f5 100644
--- a/regex.c
+++ b/regex.c
@@ -2000,7 +2000,6 @@ re_compile_pattern(pattern, size, bufp)
/* set optimize flags */
laststart = bufp->buffer;
- if (*laststart == exactn) bufp->options |= RE_OPTIMIZE_EXACTN;
if (*laststart == start_memory) laststart += 3;
if (*laststart == dummy_failure_jump) laststart += 3;
else if (*laststart == try_next) laststart += 3;
@@ -2025,18 +2024,25 @@ re_compile_pattern(pattern, size, bufp)
bufp->used = b - bufp->buffer;
bufp->re_nsub = regnum;
- bufp->must = calculate_must_string(bufp->buffer, b);
- if (current_mbctype) bufp->options |= RE_OPTIMIZE_NO_BM;
+ if (*bufp->buffer == exactn) {
+ bufp->options |= RE_OPTIMIZE_EXACTN;
+ bufp->must = bufp->buffer+1;
+ }
+ else {
+ bufp->must = calculate_must_string(bufp->buffer, b);
+ }
+ if (current_mbctype == MBCTYPE_SJIS) bufp->options |= RE_OPTIMIZE_NO_BM;
else if (bufp->must) {
- int i;
- int len = ((unsigned char)bufp->must[0]);
+ int i;
+ int len = (unsigned char)bufp->must[0];
- for (i=1; i<len; i++) {
- if ((unsigned char)bufp->must[i] == 0xff) {
- bufp->options |= RE_OPTIMIZE_NO_BM;
- break;
- }
+ for (i=1; i<len; i++) {
+ if ((unsigned char)bufp->must[i] == 0xff ||
+ (current_mbctype == MBCTYPE_EUC && ismbchar(bufp->must[i]))) {
+ bufp->options |= RE_OPTIMIZE_NO_BM;
+ break;
}
+ }
}
FREE_AND_RETURN(stackb, 0);