mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/stringio/stringio.c (strio_each_char, Init_stringio): Add
StringIO#{each_char,chars}. (Init_stringio): Fix StringIO#bytes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f7213e1c52
commit
f15c0dd7dd
2 changed files with 29 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
Tue May 27 19:00:22 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* ext/stringio/stringio.c (strio_each_char, Init_stringio): Add
|
||||
StringIO#{each_char,chars}.
|
||||
(Init_stringio): Fix StringIO#bytes.
|
||||
|
||||
Tue May 27 17:54:35 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||
|
||||
* ext/stringio/stringio.c (strio_each_byte): Return self instead
|
||||
|
|
|
@ -755,6 +755,25 @@ strio_readbyte(VALUE self)
|
|||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* strio.each_char {|char| block } -> strio
|
||||
*
|
||||
* See IO#each_char.
|
||||
*/
|
||||
static VALUE
|
||||
strio_each_char(VALUE self)
|
||||
{
|
||||
VALUE c;
|
||||
|
||||
RETURN_ENUMERATOR(self, 0, 0);
|
||||
|
||||
while (!NIL_P(c = strio_getc(self))) {
|
||||
rb_yield(c);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/* Boyer-Moore search: copied from regex.c */
|
||||
static void
|
||||
bm_init_skip(long *skip, const char *pat, long m)
|
||||
|
@ -1237,10 +1256,12 @@ Init_stringio()
|
|||
rb_define_method(StringIO, "path", strio_path, 0);
|
||||
|
||||
rb_define_method(StringIO, "each", strio_each, -1);
|
||||
rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
|
||||
rb_define_method(StringIO, "bytes", strio_each_byte, -1);
|
||||
rb_define_method(StringIO, "each_line", strio_each, -1);
|
||||
rb_define_method(StringIO, "lines", strio_each, -1);
|
||||
rb_define_method(StringIO, "each_byte", strio_each_byte, 0);
|
||||
rb_define_method(StringIO, "bytes", strio_each_byte, 0);
|
||||
rb_define_method(StringIO, "each_char", strio_each_char, 0);
|
||||
rb_define_method(StringIO, "chars", strio_each_char, 0);
|
||||
rb_define_method(StringIO, "getc", strio_getc, 0);
|
||||
rb_define_method(StringIO, "ungetc", strio_ungetc, 1);
|
||||
rb_define_method(StringIO, "readchar", strio_readchar, 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue