From 965ff82341d59088a6d417939fd48d6cba465149 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 12 Sep 2008 18:32:19 +0000 Subject: * iseq.c (iseq_s_compile_file): use rb_file_open_str. * io.c (rb_file_open_generic): call validate_enc_binmode. (rb_file_open_str): call FilePathValue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index 7890bcd77b..af2c7ad0a8 100644 --- a/io.c +++ b/io.c @@ -4037,18 +4037,19 @@ static VALUE rb_file_open_generic(VALUE io, VALUE filename, int oflags, int fmode, convconfig_t *convconfig, mode_t perm) { rb_io_t *fptr; + convconfig_t cc; + if (!convconfig) { + cc.enc = NULL; + cc.enc2 = NULL; + cc.ecflags = 0; + cc.ecopts = Qnil; + convconfig = &cc; + } + validate_enc_binmode(fmode, convconfig->enc, convconfig->enc2); MakeOpenFile(io, fptr); fptr->mode = fmode; - if (convconfig) { - fptr->encs = *convconfig; - } - else { - fptr->encs.enc = NULL; - fptr->encs.enc2 = NULL; - fptr->encs.ecflags = 0; - fptr->encs.ecopts = Qnil; - } + fptr->encs = *convconfig; fptr->pathv = rb_str_new_frozen(filename); fptr->fd = rb_sysopen(RSTRING_PTR(fptr->pathv), oflags, perm); io_check_tty(fptr); @@ -4084,6 +4085,7 @@ rb_file_open_internal(VALUE io, VALUE filename, const char *modestr) VALUE rb_file_open_str(VALUE fname, const char *modestr) { + FilePathValue(fname); return rb_file_open_internal(io_alloc(rb_cFile), fname, modestr); } -- cgit v1.2.3