summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-13 16:40:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-13 16:40:31 +0000
commitc96501058270d16b4be35c0cbc8b008182524da0 (patch)
tree0d5629d488672736c6252861e74f04a8e904e594
parentd9435e0cd3b7315c63cd534728a3de020374da80 (diff)
* 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
-rw-r--r--ChangeLog16
-rw-r--r--include/ruby/encoding.h2
-rw-r--r--include/ruby/oniguruma.h2
-rw-r--r--re.c2
-rw-r--r--regenc.c4
-rw-r--r--regexec.c4
-rw-r--r--string.c5
7 files changed, 26 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 0a36a94..2558633 100644
--- a/ChangeLog
+++ b/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.
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index a69940e..45f5201 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -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))
diff --git a/include/ruby/oniguruma.h b/include/ruby/oniguruma.h
index 2e3b2bf..cd4bedf 100644
--- a/include/ruby/oniguruma.h
+++ b/include/ruby/oniguruma.h
@@ -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
diff --git a/re.c b/re.c
index a17874a..82463fe 100644
--- a/re.c
+++ b/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);
diff --git a/regenc.c b/regenc.c
index 935e8d3..62bf661 100644
--- a/regenc.c
+++ b/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;
}
diff --git a/regexec.c b/regexec.c
index b0cc664..05bc633 100644
--- a/regexec.c
+++ b/regexec.c
@@ -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);
}
diff --git a/string.c b/string.c
index 24d33ef..0342563 100644
--- a/string.c
+++ b/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;