mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (rb_file_open_generic): take filename as a VALUE.
(rb_file_open_internal): ditto. (rb_io_open): ditto. (rb_file_open): pass filename as a VALUE to rb_file_open_internal. (rb_open_file): pass filename as a VALUE to rb_file_open_generic. (open_key_args): pass filename as a VALUE to rb_io_open. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2f59e3130c
commit
f61354c405
2 changed files with 20 additions and 10 deletions
|
@ -1,3 +1,12 @@
|
|||
Fri Aug 22 05:10:07 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* io.c (rb_file_open_generic): take filename as a VALUE.
|
||||
(rb_file_open_internal): ditto.
|
||||
(rb_io_open): ditto.
|
||||
(rb_file_open): pass filename as a VALUE to rb_file_open_internal.
|
||||
(rb_open_file): pass filename as a VALUE to rb_file_open_generic.
|
||||
(open_key_args): pass filename as a VALUE to rb_io_open.
|
||||
|
||||
Fri Aug 22 04:33:56 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* include/ruby/ruby.h: fix previous change for LP64.
|
||||
|
|
21
io.c
21
io.c
|
@ -3948,7 +3948,7 @@ io_check_tty(rb_io_t *fptr)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_file_open_generic(VALUE io, const char *fname, int modenum, int flags, convconfig_t *convconfig, mode_t perm)
|
||||
rb_file_open_generic(VALUE io, VALUE filename, int modenum, int flags, convconfig_t *convconfig, mode_t perm)
|
||||
{
|
||||
rb_io_t *fptr;
|
||||
|
||||
|
@ -3962,7 +3962,7 @@ rb_file_open_generic(VALUE io, const char *fname, int modenum, int flags, convco
|
|||
fptr->enc = NULL;
|
||||
fptr->enc2 = NULL;
|
||||
}
|
||||
fptr->path = strdup(fname);
|
||||
fptr->path = strdup(RSTRING_PTR(filename));
|
||||
fptr->fd = rb_sysopen(fptr->path, modenum, perm);
|
||||
io_check_tty(fptr);
|
||||
|
||||
|
@ -3970,7 +3970,7 @@ rb_file_open_generic(VALUE io, const char *fname, int modenum, int flags, convco
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_file_open_internal(VALUE io, const char *fname, const char *mode)
|
||||
rb_file_open_internal(VALUE io, VALUE filename, const char *mode)
|
||||
{
|
||||
int flags;
|
||||
|
||||
|
@ -3985,7 +3985,7 @@ rb_file_open_internal(VALUE io, const char *fname, const char *mode)
|
|||
}
|
||||
|
||||
flags = rb_io_mode_flags(mode);
|
||||
return rb_file_open_generic(io, fname,
|
||||
return rb_file_open_generic(io, filename,
|
||||
rb_io_flags_modenum(flags),
|
||||
flags,
|
||||
&convconfig,
|
||||
|
@ -3995,7 +3995,7 @@ rb_file_open_internal(VALUE io, const char *fname, const char *mode)
|
|||
VALUE
|
||||
rb_file_open(const char *fname, const char *mode)
|
||||
{
|
||||
return rb_file_open_internal(io_alloc(rb_cFile), fname, mode);
|
||||
return rb_file_open_internal(io_alloc(rb_cFile), rb_str_new_cstr(fname), mode);
|
||||
}
|
||||
|
||||
#if defined(__CYGWIN__) || !defined(HAVE_FORK)
|
||||
|
@ -4579,7 +4579,7 @@ rb_open_file(int argc, VALUE *argv, VALUE io)
|
|||
mode_t perm;
|
||||
|
||||
rb_scan_open_args(argc, argv, &fname, &modenum, &flags, &convconfig, &perm);
|
||||
rb_file_open_generic(io, RSTRING_PTR(fname), modenum, flags, &convconfig, perm);
|
||||
rb_file_open_generic(io, fname, modenum, flags, &convconfig, perm);
|
||||
|
||||
return io;
|
||||
}
|
||||
|
@ -4795,8 +4795,9 @@ rb_f_open(int argc, VALUE *argv)
|
|||
}
|
||||
|
||||
static VALUE
|
||||
rb_io_open(const char *fname, VALUE mode, VALUE opt)
|
||||
rb_io_open(VALUE filename, VALUE mode, VALUE opt)
|
||||
{
|
||||
char *fname = RSTRING_PTR(filename);
|
||||
int modenum, flags;
|
||||
convconfig_t convconfig;
|
||||
rb_io_extract_modeenc(&mode, opt, &modenum, &flags, &convconfig);
|
||||
|
@ -4806,7 +4807,7 @@ rb_io_open(const char *fname, VALUE mode, VALUE opt)
|
|||
return pipe_open_s(cmd, rb_io_modenum_mode(modenum), flags, &convconfig);
|
||||
}
|
||||
else {
|
||||
return rb_file_open_generic(io_alloc(rb_cFile), fname,
|
||||
return rb_file_open_generic(io_alloc(rb_cFile), filename,
|
||||
modenum, flags, &convconfig, 0666);
|
||||
}
|
||||
}
|
||||
|
@ -6700,7 +6701,7 @@ open_key_args(int argc, VALUE *argv, struct foreach_arg *arg)
|
|||
arg->argv = argv + 1;
|
||||
if (argc == 1) {
|
||||
no_key:
|
||||
arg->io = rb_io_open(RSTRING_PTR(argv[0]), INT2NUM(O_RDONLY), Qnil);
|
||||
arg->io = rb_io_open(argv[0], INT2NUM(O_RDONLY), Qnil);
|
||||
return;
|
||||
}
|
||||
opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash");
|
||||
|
@ -6722,7 +6723,7 @@ open_key_args(int argc, VALUE *argv, struct foreach_arg *arg)
|
|||
v = rb_hash_aref(opt, sym_mode);
|
||||
if (NIL_P(v))
|
||||
v = INT2NUM(O_RDONLY);
|
||||
arg->io = rb_io_open(RSTRING_PTR(argv[0]), v, opt);
|
||||
arg->io = rb_io_open(argv[0], v, opt);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
|
|
Loading…
Reference in a new issue