summaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-21 18:03:52 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-21 18:03:52 +0000
commit595309d50304bebcc586dea8dd6e9dce6d8f21ed (patch)
tree7eea59f0bff7d5cfce8e74bb07b665dc5229b7a3 /io.c
parent339f917b5490bad0359188c0082d8a50e4b24da4 (diff)
downloadruby-595309d50304bebcc586dea8dd6e9dce6d8f21ed.tar.gz
ruby-595309d50304bebcc586dea8dd6e9dce6d8f21ed.tar.xz
ruby-595309d50304bebcc586dea8dd6e9dce6d8f21ed.zip
* io.c (rb_io_s_sysopen): mode can be a Bignum.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/io.c b/io.c
index 1e3e2c338..f0626d0d6 100644
--- a/io.c
+++ b/io.c
@@ -4624,25 +4624,28 @@ static VALUE
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);
}