mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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:
parent
d9435e0cd3
commit
c965010582
7 changed files with 26 additions and 9 deletions
16
ChangeLog
16
ChangeLog
|
@ -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>
|
||||
|
||||
* 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))
|
||||
/* 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_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 */
|
||||
#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
|
||||
OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
|
||||
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
|
||||
int onigenc_strlen P_((OnigEncoding enc, const OnigUChar* p, const OnigUChar* end));
|
||||
ONIG_EXTERN
|
||||
|
|
2
re.c
2
re.c
|
@ -1264,7 +1264,7 @@ rb_reg_adjust_startpos(VALUE re, VALUE str, int pos, int reverse)
|
|||
string = (UChar*)RSTRING_PTR(str);
|
||||
|
||||
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 {
|
||||
p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, string, string + pos);
|
||||
|
|
4
regenc.c
4
regenc.c
|
@ -62,11 +62,11 @@ onigenc_mbclen_approximate(const OnigUChar* p,const OnigUChar* e, struct OnigEnc
|
|||
}
|
||||
|
||||
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);
|
||||
if (p < s) {
|
||||
p += enclen(enc, p, s);
|
||||
p += enclen(enc, p, end);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -3348,7 +3348,7 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end,
|
|||
if (reg->dmax != ONIG_INFINITE_DISTANCE) {
|
||||
*low = p - reg->dmax;
|
||||
*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
|
||||
|
@ -3506,7 +3506,7 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end,
|
|||
if ((OnigDistance )(min_semi_end - start) > reg->anchor_dmax) {
|
||||
start = min_semi_end - reg->anchor_dmax;
|
||||
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 */
|
||||
start = onigenc_get_prev_char_head(reg->enc, str, end);
|
||||
}
|
||||
|
|
5
string.c
5
string.c
|
@ -2088,7 +2088,7 @@ static long
|
|||
rb_str_index(VALUE str, VALUE sub, long offset)
|
||||
{
|
||||
long pos;
|
||||
char *s, *sptr;
|
||||
char *s, *sptr, *e;
|
||||
long len, slen;
|
||||
rb_encoding *enc;
|
||||
|
||||
|
@ -2104,6 +2104,7 @@ rb_str_index(VALUE str, VALUE sub, long offset)
|
|||
}
|
||||
if (len - offset < slen) return -1;
|
||||
s = RSTRING_PTR(str);
|
||||
e = s + RSTRING_LEN(str);
|
||||
if (offset) {
|
||||
offset = str_offset(s, RSTRING_END(str), offset, enc, single_byte_optimizable(str));
|
||||
s += offset;
|
||||
|
@ -2117,7 +2118,7 @@ rb_str_index(VALUE str, VALUE sub, long offset)
|
|||
char *t;
|
||||
pos = rb_memsearch(sptr, slen, s, len, enc);
|
||||
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 ((len -= t - s) <= 0) return -1;
|
||||
offset += t - s;
|
||||
|
|
Loading…
Reference in a new issue