[前][次][番号順一覧][スレッド一覧]

ruby-changes:5997

From: usa <ko1@a...>
Date: Sun, 22 Jun 2008 00:09:13 +0900 (JST)
Subject: [ruby-changes:5997] Ruby:r17507 (trunk): * io.c (rb_io_binmode_p, argf_binmode_p, Init_IO): new method

usa	2008-06-22 00:08:57 +0900 (Sun, 22 Jun 2008)

  New Revision: 17507

  Modified files:
    trunk/ChangeLog
    trunk/io.c

  Log:
    * io.c (rb_io_binmode_p, argf_binmode_p, Init_IO): new method
      IO#binmode? and ARGF.binmode?  [ruby-dev:35148]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17507&r2=17506&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/io.c?r1=17507&r2=17506&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17506)
+++ ChangeLog	(revision 17507)
@@ -1,3 +1,8 @@
+Sun Jun 22 00:01:36 2008  NAKAMURA Usaku  <usa@r...>
+
+	* 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@r...>
 
 	* win32/win32.c (rb_w32_spawn): no longer support P_WAIT.
Index: io.c
===================================================================
--- io.c	(revision 17506)
+++ io.c	(revision 17507)
@@ -3167,6 +3167,20 @@
     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)
 {
@@ -7378,6 +7392,12 @@
 }
 
 static VALUE
+argf_binmode_p(VALUE argf)
+{
+    return argf_binmode ? Qtrue : Qfalse;
+}
+
+static VALUE
 argf_skip(VALUE argf)
 {
     if (next_p != -1) {
@@ -7703,6 +7723,7 @@
     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 @@
     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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]