[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

IO.readlines bug? (1.6.8 vs 1.8.1

Berger, Daniel

11/10/2003 8:49:00 PM

Hi all,

Ruby 1.6.8 (32 bit) / 1.8.1 (64 bit) on Solaris 9

If I have a file with a single line of data in it, but no newline, I get
different return values:

Let's say foo.pid contains "12345" (no newline).

> VERSION
=> "1.6.8"
irb(main):002:0> IO.readlines("foo.pid")
=> ["12345"]


irb(main):001:0> VERSION
=> "1.8.1"
irb(main):002:0> IO.readlines("foo.pid")
=> []

This a bug?

Regards,

Dan

4 Answers

matz

11/11/2003 1:18:00 AM

0

Hi,

In message "IO.readlines bug? (1.6.8 vs 1.8.1)"
on 03/11/11, Daniel Berger <djberge@qwest.com> writes:

|Ruby 1.6.8 (32 bit) / 1.8.1 (64 bit) on Solaris 9
|
|If I have a file with a single line of data in it, but no newline, I get
|different return values:
|
|Let's say foo.pid contains "12345" (no newline).
|
|> VERSION
|=> "1.6.8"
|irb(main):002:0> IO.readlines("foo.pid")
|=> ["12345"]
|
|
|irb(main):001:0> VERSION
|=> "1.8.1"
|irb(main):002:0> IO.readlines("foo.pid")
|=> []
|
|This a bug?

It should be. Since it works completely on my machine, it must be a
Solaris specific bug. Wish I had a Solaris box. Let me see anyway.

matz.

Eric Sunshine

11/11/2003 2:43:00 AM

0

On Tue, 11 Nov 2003 10:17:55 +0900, Yukihiro Matsumoto wrote:
> on 03/11/11, Daniel Berger <djberge@qwest.com> writes:
> |Let's say foo.pid contains "12345" (no newline).
> |irb(main):001:0> VERSION
> |=> "1.8.1"
> |irb(main):002:0> IO.readlines("foo.pid")
> |=> []
> |This a bug?
> It should be. Since it works completely on my machine, it must be a
> Solaris specific bug. Wish I had a Solaris box. Let me see anyway.

I tested on the SourceForge CompileFarm Solaris machine and was _not_ able
to reproduce this problem.

-- ES

ts

11/11/2003 11:37:00 AM

0

>>>>> "Y" == Yukihiro Matsumoto <matz@ruby-lang.org> writes:

Y> It should be. Since it works completely on my machine, it must be a
Y> Solaris specific bug. Wish I had a Solaris box. Let me see anyway.

If I'm right the bug is in the part

#ifndef READ_DATA_PENDING_PTR
if ((*bp++ = c) == delim || bp == bpe) {
cnt = bp - buf;

if (cnt > 0) {
if (!NIL_P(str))
rb_str_cat(str, buf, cnt);
else
*strp = str = rb_str_new(buf, cnt);
}
bp = buf;
}
#endif

it use a 64 bit ruby/Solaris and in its case READ_DATA_PENDING_PTR is not
defined.

Now `c' never equal `delim' (because it don't have a newline at the end),
and bp != bpe (it read only few characters) this mean that *strp is never
created if I'm right


Guy Decoux




matz

11/11/2003 1:47:00 PM

0

Hi,

In message "Re: IO.readlines bug? (1.6.8 vs 1.8.1)"
on 03/11/11, ts <decoux@moulon.inra.fr> writes:

| If I'm right the bug is in the part
|
|#ifndef READ_DATA_PENDING_PTR
| if ((*bp++ = c) == delim || bp == bpe) {
| cnt = bp - buf;
|
| if (cnt > 0) {
| if (!NIL_P(str))
| rb_str_cat(str, buf, cnt);
| else
| *strp = str = rb_str_new(buf, cnt);
| }
| bp = buf;
| }
|#endif
|
| it use a 64 bit ruby/Solaris and in its case READ_DATA_PENDING_PTR is not
| defined.

Bingo. Thank you for finding it before 1.8.2. I will fix it soon.

matz.