[#30220] schedule for Ruby 1.8.6 — "Akinori MUSHA" <knu@...>

 ruby-core を読んでいない人もいると思うので、ここでもアナウンス

20 messages 2007/01/30

[ruby-dev:30081] Re: IO#lineno always returns 0

From: "Nobuyoshi Nakada" <nobu@...>
Date: 2007-01-05 05:15:47 UTC
List: ruby-dev #30081
なかだです。

At Wed, 3 Jan 2007 10:25:19 +0900,
Minero Aoki wrote in [ruby-dev:30065]:
> HEAD で IO#lineno が常に 0 を返すようになっています。

ちょうど一行の長さと同じlimitを指定したときにlinenoが進んでいません。

$ yes hello | ./miniruby.exe -e '3.times{gets(6);p STDIN.lineno}'
0
0
0

$ ./miniruby.exe -e 'open(ARGV[0]){|f|3.times{s = f.gets(39); p
[f.lineno, s]}}' ../src/version.h
[1, "#define RUBY_VERSION \"1.9.0\"\n"]
[1, "#define RUBY_RELEASE_DATE \"2007-01-04\"\n"]
[2, "#define RUBY_VERSION_CODE 190\n"]


Index: io.c
===================================================================
--- io.c	(revision 11475)
+++ io.c	(working copy)
@@ -1644,7 +1644,7 @@
     }

     if (!NIL_P(str)) {
-	if (limit != 0) {
+	if (c == EOF || c == delim) {
 	    fptr->lineno++;
 	    lineno = INT2FIX(fptr->lineno);
 	}
@@ -1740,7 +1740,7 @@
     }

     if (!NIL_P(str)) {
-	if (limit != 0) {
+	if (c == EOF || c == delim) {
 	    fptr->lineno++;
 	    lineno = INT2FIX(fptr->lineno);
 	}


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread