summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ruby.c b/ruby.c
index 328912549b..cfefc04fa4 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1552,7 +1552,6 @@ load_file_internal(VALUE arg)
rb_io_ungetbyte(f, c);
}
require_libraries(opt); /* Why here? unnatural */
- rb_io_ungetbyte(f, Qnil);
}
if (opt->src.enc.index >= 0) {
enc = rb_enc_from_index(opt->src.enc.index);
@@ -1572,6 +1571,9 @@ load_file_internal(VALUE arg)
else if (f != rb_stdin) {
rb_io_close(f);
}
+ else {
+ rb_io_ungetbyte(f, Qnil);
+ }
return (VALUE)tree;
}