1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* io.c (rb_io_binmode_p, argf_binmode_p, Init_IO): new method

IO#binmode? and ARGF.binmode?  [ruby-dev:35148]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2008-06-21 15:08:57 +00:00
parent 5f2183f6b3
commit a9730c786e
2 changed files with 27 additions and 0 deletions

View file

@ -1,3 +1,8 @@
Sun Jun 22 00:01:36 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* io.c (rb_io_binmode_p, argf_binmode_p, Init_IO): new method
IO#binmode? and ARGF.binmode? [ruby-dev:35148]
Sat Jun 21 17:33:50 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (rb_w32_spawn): no longer support P_WAIT.

22
io.c
View file

@ -3167,6 +3167,20 @@ rb_io_binmode_m(VALUE io)
return io;
}
/*
* call-seq:
* ios.binmode? => true or false
*
* Returns <code>true</code> if <em>ios</em> is binmode.
*/
static VALUE
rb_io_binmode_p(VALUE io)
{
rb_io_t *fptr;
GetOpenFile(io, fptr);
return fptr->mode & FMODE_BINMODE ? Qtrue : Qfalse;
}
static const char*
rb_io_flags_mode(int flags)
{
@ -7377,6 +7391,12 @@ argf_binmode_m(VALUE argf)
return argf;
}
static VALUE
argf_binmode_p(VALUE argf)
{
return argf_binmode ? Qtrue : Qfalse;
}
static VALUE
argf_skip(VALUE argf)
{
@ -7703,6 +7723,7 @@ Init_IO(void)
rb_define_method(rb_cIO, "isatty", rb_io_isatty, 0);
rb_define_method(rb_cIO, "tty?", rb_io_isatty, 0);
rb_define_method(rb_cIO, "binmode", rb_io_binmode_m, 0);
rb_define_method(rb_cIO, "binmode?", rb_io_binmode_p, 0);
rb_define_method(rb_cIO, "sysseek", rb_io_sysseek, -1);
rb_define_method(rb_cIO, "ioctl", rb_io_ioctl, -1);
@ -7769,6 +7790,7 @@ Init_IO(void)
rb_define_method(rb_cARGF, "eof", argf_eof, 0);
rb_define_method(rb_cARGF, "eof?", argf_eof, 0);
rb_define_method(rb_cARGF, "binmode", argf_binmode_m, 0);
rb_define_method(rb_cARGF, "binmode?", argf_binmode_p, 0);
rb_define_method(rb_cARGF, "filename", argf_filename, 0);
rb_define_method(rb_cARGF, "path", argf_filename, 0);