ruby-changes:3052
From: ko1@a...
Date: 24 Dec 2007 03:12:56 +0900
Subject: [ruby-changes:3052] matz - Ruby:r14544 (trunk): * io.c (prepare_getline_args): convert RS to external encoding.
matz 2007-12-24 03:12:44 +0900 (Mon, 24 Dec 2007) New Revision: 14544 Modified files: trunk/ChangeLog trunk/io.c Log: * io.c (prepare_getline_args): convert RS to external encoding. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14544&r2=14543 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=14544&r2=14543 Index: ChangeLog =================================================================== --- ChangeLog (revision 14543) +++ ChangeLog (revision 14544) @@ -5,6 +5,8 @@ * io.c (io_read_encoding): retrieve reading encoding. + * io.c (prepare_getline_args): convert RS to external encoding. + Mon Dec 24 02:06:35 2007 Yukihiro Matsumoto <matz@r...> * io.c (rb_f_open): documentation update. Index: io.c =================================================================== --- io.c (revision 14543) +++ io.c (revision 14544) @@ -1769,9 +1769,10 @@ } static void -prepare_getline_args(int argc, VALUE *argv, VALUE *rsp, long *limit) +prepare_getline_args(int argc, VALUE *argv, VALUE *rsp, long *limit, VALUE io) { VALUE lim, rs; + rb_io_t *fptr; if (argc == 0) { rs = rb_rs; @@ -1791,6 +1792,12 @@ } } } + GetOpenFile(io, fptr); + if (fptr->enc2) { + rs = rb_funcall(rs, id_encode, 2, + rb_enc_from_encoding(fptr->enc2), + rb_enc_from_encoding(fptr->enc)); + } *rsp = rs; *limit = NIL_P(lim) ? -1L : NUM2LONG(lim); } @@ -1872,7 +1879,7 @@ VALUE rs; long limit; - prepare_getline_args(argc, argv, &rs, &limit); + prepare_getline_args(argc, argv, &rs, &limit, io); return rb_io_getline_1(rs, limit, io); } @@ -2041,7 +2048,7 @@ VALUE line, ary, rs; long limit; - prepare_getline_args(argc, argv, &rs, &limit); + prepare_getline_args(argc, argv, &rs, &limit, io); ary = rb_ary_new(); while (!NIL_P(line = rb_io_getline_1(rs, limit, io))) { rb_ary_push(ary, line); @@ -2080,7 +2087,7 @@ long limit; RETURN_ENUMERATOR(io, argc, argv); - prepare_getline_args(argc, argv, &rs, &limit); + prepare_getline_args(argc, argv, &rs, &limit, io); while (!NIL_P(str = rb_io_getline_1(rs, limit, io))) { rb_yield(str); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml