[ruby-dev:48176] [ruby-trunk - Feature #3526] IO::NULL; null device path name

From: nobu@...
Date: 2014-05-06 01:29:20 UTC
List: ruby-dev #48176
Issue #3526 has been updated by Nobuyoshi Nakada.

Description updated

----------------------------------------
Feature #3526: IO::NULL; null device path name
https://bugs.ruby-lang.org/issues/3526#change-46559

* Author: Nobuyoshi Nakada
* Status: Closed
* Priority: Low
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
なかだです。
 
`IO::NULL` を追加するのはどうでしょうか。
 
 ~~~diff
diff --git a/io.c b/io.c
index 05b2d45..3793ae5 100644
--- a/io.c
+++ b/io.c
@@ -9623,6 +9623,18 @@ rb_get_argv(void)
     return ARGF.argv;
 }
 
+static const char null_device[] =
+#if defined DOSISH
+    "NUL"
+#elif defined AMIGA || defined __amigaos__
+    "NIL"
+#elif defined __VMS
+    "NL:"
+#else
+    "/dev/null"
+#endif
+    ;
+
 /*
  * Document-class: IOError
  *
@@ -9956,6 +9968,8 @@ Init_IO(void)
     rb_define_method(rb_cIO, "autoclose?", rb_io_autoclose_p, 0);
     rb_define_method(rb_cIO, "autoclose=", rb_io_set_autoclose, 1);
 
+    rb_define_const(rb_cIO, "NULL", rb_obj_freeze(rb_usascii_str_new2(null_device)));
+
     rb_define_variable("$stdin", &rb_stdin);
     rb_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO, "<STDIN>");
     rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter);
~~~
---
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦





-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next