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

ruby-changes:7242

From: akr <ko1@a...>
Date: Fri, 22 Aug 2008 03:04:05 +0900 (JST)
Subject: [ruby-changes:7242] Ruby:r18761 (trunk): * io.c (rb_io_s_sysopen): mode can be a Bignum.

akr	2008-08-22 03:03:52 +0900 (Fri, 22 Aug 2008)

  New Revision: 18761

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

  Log:
    * io.c (rb_io_s_sysopen): mode can be a Bignum.

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18760)
+++ ChangeLog	(revision 18761)
@@ -1,3 +1,7 @@
+Fri Aug 22 03:03:22 2008  Tanaka Akira  <akr@f...>
+
+	* io.c (rb_io_s_sysopen): mode can be a Bignum.
+
 Fri Aug 22 02:57:03 2008  Tanaka Akira  <akr@f...>
 
 	* io.c (rb_io_extract_modeenc): notify coerced to caller.
Index: io.c
===================================================================
--- io.c	(revision 18760)
+++ io.c	(revision 18761)
@@ -4624,25 +4624,28 @@
 rb_io_s_sysopen(int argc, VALUE *argv)
 {
     VALUE fname, vmode, vperm;
-    int flags, fd;
+    VALUE intmode;
+    int modenum, fd;
     mode_t perm;
     char *path;
 
     rb_scan_args(argc, argv, "12", &fname, &vmode, &vperm);
     FilePathValue(fname);
 
-    if (NIL_P(vmode)) flags = O_RDONLY;
-    else if (FIXNUM_P(vmode)) flags = FIX2INT(vmode);
+    if (NIL_P(vmode))
+        modenum = O_RDONLY;
+    else if (!NIL_P(intmode = rb_check_to_integer(vmode, "to_int")))
+        modenum = NUM2INT(intmode);
     else {
 	SafeStringValue(vmode);
-	flags = rb_io_mode_modenum(StringValueCStr(vmode));
+	modenum = rb_io_mode_modenum(StringValueCStr(vmode));
     }
     if (NIL_P(vperm)) perm = 0666;
     else              perm = NUM2UINT(vperm);
 
     RB_GC_GUARD(fname) = rb_str_new4(fname);
     path = RSTRING_PTR(fname);
-    fd = rb_sysopen(path, flags, perm);
+    fd = rb_sysopen(path, modenum, perm);
     return INT2NUM(fd);
 }
 

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

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