summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/io.c b/io.c
index ddb6d9576a..b0d4ff3ce2 100644
--- a/io.c
+++ b/io.c
@@ -4440,7 +4440,7 @@ validate_enc_binmode(int *fmode_p, int ecflags, rb_encoding *enc, rb_encoding *e
rb_raise(rb_eArgError, "ASCII incompatible encoding needs binmode");
if (!(fmode & FMODE_BINMODE) &&
- (ecflags & ECONV_NEWLINE_DECORATOR_MASK)) {
+ (DEFAULT_TEXTMODE || (ecflags & ECONV_NEWLINE_DECORATOR_MASK))) {
fmode |= DEFAULT_TEXTMODE;
*fmode_p = fmode;
}
@@ -6409,9 +6409,10 @@ static VALUE
prep_stdio(FILE *f, int fmode, VALUE klass, const char *path)
{
rb_io_t *fptr;
- VALUE io = prep_io(fileno(f), fmode|FMODE_PREP, klass, path);
+ VALUE io = prep_io(fileno(f), fmode|FMODE_PREP|DEFAULT_TEXTMODE, klass, path);
GetOpenFile(io, fptr);
+ fptr->encs.ecflags |= ECONV_DEFAULT_NEWLINE_DECORATOR;
fptr->stdio_file = f;
return io;