summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-12 18:32:19 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-12 18:32:19 +0000
commit965ff82341d59088a6d417939fd48d6cba465149 (patch)
treeda89f6e2fc231fdbf863e65544df5c931643ead9 /io.c
parent207ad0a285c1adabef466a5012c94ada47c53ab1 (diff)
* 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
Diffstat (limited to 'io.c')
-rw-r--r--io.c20
1 files changed, 11 insertions, 9 deletions
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);
}