From 4aa0fea5d6d76ec0e84beafd1f14717c626a8a4e Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 18 Aug 2008 16:33:46 +0000 Subject: * io.c (rb_open_file): encoding in mode string was ignored if perm is specified. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index ad0cb3f7a..30e407f5d 100644 --- a/io.c +++ b/io.c @@ -4506,6 +4506,12 @@ rb_open_file(int argc, VALUE *argv, VALUE io) fmode = NIL_P(perm) ? 0666 : NUM2UINT(perm); rb_file_sysopen_internal(io, RSTRING_PTR(fname), flags, fmode); + + if (!FIXNUM_P(vmode)) { + rb_io_t *fptr; + GetOpenFile(io, fptr); + rb_io_mode_enc(fptr, StringValueCStr(vmode)); + } } else { mode = NIL_P(vmode) ? "r" : StringValueCStr(vmode); -- cgit