Skip to content

Commit

Permalink
delete deprecated IO-like methods
Browse files Browse the repository at this point in the history
This commit deletes
{IO,ARGF,StringIO,Zib::GZipReader}#{bytes,chars,lines,codepoints}, which
have been deprecated since c47c095.

Note that String also has those methods.  They are neither depreacted
nor deleted because they are not aliases of counterpart each_something.
  • Loading branch information
shyouhei authored and nobu committed Dec 3, 2020
1 parent 84eb2bf commit 43b95ba
Show file tree
Hide file tree
Showing 20 changed files with 194 additions and 358 deletions.
52 changes: 0 additions & 52 deletions ext/stringio/stringio.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,18 +832,6 @@ strio_each_byte(VALUE self)
return self;
}

/*
* This is a deprecated alias for #each_byte.
*/
static VALUE
strio_bytes(VALUE self)
{
rb_warn("StringIO#bytes is deprecated; use #each_byte instead");
if (!rb_block_given_p())
return rb_enumeratorize(self, ID2SYM(rb_intern("each_byte")), 0, 0);
return strio_each_byte(self);
}

/*
* call-seq:
* strio.getc -> string or nil
Expand Down Expand Up @@ -1057,18 +1045,6 @@ strio_each_char(VALUE self)
return self;
}

/*
* This is a deprecated alias for #each_char.
*/
static VALUE
strio_chars(VALUE self)
{
rb_warn("StringIO#chars is deprecated; use #each_char instead");
if (!rb_block_given_p())
return rb_enumeratorize(self, ID2SYM(rb_intern("each_char")), 0, 0);
return strio_each_char(self);
}

/*
* call-seq:
* strio.each_codepoint {|c| block } -> strio
Expand Down Expand Up @@ -1101,18 +1077,6 @@ strio_each_codepoint(VALUE self)
return self;
}

/*
* This is a deprecated alias for #each_codepoint.
*/
static VALUE
strio_codepoints(VALUE self)
{
rb_warn("StringIO#codepoints is deprecated; use #each_codepoint instead");
if (!rb_block_given_p())
return rb_enumeratorize(self, ID2SYM(rb_intern("each_codepoint")), 0, 0);
return strio_each_codepoint(self);
}

/* Boyer-Moore search: copied from regex.c */
static void
bm_init_skip(long *skip, const char *pat, long m)
Expand Down Expand Up @@ -1363,18 +1327,6 @@ strio_each(int argc, VALUE *argv, VALUE self)
return self;
}

/*
* This is a deprecated alias for #each_line.
*/
static VALUE
strio_lines(int argc, VALUE *argv, VALUE self)
{
rb_warn("StringIO#lines is deprecated; use #each_line instead");
if (!rb_block_given_p())
return rb_enumeratorize(self, ID2SYM(rb_intern("each_line")), argc, argv);
return strio_each(argc, argv, self);
}

/*
* call-seq:
* strio.readlines(sep=$/, chomp: false) -> array
Expand Down Expand Up @@ -1843,13 +1795,9 @@ Init_stringio(void)

rb_define_method(StringIO, "each", strio_each, -1);
rb_define_method(StringIO, "each_line", strio_each, -1);
rb_define_method(StringIO, "lines", strio_lines, -1);
rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
rb_define_method(StringIO, "bytes", strio_bytes, 0);
rb_define_method(StringIO, "each_char", strio_each_char, 0);
rb_define_method(StringIO, "chars", strio_chars, 0);
rb_define_method(StringIO, "each_codepoint", strio_each_codepoint, 0);
rb_define_method(StringIO, "codepoints", strio_codepoints, 0);
rb_define_method(StringIO, "getc", strio_getc, 0);
rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
rb_define_method(StringIO, "ungetbyte", strio_ungetbyte, 1);
Expand Down
30 changes: 0 additions & 30 deletions ext/zlib/zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -4003,20 +4003,6 @@ rb_gzreader_each_byte(VALUE obj)
return Qnil;
}

/*
* Document-method: Zlib::GzipReader#bytes
*
* This is a deprecated alias for <code>each_byte</code>.
*/
static VALUE
rb_gzreader_bytes(VALUE obj)
{
rb_warn("Zlib::GzipReader#bytes is deprecated; use #each_byte instead");
if (!rb_block_given_p())
return rb_enumeratorize(obj, ID2SYM(rb_intern("each_byte")), 0, 0);
return rb_gzreader_each_byte(obj);
}

/*
* Document-method: Zlib::GzipReader#ungetc
*
Expand Down Expand Up @@ -4289,20 +4275,6 @@ rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
return obj;
}

/*
* Document-method: Zlib::GzipReader#lines
*
* This is a deprecated alias for <code>each_line</code>.
*/
static VALUE
rb_gzreader_lines(int argc, VALUE *argv, VALUE obj)
{
rb_warn("Zlib::GzipReader#lines is deprecated; use #each_line instead");
if (!rb_block_given_p())
return rb_enumeratorize(obj, ID2SYM(rb_intern("each_line")), argc, argv);
return rb_gzreader_each(argc, argv, obj);
}

/*
* Document-method: Zlib::GzipReader#readlines
*
Expand Down Expand Up @@ -4763,14 +4735,12 @@ Init_zlib(void)
rb_define_method(cGzipReader, "readbyte", rb_gzreader_readbyte, 0);
rb_define_method(cGzipReader, "each_byte", rb_gzreader_each_byte, 0);
rb_define_method(cGzipReader, "each_char", rb_gzreader_each_char, 0);
rb_define_method(cGzipReader, "bytes", rb_gzreader_bytes, 0);
rb_define_method(cGzipReader, "ungetc", rb_gzreader_ungetc, 1);
rb_define_method(cGzipReader, "ungetbyte", rb_gzreader_ungetbyte, 1);
rb_define_method(cGzipReader, "gets", rb_gzreader_gets, -1);
rb_define_method(cGzipReader, "readline", rb_gzreader_readline, -1);
rb_define_method(cGzipReader, "each", rb_gzreader_each, -1);
rb_define_method(cGzipReader, "each_line", rb_gzreader_each, -1);
rb_define_method(cGzipReader, "lines", rb_gzreader_lines, -1);
rb_define_method(cGzipReader, "readlines", rb_gzreader_readlines, -1);
rb_define_method(cGzipReader, "external_encoding", rb_gzreader_external_encoding, 0);

Expand Down
117 changes: 0 additions & 117 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3958,19 +3958,6 @@ rb_io_each_line(int argc, VALUE *argv, VALUE io)
return io;
}

/*
* This is a deprecated alias for #each_line.
*/

static VALUE
rb_io_lines(int argc, VALUE *argv, VALUE io)
{
rb_warn_deprecated("IO#lines", "#each_line");
if (!rb_block_given_p())
return rb_enumeratorize(io, ID2SYM(rb_intern("each_line")), argc, argv);
return rb_io_each_line(argc, argv, io);
}

/*
* call-seq:
* ios.each_byte {|byte| block } -> ios
Expand Down Expand Up @@ -4009,19 +3996,6 @@ rb_io_each_byte(VALUE io)
return io;
}

/*
* This is a deprecated alias for #each_byte.
*/

static VALUE
rb_io_bytes(VALUE io)
{
rb_warn_deprecated("IO#bytes", "#each_byte");
if (!rb_block_given_p())
return rb_enumeratorize(io, ID2SYM(rb_intern("each_byte")), 0, 0);
return rb_io_each_byte(io);
}

static VALUE
io_getc(rb_io_t *fptr, rb_encoding *enc)
{
Expand Down Expand Up @@ -4163,20 +4137,6 @@ rb_io_each_char(VALUE io)
return io;
}

/*
* This is a deprecated alias for #each_char.
*/

static VALUE
rb_io_chars(VALUE io)
{
rb_warn_deprecated("IO#chars", "#each_char");
if (!rb_block_given_p())
return rb_enumeratorize(io, ID2SYM(rb_intern("each_char")), 0, 0);
return rb_io_each_char(io);
}


/*
* call-seq:
* ios.each_codepoint {|c| block } -> ios
Expand Down Expand Up @@ -4294,20 +4254,6 @@ rb_io_each_codepoint(VALUE io)
UNREACHABLE_RETURN(Qundef);
}

/*
* This is a deprecated alias for #each_codepoint.
*/

static VALUE
rb_io_codepoints(VALUE io)
{
rb_warn_deprecated("IO#codepoints", "#each_codepoint");
if (!rb_block_given_p())
return rb_enumeratorize(io, ID2SYM(rb_intern("each_codepoint")), 0, 0);
return rb_io_each_codepoint(io);
}


/*
* call-seq:
* ios.getc -> string or nil
Expand Down Expand Up @@ -12754,24 +12700,8 @@ argf_each_line(int argc, VALUE *argv, VALUE argf)
return argf;
}

/*
* This is a deprecated alias for #each_line.
*/

static VALUE
argf_lines(int argc, VALUE *argv, VALUE argf)
{
rb_warn_deprecated("ARGF#lines", "#each_line");
if (!rb_block_given_p())
return rb_enumeratorize(argf, ID2SYM(rb_intern("each_line")), argc, argv);
return argf_each_line(argc, argv, argf);
}

/*
* call-seq:
* ARGF.bytes {|byte| block } -> ARGF
* ARGF.bytes -> an_enumerator
*
* ARGF.each_byte {|byte| block } -> ARGF
* ARGF.each_byte -> an_enumerator
*
Expand Down Expand Up @@ -12801,19 +12731,6 @@ argf_each_byte(VALUE argf)
return argf;
}

/*
* This is a deprecated alias for #each_byte.
*/

static VALUE
argf_bytes(VALUE argf)
{
rb_warn_deprecated("ARGF#bytes", "#each_byte");
if (!rb_block_given_p())
return rb_enumeratorize(argf, ID2SYM(rb_intern("each_byte")), 0, 0);
return argf_each_byte(argf);
}

/*
* call-seq:
* ARGF.each_char {|char| block } -> ARGF
Expand All @@ -12840,19 +12757,6 @@ argf_each_char(VALUE argf)
return argf;
}

/*
* This is a deprecated alias for #each_char.
*/

static VALUE
argf_chars(VALUE argf)
{
rb_warn_deprecated("ARGF#chars", "#each_char");
if (!rb_block_given_p())
return rb_enumeratorize(argf, ID2SYM(rb_intern("each_char")), 0, 0);
return argf_each_char(argf);
}

/*
* call-seq:
* ARGF.each_codepoint {|codepoint| block } -> ARGF
Expand All @@ -12879,19 +12783,6 @@ argf_each_codepoint(VALUE argf)
return argf;
}

/*
* This is a deprecated alias for #each_codepoint.
*/

static VALUE
argf_codepoints(VALUE argf)
{
rb_warn_deprecated("ARGF#codepoints", "#each_codepoint");
if (!rb_block_given_p())
return rb_enumeratorize(argf, ID2SYM(rb_intern("each_codepoint")), 0, 0);
return argf_each_codepoint(argf);
}

/*
* call-seq:
* ARGF.filename -> String
Expand Down Expand Up @@ -13555,10 +13446,6 @@ Init_IO(void)
rb_define_method(rb_cIO, "each_byte", rb_io_each_byte, 0);
rb_define_method(rb_cIO, "each_char", rb_io_each_char, 0);
rb_define_method(rb_cIO, "each_codepoint", rb_io_each_codepoint, 0);
rb_define_method(rb_cIO, "lines", rb_io_lines, -1);
rb_define_method(rb_cIO, "bytes", rb_io_bytes, 0);
rb_define_method(rb_cIO, "chars", rb_io_chars, 0);
rb_define_method(rb_cIO, "codepoints", rb_io_codepoints, 0);

rb_define_method(rb_cIO, "syswrite", rb_io_syswrite, 1);
rb_define_method(rb_cIO, "sysread", rb_io_sysread, -1);
Expand Down Expand Up @@ -13697,10 +13584,6 @@ Init_IO(void)
rb_define_method(rb_cARGF, "each_byte", argf_each_byte, 0);
rb_define_method(rb_cARGF, "each_char", argf_each_char, 0);
rb_define_method(rb_cARGF, "each_codepoint", argf_each_codepoint, 0);
rb_define_method(rb_cARGF, "lines", argf_lines, -1);
rb_define_method(rb_cARGF, "bytes", argf_bytes, 0);
rb_define_method(rb_cARGF, "chars", argf_chars, 0);
rb_define_method(rb_cARGF, "codepoints", argf_codepoints, 0);

rb_define_method(rb_cARGF, "read", argf_read, -1);
rb_define_method(rb_cARGF, "readpartial", argf_readpartial, -1);
Expand Down
6 changes: 4 additions & 2 deletions spec/ruby/core/argf/bytes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require_relative '../../spec_helper'
require_relative 'shared/each_byte'

describe "ARGF.bytes" do
it_behaves_like :argf_each_byte, :bytes
ruby_version_is ''...'2.8' do
describe "ARGF.bytes" do
it_behaves_like :argf_each_byte, :bytes
end
end
6 changes: 4 additions & 2 deletions spec/ruby/core/argf/chars_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require_relative '../../spec_helper'
require_relative 'shared/each_char'

describe "ARGF.chars" do
it_behaves_like :argf_each_char, :chars
ruby_version_is ''...'2.8' do
describe "ARGF.chars" do
it_behaves_like :argf_each_char, :chars
end
end
6 changes: 4 additions & 2 deletions spec/ruby/core/argf/codepoints_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require_relative '../../spec_helper'
require_relative 'shared/each_codepoint'

describe "ARGF.codepoints" do
it_behaves_like :argf_each_codepoint, :codepoints
ruby_version_is ''...'2.8' do
describe "ARGF.codepoints" do
it_behaves_like :argf_each_codepoint, :codepoints
end
end
6 changes: 4 additions & 2 deletions spec/ruby/core/argf/lines_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require_relative '../../spec_helper'
require_relative 'shared/each_line'

describe "ARGF.lines" do
it_behaves_like :argf_each_line, :lines
ruby_version_is ''...'2.8' do
describe "ARGF.lines" do
it_behaves_like :argf_each_line, :lines
end
end
Loading

0 comments on commit 43b95ba

Please sign in to comment.