summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-04 05:36:08 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-04 05:36:08 +0000
commit6b5e05d79251940aab2767d6ac22693205966a0d (patch)
treef5c64bc7b2dfa6a6997e39401a5d59ad55a1d887
parent6595548057f576aac620f8791d751541510584ac (diff)
downloadruby-6b5e05d79251940aab2767d6ac22693205966a0d.tar.gz
ruby-6b5e05d79251940aab2767d6ac22693205966a0d.tar.xz
ruby-6b5e05d79251940aab2767d6ac22693205966a0d.zip
* io.c (open_key_args): use rb_io_open_with_args instead of rb_f_open.
[ruby-core:15763] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c23
2 files changed, 25 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d6ee0cc9..869796b35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Mar 04 14:35:12 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * io.c (open_key_args): use rb_io_open_with_args instead of rb_f_open.
+ [ruby-core:15763]
+
Tue Mar 4 13:41:46 2008 Tanaka Akira <akr@fsij.org>
* gc.c (add_heap): fix previous change. [ruby-dev:33988]
diff --git a/io.c b/io.c
index f6e8bfb5c..f7aec9666 100644
--- a/io.c
+++ b/io.c
@@ -4093,6 +4093,24 @@ rb_io_open(const char *fname, const char *mode)
}
static VALUE
+rb_io_open_with_args(int argc, VALUE *argv)
+{
+ const char *mode;
+ VALUE pname, pmode;
+
+ if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) {
+ mode = "r";
+ }
+ else if (FIXNUM_P(pmode)) {
+ mode = rb_io_modenum_mode(FIX2INT(pmode));
+ }
+ else {
+ mode = StringValueCStr(pmode);
+ }
+ return rb_io_open(StringValueCStr(pname), mode);
+}
+
+static VALUE
io_reopen(VALUE io, VALUE nfile)
{
rb_io_t *fptr, *orig;
@@ -5927,15 +5945,14 @@ open_key_args(int argc, VALUE *argv, struct foreach_arg *arg)
rb_ary_concat(args, v);
MEMCPY(RARRAY_PTR(args)+1, RARRAY_PTR(v), VALUE, RARRAY_LEN(v));
- arg->io = rb_f_open(RARRAY_LEN(args), RARRAY_PTR(args));
+ arg->io = rb_io_open_with_args(RARRAY_LEN(args), RARRAY_PTR(args));
return;
}
v = rb_hash_aref(opt, mode);
if (!NIL_P(v)) {
arg->io = rb_io_open(RSTRING_PTR(argv[0]), StringValueCStr(v));
}
-
- if (!arg->io) {
+ else {
arg->io = rb_io_open(RSTRING_PTR(argv[0]), "r");
}