[前][次][番号順一覧][スレッド一覧]

ruby-changes:55663

From: Nobuyoshi <ko1@a...>
Date: Sun, 5 May 2019 14:35:53 +0900 (JST)
Subject: [ruby-changes:55663] Nobuyoshi Nakada: 374c8f4eba (trunk): Fixed about ARGF.lineno

https://git.ruby-lang.org/ruby.git/commit/?id=374c8f4eba

From 374c8f4ebab1a740990330c732b9de965c5e8d10 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 5 May 2019 14:32:45 +0900
Subject: Fixed about ARGF.lineno

[Bug #15823]

diff --git a/io.c b/io.c
index ed8bc1e..32e3a39 100644
--- a/io.c
+++ b/io.c
@@ -12393,13 +12393,21 @@ argf_block_call_line(ID mid, int argc, VALUE *argv, VALUE argf) https://github.com/ruby/ruby/blob/trunk/io.c#L12393
  *  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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]