青木です。

とりあえず String#each に警告を出してみませんか。
同時に移行用メソッドとして String#lines を実装しました。
-------------------------------------------------------------------
青木峰郎

Index: string.c =================================================================== RCS file: /var/cvs/src/ruby/string.c,v retrieving revision 1.196 diff -u -r1.196 string.c --- string.c 17 Aug 2004 09:02:39 -0000 1.196 +++ string.c 18 Aug 2004 19:13:21 -0000 @@ -3568,9 +3568,10 @@ } +static VALUE rb_str_each_line(VALUE str, VALUE rs); + /* * call-seq: - * str.each(separator=$/) {|substr| block } => str * str.each_line(separator=$/) {|substr| block } => str * * Splits <i>str</i> using the supplied parameter as the record separator @@ -3602,22 +3603,33 @@ */ static VALUE -rb_str_each_line(argc, argv, str) +rb_str_each_line_m(argc, argv, str) int argc; VALUE *argv; VALUE str; { VALUE rs; + + switch (rb_scan_args(argc, argv, "01", &rs)) { + case 0: + return rb_str_each_line(str, rb_rs); + case 1: + return rb_str_each_line(str, rs); + default: + rb_bug("rb_str_each_line_m: must not happen"); + } +} + +static VALUE +rb_str_each_line(str, rs) + VALUE str, rs; +{ int newline; char *p = RSTRING(str)->ptr, *pend = p + RSTRING(str)->len, *s; char *ptr = p; long len = RSTRING(str)->len, rslen; VALUE line; - if (rb_scan_args(argc, argv, "01", &rs) == 0) { - rs = rb_rs; - } - if (NIL_P(rs)) { rb_yield(str); return str; @@ -3687,6 +3699,63 @@ /* * call-seq: + * str.each(separator=$/) {|substr| block } => str + * + * Equivalent to String#each_line. + */ + +static VALUE +rb_str_each(argc, argv, self) + int argc; + VALUE *argv, self; +{ + rb_warning("String#each is subject to change; suggest str.lines.each"); + return rb_str_each_line_m(argc, argv, self); +} + + +static VALUE +each_line(str) + VALUE str; +{ + rb_funcall(str, rb_intern("each_line"), 0); + return Qnil; +} + +static VALUE +lines_i(i, ary) + VALUE i, ary; +{ + rb_ary_push(ary, i); + return Qnil; +} + +/* + * call-seq: + * str.lines => array + * + * Returns an array containing the lines in <i>str</i>. + * + * p "a\nb\nc\n".lines #=> ["a\n", "b\n", "c\n"] + * p "a\r\nb\r\nc\r\n".lines #=> ["a\r\n", "b\r\n", "c\r\n"] + * p "a\rb\rc\r".lines #=> ["a\rb\rc\r"] + * p "x".lines #=> ["x"] + * p "".lines #=> [] + */ + +static VALUE +rb_str_lines(str) + VALUE str; +{ + VALUE result = rb_ary_new(); + + rb_iterate(each_line, str, lines_i, result); + return result; +} + + +/* + * call-seq: * str.chop! => str or nil * * Processes <i>str</i> as for <code>String#chop</code>, returning <i>str</i>, @@ -4657,9 +4726,11 @@ rb_define_method(rb_cString, "delete!", rb_str_delete_bang, -1); rb_define_method(rb_cString, "squeeze!", rb_str_squeeze_bang, -1); - rb_define_method(rb_cString, "each_line", rb_str_each_line, -1); - rb_define_method(rb_cString, "each", rb_str_each_line, -1); + rb_define_method(rb_cString, "each_line", rb_str_each_line_m, -1); + rb_define_method(rb_cString, "each", rb_str_each, -1); rb_define_method(rb_cString, "each_byte", rb_str_each_byte, 0); + + rb_define_method(rb_cString, "lines", rb_str_lines, 0); rb_define_method(rb_cString, "sum", rb_str_sum, -1);