summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--io.c7
2 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 1051ebde2..6b497d3c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,11 @@ Fri Dec 21 12:16:50 2007 Tanaka Akira <akr@fsij.org>
* string.c (rb_str_is_ascii_only_p): new method ascii_only?.
+Fri Dec 21 12:11:57 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_mode_enc): set default external encoding if no
+ encoding specified explicitly.
+
Fri Dec 21 12:00:34 2007 Tanaka Akira <akr@fsij.org>
* configure.in: check langinfo.h and locale.h.
diff --git a/io.c b/io.c
index e07845fb3..89d15cac8 100644
--- a/io.c
+++ b/io.c
@@ -3068,6 +3068,9 @@ rb_io_mode_enc(rb_io_t *fptr, const char *mode)
}
#endif
}
+ else if (!(fptr->mode & FMODE_BINMODE)) {
+ fptr->enc = rb_default_external_encoding();
+ }
}
struct sysopen_struct {
@@ -3188,8 +3191,8 @@ rb_file_open_internal(VALUE io, const char *fname, const char *mode)
rb_io_t *fptr;
MakeOpenFile(io, fptr);
- rb_io_mode_enc(fptr, mode);
fptr->mode = rb_io_mode_flags(mode);
+ rb_io_mode_enc(fptr, mode);
fptr->path = strdup(fname);
fptr->fd = rb_sysopen(fptr->path, rb_io_mode_modenum(rb_io_flags_mode(fptr->mode)), 0666);
io_check_tty(fptr);
@@ -3498,10 +3501,10 @@ pipe_open(const char *cmd, int argc, VALUE *argv, const char *mode)
port = io_alloc(rb_cIO);
MakeOpenFile(port, fptr);
- rb_io_mode_enc(fptr, mode);
fptr->fd = fd;
fptr->stdio_file = fp;
fptr->mode = modef | FMODE_SYNC|FMODE_DUPLEX;
+ rb_io_mode_enc(fptr, mode);
fptr->pid = pid;
if (0 <= write_fd) {