IO.readlines bug? (1.6.8 vs 1.8.1)

D

Daniel Berger

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).
=> "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
 
Y

Yukihiro Matsumoto

Hi,

In message "IO.readlines bug? (1.6.8 vs 1.8.1)"

|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.
 
E

Eric Sunshine

|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
 
T

ts

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
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: IO.readlines bug? (1.6.8 vs 1.8.1)"

| 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

IO.pos bug? 5
A bug in logical 'or' with regexp? 3
parentheses and newlines 2
Is this a bug in Time.local? 2
pack bug on 64-bit ruby 0
cannot load watir 7
UnboundMethod#hash apparently broken in 1.8.1 8
:IRB Bug 1

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top