[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:=20
* Category:=20
* Target version:=20
----------------------------------------
=E3=81=AA=E3=81=8B=E3=81=A0=E3=81=A7=E3=81=99=E3=80=82
=20
`IO::NULL` =E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B=E3=81=AE=E3=81=AF=
=E3=81=A9=E3=81=86=E3=81=A7=E3=81=97=E3=82=87=E3=81=86=E3=81=8B=E3=80=82
=20
 ~~~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;
 }
=20
+static const char null_device[] =3D
+#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=3D", rb_io_set_autoclose, 1);
=20
+    rb_define_const(rb_cIO, "NULL", rb_obj_freeze(rb_usascii_str_new2(null=
_device)));
+
     rb_define_variable("$stdin", &rb_stdin);
     rb_stdin =3D prep_stdio(stdin, FMODE_READABLE, rb_cIO, "<STDIN>");
     rb_define_hooked_variable("$stdout", &rb_stdout, 0, stdout_setter);
~~~
---
--- =E5=83=95=E3=81=AE=E5=89=8D=E3=81=ABBug=E3=81=AF=E3=81=AA=E3=81=84=E3=
=80=82
--- =E5=83=95=E3=81=AE=E5=BE=8C=E3=82=8D=E3=81=ABBug=E3=81=AF=E3=81=A7=E3=
=81=8D=E3=82=8B=E3=80=82
    =E4=B8=AD=E7=94=B0 =E4=BC=B8=E6=82=A6





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

In This Thread

Prev Next