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

ruby-changes:25689

From: kosaki <ko1@a...>
Date: Tue, 20 Nov 2012 14:02:53 +0900 (JST)
Subject: [ruby-changes:25689] kosaki:r37746 (trunk): * io.c (Init_IO): removed all rb_file_const() into file.c.

kosaki	2012-11-20 14:00:45 +0900 (Tue, 20 Nov 2012)

  New Revision: 37746

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37746

  Log:
    * io.c (Init_IO): removed all rb_file_const() into file.c.
    * file.c (Init_File): replace with rb_file_const() with
      rb_define_const() because RDoc don't care rb_file_const.
      [Bug #5530]

  Modified files:
    trunk/ChangeLog
    trunk/file.c
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37745)
+++ ChangeLog	(revision 37746)
@@ -1,3 +1,10 @@
+Tue Nov 20 13:58:11 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* io.c (Init_IO): removed all rb_file_const() into file.c.
+	* file.c (Init_File): replace with rb_file_const() with
+	  rb_define_const() because RDoc don't care rb_file_const.
+	  [Bug #5530]
+
 Tue Nov 20 12:35:00 2012  Zachary Scott  <zachary@z...>
 
 	* ruby.c (usage_msg): Fix typo [ruby-core:49205] [Bug #7327]
Index: io.c
===================================================================
--- io.c	(revision 37745)
+++ io.c	(revision 37746)
@@ -11631,58 +11631,6 @@
 
     rb_define_method(rb_cFile, "initialize",  rb_file_initialize, -1);
 
-    /* open for reading only */
-    rb_file_const("RDONLY", INT2FIX(O_RDONLY));
-    /* open for writing only */
-    rb_file_const("WRONLY", INT2FIX(O_WRONLY));
-    /* open for reading and writing */
-    rb_file_const("RDWR", INT2FIX(O_RDWR));
-    /* append on each write */
-    rb_file_const("APPEND", INT2FIX(O_APPEND));
-    /* create file if it does not exist */
-    rb_file_const("CREAT", INT2FIX(O_CREAT));
-    /* error if CREAT and the file exists */
-    rb_file_const("EXCL", INT2FIX(O_EXCL));
-#if defined(O_NDELAY) || defined(O_NONBLOCK)
-# ifndef O_NONBLOCK
-#   define O_NONBLOCK O_NDELAY
-# endif
-    /* do not block on open or for data to become available */
-    rb_file_const("NONBLOCK", INT2FIX(O_NONBLOCK));
-#endif
-    /* truncate size to 0 */
-    rb_file_const("TRUNC", INT2FIX(O_TRUNC));
-#ifdef O_NOCTTY
-    /* not to make opened IO the controlling terminal device */
-    rb_file_const("NOCTTY", INT2FIX(O_NOCTTY));
-#endif
-#ifndef O_BINARY
-# define  O_BINARY 0
-#endif
-    /* disable line code conversion */
-    rb_file_const("BINARY", INT2FIX(O_BINARY));
-#ifdef O_SYNC
-    rb_file_const("SYNC", INT2FIX(O_SYNC));
-#endif
-#ifdef O_DSYNC
-    rb_file_const("DSYNC", INT2FIX(O_DSYNC));
-#endif
-#ifdef O_RSYNC
-    rb_file_const("RSYNC", INT2FIX(O_RSYNC));
-#endif
-#ifdef O_NOFOLLOW
-    /* do not follow symlinks */
-    rb_file_const("NOFOLLOW", INT2FIX(O_NOFOLLOW)); /* FreeBSD, Linux */
-#endif
-#ifdef O_NOATIME
-    /* do not change atime */
-    rb_file_const("NOATIME", INT2FIX(O_NOATIME)); /* Linux */
-#endif
-#ifdef O_DIRECT
-    /*  Try to minimize cache effects of the I/O to and from this file. */
-    rb_file_const("DIRECT", INT2FIX(O_DIRECT));
-#endif
-
     sym_mode = ID2SYM(rb_intern("mode"));
     sym_perm = ID2SYM(rb_intern("perm"));
     sym_extenc = ID2SYM(rb_intern("external_encoding"));
Index: file.c
===================================================================
--- file.c	(revision 37745)
+++ file.c	(revision 37746)
@@ -5513,13 +5513,86 @@
 
     rb_define_method(rb_cFile, "flock", rb_file_flock, 1);
 
+    /*
+     * Document-module: File::Constants
+     *
+     * File::Constants provides file-related constants.  All possible
+     * file constants are listed in the documentation but they may not all
+     * be present on your platform.
+     *
+     * If the underlying platform doesn't define a constant the corresponding
+     * Ruby constant is not defined.
+     *
+     * Your platform documentations (e.g. man open(2)) may describe more
+     * detailed information.
+     */
     rb_mFConst = rb_define_module_under(rb_cFile, "Constants");
     rb_include_module(rb_cIO, rb_mFConst);
-    rb_file_const("LOCK_SH", INT2FIX(LOCK_SH));
-    rb_file_const("LOCK_EX", INT2FIX(LOCK_EX));
-    rb_file_const("LOCK_UN", INT2FIX(LOCK_UN));
-    rb_file_const("LOCK_NB", INT2FIX(LOCK_NB));
 
+    /* open for reading only */
+    rb_define_const(rb_mFConst, "RDONLY", INT2FIX(O_RDONLY));
+    /* open for writing only */
+    rb_define_const(rb_mFConst, "WRONLY", INT2FIX(O_WRONLY));
+    /* open for reading and writing */
+    rb_define_const(rb_mFConst, "RDWR", INT2FIX(O_RDWR));
+    /* append on each write */
+    rb_define_const(rb_mFConst, "APPEND", INT2FIX(O_APPEND));
+    /* create file if it does not exist */
+    rb_define_const(rb_mFConst, "CREAT", INT2FIX(O_CREAT));
+    /* error if CREAT and the file exists */
+    rb_define_const(rb_mFConst, "EXCL", INT2FIX(O_EXCL));
+#if defined(O_NDELAY) || defined(O_NONBLOCK)
+# ifndef O_NONBLOCK
+#   define O_NONBLOCK O_NDELAY
+# endif
+    /* do not block on open or for data to become available */
+    rb_define_const(rb_mFConst, "NONBLOCK", INT2FIX(O_NONBLOCK));
+#endif
+    /* truncate size to 0 */
+    rb_define_const(rb_mFConst, "TRUNC", INT2FIX(O_TRUNC));
+#ifdef O_NOCTTY
+    /* not to make opened IO the controlling terminal device */
+    rb_define_const(rb_mFConst, "NOCTTY", INT2FIX(O_NOCTTY));
+#endif
+#ifndef O_BINARY
+# define  O_BINARY 0
+#endif
+    /* disable line code conversion */
+    rb_define_const(rb_mFConst, "BINARY", INT2FIX(O_BINARY));
+#ifdef O_SYNC
+    /* any write operation perform synchronously */
+    rb_define_const(rb_mFConst, "SYNC", INT2FIX(O_SYNC));
+#endif
+#ifdef O_DSYNC
+    /* any write operation perform synchronously except some meta data */
+    rb_define_const(rb_mFConst, "DSYNC", INT2FIX(O_DSYNC));
+#endif
+#ifdef O_RSYNC
+    /* any read operation perform synchronously. used with SYNC or DSYNC. */
+    rb_define_const(rb_mFConst, "RSYNC", INT2FIX(O_RSYNC));
+#endif
+#ifdef O_NOFOLLOW
+    /* do not follow symlinks */
+    rb_define_const(rb_mFConst, "NOFOLLOW", INT2FIX(O_NOFOLLOW)); /* FreeBSD, Linux */
+#endif
+#ifdef O_NOATIME
+    /* do not change atime */
+    rb_define_const(rb_mFConst, "NOATIME", INT2FIX(O_NOATIME)); /* Linux */
+#endif
+#ifdef O_DIRECT
+    /*  Try to minimize cache effects of the I/O to and from this file. */
+    rb_define_const(rb_mFConst, "DIRECT", INT2FIX(O_DIRECT));
+#endif
+
+    /* shared lock. see File#flock */
+    rb_define_const(rb_mFConst, "LOCK_SH", INT2FIX(LOCK_SH));
+    /* exclusive lock. see File#flock */
+    rb_define_const(rb_mFConst, "LOCK_EX", INT2FIX(LOCK_EX));
+    /* unlock. see File#flock */
+    rb_define_const(rb_mFConst, "LOCK_UN", INT2FIX(LOCK_UN));
+    /* non-blocking lock. used with LOCK_SH or LOCK_EX. see File#flock  */
+    rb_define_const(rb_mFConst, "LOCK_NB", INT2FIX(LOCK_NB));
+
     /* Document-const: NULL
      *
      * Name of the null device

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

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