* include/ruby/oniguruma.h (onigenc_get_right_adjust_char_head): add

end argument.

* include/ruby/encoding.h (rb_enc_right_char_head): add end argument.

* regenc.c (onigenc_get_right_adjust_char_head): use end argument.

* re.c (rb_reg_adjust_startpos): follow the interface change.

* string.c (rb_str_index): ditto.

* regexec.c (backward_search_range): ditto.
  (onig_search): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-09-13 16:40:31 +00:00
Родитель d9435e0cd3
Коммит c965010582
7 изменённых файлов: 26 добавлений и 9 удалений

Просмотреть файл

@ -1,3 +1,19 @@
Sun Sep 14 01:38:26 2008 Tanaka Akira <akr@fsij.org>
* include/ruby/oniguruma.h (onigenc_get_right_adjust_char_head): add
end argument.
* include/ruby/encoding.h (rb_enc_right_char_head): add end argument.
* regenc.c (onigenc_get_right_adjust_char_head): use end argument.
* re.c (rb_reg_adjust_startpos): follow the interface change.
* string.c (rb_str_index): ditto.
* regexec.c (backward_search_range): ditto.
(onig_search): ditto.
Sun Sep 14 00:43:28 2008 Tanaka Akira <akr@fsij.org> Sun Sep 14 00:43:28 2008 Tanaka Akira <akr@fsij.org>
* ext/ripper/depend (ripper.o): it depends on ruby headers. * ext/ripper/depend (ripper.o): it depends on ruby headers.

Просмотреть файл

@ -133,7 +133,7 @@ int rb_enc_codelen(int code, rb_encoding *enc);
#define rb_enc_prev_char(s,p,enc) (char *)onigenc_get_prev_char_head(enc,(UChar*)(s),(UChar*)(p)) #define rb_enc_prev_char(s,p,enc) (char *)onigenc_get_prev_char_head(enc,(UChar*)(s),(UChar*)(p))
/* ptr, ptr, encoding -> next_char */ /* ptr, ptr, encoding -> next_char */
#define rb_enc_left_char_head(s,p,enc) (char *)onigenc_get_left_adjust_char_head(enc,(UChar*)(s),(UChar*)(p)) #define rb_enc_left_char_head(s,p,enc) (char *)onigenc_get_left_adjust_char_head(enc,(UChar*)(s),(UChar*)(p))
#define rb_enc_right_char_head(s,p,enc) (char *)onigenc_get_right_adjust_char_head(enc,(UChar*)(s),(UChar*)(p)) #define rb_enc_right_char_head(s,p,e,enc) (char *)onigenc_get_right_adjust_char_head(enc,(UChar*)(s),(UChar*)(p),(UChar*)(e))
/* ptr, ptr, encoding -> newline_or_not */ /* ptr, ptr, encoding -> newline_or_not */
#define rb_enc_is_newline(p,end,enc) ONIGENC_IS_MBC_NEWLINE(enc,(UChar*)(p),(UChar*)(end)) #define rb_enc_is_newline(p,end,enc) ONIGENC_IS_MBC_NEWLINE(enc,(UChar*)(p),(UChar*)(end))

Просмотреть файл

@ -309,7 +309,7 @@ OnigUChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const OnigUChar* sta
ONIG_EXTERN ONIG_EXTERN
OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s)); OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
ONIG_EXTERN ONIG_EXTERN
OnigUChar* onigenc_get_right_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s)); OnigUChar* onigenc_get_right_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar* end));
ONIG_EXTERN ONIG_EXTERN
int onigenc_strlen P_((OnigEncoding enc, const OnigUChar* p, const OnigUChar* end)); int onigenc_strlen P_((OnigEncoding enc, const OnigUChar* p, const OnigUChar* end));
ONIG_EXTERN ONIG_EXTERN

2
re.c
Просмотреть файл

@ -1264,7 +1264,7 @@ rb_reg_adjust_startpos(VALUE re, VALUE str, int pos, int reverse)
string = (UChar*)RSTRING_PTR(str); string = (UChar*)RSTRING_PTR(str);
if (range > 0) { if (range > 0) {
p = onigenc_get_right_adjust_char_head(enc, string, string + pos); p = onigenc_get_right_adjust_char_head(enc, string, string + pos, string + RSTRING_LEN(str));
} }
else { else {
p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, string, string + pos); p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, string, string + pos);

Просмотреть файл

@ -62,11 +62,11 @@ onigenc_mbclen_approximate(const OnigUChar* p,const OnigUChar* e, struct OnigEnc
} }
extern UChar* extern UChar*
onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s) onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s, const UChar* end)
{ {
UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s); UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
if (p < s) { if (p < s) {
p += enclen(enc, p, s); p += enclen(enc, p, end);
} }
return p; return p;
} }

Просмотреть файл

@ -3348,7 +3348,7 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end,
if (reg->dmax != ONIG_INFINITE_DISTANCE) { if (reg->dmax != ONIG_INFINITE_DISTANCE) {
*low = p - reg->dmax; *low = p - reg->dmax;
*high = p - reg->dmin; *high = p - reg->dmin;
*high = onigenc_get_right_adjust_char_head(reg->enc, adjrange, *high); *high = onigenc_get_right_adjust_char_head(reg->enc, adjrange, *high, end);
} }
#ifdef ONIG_DEBUG_SEARCH #ifdef ONIG_DEBUG_SEARCH
@ -3506,7 +3506,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
if ((OnigDistance )(min_semi_end - start) > reg->anchor_dmax) { if ((OnigDistance )(min_semi_end - start) > reg->anchor_dmax) {
start = min_semi_end - reg->anchor_dmax; start = min_semi_end - reg->anchor_dmax;
if (start < end) if (start < end)
start = onigenc_get_right_adjust_char_head(reg->enc, str, start); start = onigenc_get_right_adjust_char_head(reg->enc, str, start, end);
else { /* match with empty at end */ else { /* match with empty at end */
start = onigenc_get_prev_char_head(reg->enc, str, end); start = onigenc_get_prev_char_head(reg->enc, str, end);
} }

Просмотреть файл

@ -2088,7 +2088,7 @@ static long
rb_str_index(VALUE str, VALUE sub, long offset) rb_str_index(VALUE str, VALUE sub, long offset)
{ {
long pos; long pos;
char *s, *sptr; char *s, *sptr, *e;
long len, slen; long len, slen;
rb_encoding *enc; rb_encoding *enc;
@ -2104,6 +2104,7 @@ rb_str_index(VALUE str, VALUE sub, long offset)
} }
if (len - offset < slen) return -1; if (len - offset < slen) return -1;
s = RSTRING_PTR(str); s = RSTRING_PTR(str);
e = s + RSTRING_LEN(str);
if (offset) { if (offset) {
offset = str_offset(s, RSTRING_END(str), offset, enc, single_byte_optimizable(str)); offset = str_offset(s, RSTRING_END(str), offset, enc, single_byte_optimizable(str));
s += offset; s += offset;
@ -2117,7 +2118,7 @@ rb_str_index(VALUE str, VALUE sub, long offset)
char *t; char *t;
pos = rb_memsearch(sptr, slen, s, len, enc); pos = rb_memsearch(sptr, slen, s, len, enc);
if (pos < 0) return pos; if (pos < 0) return pos;
t = rb_enc_right_char_head(s, s+pos, enc); t = rb_enc_right_char_head(s, s+pos, e, enc);
if (t == s + pos) break; if (t == s + pos) break;
if ((len -= t - s) <= 0) return -1; if ((len -= t - s) <= 0) return -1;
offset += t - s; offset += t - s;