Project

General

Profile

Bug #8625

IO#read(len, buf) shortens buf even if data is not read actually

Added by no6v (Nobuhiro IMAI) over 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.1.0dev (2013-07-11 trunk 41923) [x86_64-linux]
[ruby-core:55951]

Description

By r34580, IO#read(len, buf) does not expand buf until data is read actually,
but it still shortens if the original buf size is greater than len.
Is this an intended behavior?

def m(s)
  IO.pipe do |r, w|
    t = Thread.new{r.read(2, s)}
    Thread.pass until t.stop?
    t.kill
    t.value
  end
end

(1..3).each do |len|
  s = "x" * len
  s # => "x", "xx", "xxx"
  m(s)
  s # => "x", "xx", "xx"
end

Associated revisions

Revision 46360
Added by nobu (Nobuyoshi Nakada) over 3 years ago

io.c: not shorten buffer unless succeeded

  • io.c (io_setstrbuf, io_read): should not shorten the given buffer until read succeeds. [Bug #8625]

Revision 46360
Added by nobu (Nobuyoshi Nakada) over 3 years ago

io.c: not shorten buffer unless succeeded

  • io.c (io_setstrbuf, io_read): should not shorten the given buffer until read succeeds. [Bug #8625]

Revision 46360
Added by nobu (Nobuyoshi Nakada) over 3 years ago

io.c: not shorten buffer unless succeeded

  • io.c (io_setstrbuf, io_read): should not shorten the given buffer until read succeeds. [Bug #8625]

Revision 46360
Added by nobu (Nobuyoshi Nakada) over 3 years ago

io.c: not shorten buffer unless succeeded

  • io.c (io_setstrbuf, io_read): should not shorten the given buffer until read succeeds. [Bug #8625]

Revision 46372
Added by nobu (Nobuyoshi Nakada) over 3 years ago

io.c: truncate before appending

  • io.c (read_all): truncate the buffer before appending read data, instead of truncating before reading. [Bug #8625]

Revision 46372
Added by nobu (Nobuyoshi Nakada) over 3 years ago

io.c: truncate before appending

  • io.c (read_all): truncate the buffer before appending read data, instead of truncating before reading. [Bug #8625]

Revision 46372
Added by nobu (Nobuyoshi Nakada) over 3 years ago

io.c: truncate before appending

  • io.c (read_all): truncate the buffer before appending read data, instead of truncating before reading. [Bug #8625]

Revision 46372
Added by nobu (Nobuyoshi Nakada) over 3 years ago

io.c: truncate before appending

  • io.c (read_all): truncate the buffer before appending read data, instead of truncating before reading. [Bug #8625]

Revision 46629
Added by nagachika (Tomoyuki Chikanaga) over 3 years ago

merge revision(s) r46360,r46372: [Backport #8625]

* io.c (io_setstrbuf, io_read): should not shorten the given buffer until
  read succeeds.   [Bug #8625]

* io.c (read_all): truncate the buffer before appending read data,
  instead of truncating before reading.
   [Bug #8625]

History

#1 Updated by Glass_saga (Masaki Matsushita) over 4 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

Nakada-san, what do you think?

#2 [ruby-core:60728] Updated by Glass_saga (Masaki Matsushita) almost 4 years ago

  • Assignee changed from nobu (Nobuyoshi Nakada) to Glass_saga (Masaki Matsushita)

#3 [ruby-core:62952] Updated by nobu (Nobuyoshi Nakada) over 3 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED
  • Description updated (diff)

#4 [ruby-core:62953] Updated by nobu (Nobuyoshi Nakada) over 3 years ago

  • % Done changed from 0 to 100
  • Status changed from Assigned to Closed

Applied in changeset r46360.


io.c: not shorten buffer unless succeeded

  • io.c (io_setstrbuf, io_read): should not shorten the given buffer until read succeeds. [Bug #8625]

#5 [ruby-core:62971] Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Status changed from Closed to Assigned
  • Assignee changed from Glass_saga (Masaki Matsushita) to nobu (Nobuyoshi Nakada)

r46360 breaks some tests on mswin.

#6 [ruby-core:62976] Updated by nobu (Nobuyoshi Nakada) over 3 years ago

  • Status changed from Assigned to Closed

Applied in changeset r46372.


io.c: truncate before appending

  • io.c (read_all): truncate the buffer before appending read data, instead of truncating before reading. [Bug #8625]

#7 [ruby-core:63447] Updated by nagachika (Tomoyuki Chikanaga) over 3 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE

Backported into ruby_2_1 branch at r46629.

#8 [ruby-core:63569] Updated by usa (Usaku NAKAMURA) over 3 years ago

backported into ruby_2_0_0 at r46738.

#9 [ruby-core:63577] Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: DONE, 2.1: DONE

Also available in: Atom PDF