зеркало из https://github.com/github/ruby.git
* re.c (rb_reg_search): avoid inner loop for reverse search.
* regexec.c: unset USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE which is turned on since oniguruma 5.9.1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ed74723af4
Коммит
22e7258275
|
@ -1,3 +1,10 @@
|
||||||
|
Fri Jan 4 10:22:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* re.c (rb_reg_search): avoid inner loop for reverse search.
|
||||||
|
|
||||||
|
* regexec.c: unset USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
|
||||||
|
which is turned on since oniguruma 5.9.1.
|
||||||
|
|
||||||
Fri Jan 4 02:53:31 2008 Tanaka Akira <akr@fsij.org>
|
Fri Jan 4 02:53:31 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* enc/euc_jp.c: remove eucjp_ prefix. breakpoint can be specified as
|
* enc/euc_jp.c: remove eucjp_ prefix. breakpoint can be specified as
|
||||||
|
|
36
re.c
36
re.c
|
@ -1035,7 +1035,7 @@ rb_reg_search(VALUE re, VALUE str, int pos, int reverse)
|
||||||
int result;
|
int result;
|
||||||
VALUE match;
|
VALUE match;
|
||||||
static struct re_registers regs;
|
static struct re_registers regs;
|
||||||
int range;
|
char *range = RSTRING_PTR(str);
|
||||||
rb_encoding *enc = rb_enc_get(str);
|
rb_encoding *enc = rb_enc_get(str);
|
||||||
|
|
||||||
if (pos > RSTRING_LEN(str) || pos < 0) {
|
if (pos > RSTRING_LEN(str) || pos < 0) {
|
||||||
|
@ -1045,33 +1045,15 @@ rb_reg_search(VALUE re, VALUE str, int pos, int reverse)
|
||||||
|
|
||||||
rb_reg_prepare_re(re, str);
|
rb_reg_prepare_re(re, str);
|
||||||
|
|
||||||
if (reverse) {
|
if (!reverse) {
|
||||||
char *p = RSTRING_PTR(str) + pos;
|
range += RSTRING_LEN(str);
|
||||||
while (1) {
|
|
||||||
result = onig_match(RREGEXP(re)->ptr,
|
|
||||||
(UChar*)(RSTRING_PTR(str)),
|
|
||||||
((UChar*)(RSTRING_PTR(str)) + RSTRING_LEN(str)),
|
|
||||||
(UChar*)p,
|
|
||||||
®s,
|
|
||||||
ONIG_OPTION_NONE);
|
|
||||||
if (result != ONIG_MISMATCH) {
|
|
||||||
result = p - RSTRING_PTR(str);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (RSTRING_PTR(str) == p)
|
|
||||||
break;
|
|
||||||
p = rb_enc_prev_char(RSTRING_PTR(str), p, enc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
range = RSTRING_LEN(str) - pos;
|
|
||||||
result = onig_search(RREGEXP(re)->ptr,
|
|
||||||
(UChar*)(RSTRING_PTR(str)),
|
|
||||||
((UChar*)(RSTRING_PTR(str)) + RSTRING_LEN(str)),
|
|
||||||
((UChar*)(RSTRING_PTR(str)) + pos),
|
|
||||||
((UChar*)(RSTRING_PTR(str)) + pos + range),
|
|
||||||
®s, ONIG_OPTION_NONE);
|
|
||||||
}
|
}
|
||||||
|
result = onig_search(RREGEXP(re)->ptr,
|
||||||
|
(UChar*)(RSTRING_PTR(str)),
|
||||||
|
((UChar*)(RSTRING_PTR(str)) + RSTRING_LEN(str)),
|
||||||
|
((UChar*)(RSTRING_PTR(str)) + pos),
|
||||||
|
((UChar*)range),
|
||||||
|
®s, ONIG_OPTION_NONE);
|
||||||
|
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
if (result == ONIG_MISMATCH) {
|
if (result == ONIG_MISMATCH) {
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#include "regint.h"
|
#include "regint.h"
|
||||||
|
|
||||||
#define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE
|
/* #define USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE */
|
||||||
|
|
||||||
#ifdef USE_CRNL_AS_LINE_TERMINATOR
|
#ifdef USE_CRNL_AS_LINE_TERMINATOR
|
||||||
#define ONIGENC_IS_MBC_CRNL(enc,p,end) \
|
#define ONIGENC_IS_MBC_CRNL(enc,p,end) \
|
||||||
|
|
Загрузка…
Ссылка в новой задаче