diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-21 20:12:29 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-21 20:12:29 +0000 |
commit | f61354c40577276ebc6ef4dee9aadcaa3b59f97c (patch) | |
tree | 0ce4f4202f5c4e050b3f40024814e8038b1deb11 | |
parent | 2f59e3130c0f9be681ade633bbabf41f40a5435f (diff) | |
download | ruby-f61354c40577276ebc6ef4dee9aadcaa3b59f97c.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | io.c | 21 |
2 files changed, 20 insertions, 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. @@ -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 |