зеркало из https://github.com/github/ruby.git
io.c: open_key_args by rb_io_open
* io.c (open_key_args): open by rb_io_open always also when open_args: option is given. From: Nobuyoshi Nakada <nobu@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
2e24a66b88
Коммит
7d24c27d21
38
io.c
38
io.c
|
@ -7097,16 +7097,6 @@ rb_io_open_generic(VALUE filename, int oflags, int fmode,
|
|||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_io_open_with_args(int argc, const VALUE *argv)
|
||||
{
|
||||
VALUE io;
|
||||
|
||||
io = io_alloc(rb_cFile);
|
||||
rb_open_file(argc, argv, io);
|
||||
return io;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
io_reopen(VALUE io, VALUE nfile)
|
||||
{
|
||||
|
@ -10168,6 +10158,7 @@ static void
|
|||
open_key_args(int argc, VALUE *argv, VALUE opt, struct foreach_arg *arg)
|
||||
{
|
||||
VALUE path, v;
|
||||
VALUE vmode = Qnil, vperm = Qnil;
|
||||
|
||||
path = *argv++;
|
||||
argc--;
|
||||
|
@ -10176,29 +10167,18 @@ open_key_args(int argc, VALUE *argv, VALUE opt, struct foreach_arg *arg)
|
|||
arg->argc = argc;
|
||||
arg->argv = argv;
|
||||
if (NIL_P(opt)) {
|
||||
arg->io = rb_io_open(path, INT2NUM(O_RDONLY), INT2FIX(0666), Qnil);
|
||||
return;
|
||||
vmode = INT2NUM(O_RDONLY);
|
||||
vperm = INT2FIX(0666);
|
||||
}
|
||||
v = rb_hash_aref(opt, sym_open_args);
|
||||
if (!NIL_P(v)) {
|
||||
VALUE args;
|
||||
long n;
|
||||
else if (!NIL_P(v = rb_hash_aref(opt, sym_open_args))) {
|
||||
int n;
|
||||
|
||||
v = rb_to_array_type(v);
|
||||
n = RARRAY_LEN(v) + 1;
|
||||
#if SIZEOF_LONG > SIZEOF_INT
|
||||
if (n > INT_MAX) {
|
||||
rb_raise(rb_eArgError, "too many arguments");
|
||||
}
|
||||
#endif
|
||||
args = rb_ary_tmp_new(n);
|
||||
rb_ary_push(args, path);
|
||||
rb_ary_concat(args, v);
|
||||
arg->io = rb_io_open_with_args((int)n, RARRAY_CONST_PTR(args));
|
||||
rb_ary_clear(args); /* prevent from GC */
|
||||
return;
|
||||
n = RARRAY_LENINT(v);
|
||||
rb_check_arity(n, 0, 3); /* rb_io_open */
|
||||
rb_scan_args(n, RARRAY_CONST_PTR(v), "02:", &vmode, &vperm, &opt);
|
||||
}
|
||||
arg->io = rb_io_open(path, Qnil, Qnil, opt);
|
||||
arg->io = rb_io_open(path, vmode, vperm, opt);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Загрузка…
Ссылка в новой задаче