diff options
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -6025,12 +6025,9 @@ io_strip_bom(VALUE io) return ENCINDEX_UTF_32LE; } rb_io_ungetbyte(io, b4); - rb_io_ungetbyte(io, b3); - } - else { - rb_io_ungetbyte(io, b3); - return ENCINDEX_UTF_16LE; } + rb_io_ungetbyte(io, b3); + return ENCINDEX_UTF_16LE; } rb_io_ungetbyte(io, b2); break; @@ -8897,6 +8894,7 @@ rb_f_backquote(VALUE obj, VALUE str) GetOpenFile(port, fptr); result = read_all(fptr, remain_size(fptr), Qnil); rb_io_close(port); + RFILE(port)->fptr = NULL; rb_io_fptr_finalize(fptr); rb_gc_force_recycle(port); /* also guards from premature GC */ @@ -12190,13 +12188,21 @@ argf_block_call_line(ID mid, int argc, VALUE *argv, VALUE argf) * a single file consisting of the concatenation of each named file. After * the last line of the first file has been returned, the first line of the * second file is returned. The +ARGF.filename+ and +ARGF.lineno+ methods can - * be used to determine the filename and line number, respectively, of the - * current line. + * be used to determine the filename of the current line and line number of + * the whole input, respectively. * * For example, the following code prints out each line of each named file * prefixed with its line number, displaying the filename once per file: * * ARGF.each_line do |line| + * puts ARGF.filename if ARGF.file.lineno == 1 + * puts "#{ARGF.file.lineno}: #{line}" + * end + * + * While the following code prints only the first file's name at first, and + * the contents with line number counted through all named files. + * + * ARGF.each_line do |line| * puts ARGF.filename if ARGF.lineno == 1 * puts "#{ARGF.lineno}: #{line}" * end |