diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-13 19:23:52 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-13 19:23:52 +0000 |
commit | 19416601a0af3b7c99a570ae6993cb29e4360e64 (patch) | |
tree | a7406d81b554109333ea2240825897a87ebdfe4b /string.c | |
parent | 10ff0f292e9b7cd673915fcc32f5d236c95c8d7d (diff) | |
download | ruby-19416601a0af3b7c99a570ae6993cb29e4360e64.tar.gz |
* include/ruby/oniguruma.h (OnigEncodingTypeST): add end argument for
left_adjust_char_head.
(ONIGENC_LEFT_ADJUST_CHAR_HEAD): add end argument.
(onigenc_get_left_adjust_char_head): ditto.
* include/ruby/encoding.h (rb_enc_left_char_head): add end argument.
* regenc.h (onigenc_single_byte_left_adjust_char_head): ditto.
* regenc.c (onigenc_get_right_adjust_char_head): follow the interface
change.
(onigenc_get_right_adjust_char_head_with_prev): ditto.
(onigenc_get_prev_char_head): ditto.
(onigenc_step_back): ditto.
(onigenc_get_left_adjust_char_head): ditto.
(onigenc_single_byte_code_to_mbc): ditto.
* re.c: ditto.
* string.c: ditto.
* io.c: ditto.
* regexec.c: ditto.
* enc/euc_jp.c: ditto.
* enc/cp949.c: ditto.
* enc/shift_jis.c: ditto.
* enc/gbk.c: ditto.
* enc/big5.c: ditto.
* enc/euc_tw.c: ditto.
* enc/euc_kr.c: ditto.
* enc/emacs_mule.c: ditto.
* enc/gb18030.c: ditto.
* enc/utf_8.c: ditto.
* enc/utf_16le.c: ditto.
* enc/utf_16be.c: ditto.
* enc/utf_32le.c: ditto.
* enc/utf_32be.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -5179,7 +5179,7 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str) p = memchr(p, '\n', pend - p); if (!p) break; - p0 = rb_enc_left_char_head(s, p, enc); + p0 = rb_enc_left_char_head(s, p, pend, enc); if (!rb_enc_is_newline(p0, pend, enc)) { p++; continue; @@ -5424,13 +5424,13 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str) rb_str_modify(str); enc = rb_enc_get(str); if (rb_enc_mbminlen(enc) > 1) { - pp = rb_enc_left_char_head(p, e-rb_enc_mbminlen(enc), enc); + pp = rb_enc_left_char_head(p, e-rb_enc_mbminlen(enc), e, enc); if (rb_enc_is_newline(pp, e, enc)) { e = pp; } pp = e - rb_enc_mbminlen(enc); if (pp >= p) { - pp = rb_enc_left_char_head(p, pp, enc); + pp = rb_enc_left_char_head(p, pp, e, enc); if (rb_enc_ascget(pp, e, 0, enc) == '\r') { e = pp; } @@ -5493,7 +5493,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str) if (p[len-1] == newline && (rslen <= 1 || memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) { - if (rb_enc_left_char_head(p, pp, enc) != pp) + if (rb_enc_left_char_head(p, pp, e, enc) != pp) return Qnil; rb_str_modify(str); STR_SET_LEN(str, RSTRING_LEN(str) - rslen); @@ -6284,7 +6284,7 @@ static VALUE rb_str_end_with(int argc, VALUE *argv, VALUE str) { int i; - char *p, *s; + char *p, *s, *e; rb_encoding *enc; for (i=0; i<argc; i++) { @@ -6293,8 +6293,9 @@ rb_str_end_with(int argc, VALUE *argv, VALUE str) enc = rb_enc_check(str, tmp); if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue; p = RSTRING_PTR(str); - s = p + RSTRING_LEN(str) - RSTRING_LEN(tmp); - if (rb_enc_left_char_head(p, s, enc) != s) + e = p + RSTRING_LEN(str); + s = e - RSTRING_LEN(tmp); + if (rb_enc_left_char_head(p, s, e, enc) != s) continue; if (memcmp(s, RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0) return Qtrue; |