From 368a41151e2969097787eb663ba1bb5c1fb09efd Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 24 Dec 2007 16:36:14 +0000 Subject: * include/ruby/encoding.h (rb_enc_left_char_head): new utility macro. * include/ruby/encoding.h (rb_enc_right_char_head): ditto. * io.c (appendline): does multibyte RS search in the function. * io.c (prepare_getline_args): RS may be nil. * io.c (rb_io_getc): should process character based on external encoding, when transcoding required. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index fd2c672f1..6ca4ba3c6 100644 --- a/string.c +++ b/string.c @@ -1491,8 +1491,7 @@ rb_str_index(VALUE str, VALUE sub, long offset) char *t; pos = rb_memsearch(sptr, slen, s, len); if (pos < 0) return pos; - t = (char *)onigenc_get_right_adjust_char_head(enc, (const UChar *)s, - (const UChar *)s + pos); + t = rb_enc_right_char_head(s, s+pos, enc); if (t == s) break; if ((len -= t - s) <= 0) return -1; offset += t - s; @@ -4564,7 +4563,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 (ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, (UChar *)p, (UChar *)pp) != (const UChar*)pp) + if (rb_enc_left_char_head(p, pp, enc) != pp) return Qnil; rb_str_modify(str); STR_SET_LEN(str, RSTRING_LEN(str) - rslen); -- cgit