IO.readlines bug? (1.6.8 vs 1.8.1)

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

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.

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

– ES

···

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.

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.

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

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.