Project

General

Profile

Actions

Bug #8625

closed

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

Added by no6v (Nobuhiro IMAI) almost 11 years ago. Updated almost 10 years ago.

Status:
Closed
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
Actions #1

Updated by Glass_saga (Masaki Matsushita) over 10 years ago

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

Nakada-san, what do you think?

Updated by Glass_saga (Masaki Matsushita) about 10 years ago

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

Updated by nobu (Nobuyoshi Nakada) almost 10 years ago

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

Updated by nobu (Nobuyoshi Nakada) almost 10 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. [ruby-core:55951] [Bug #8625]

Updated by usa (Usaku NAKAMURA) almost 10 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.

Updated by nobu (Nobuyoshi Nakada) almost 10 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.
    [ruby-core:55951] [Bug #8625]

Updated by nagachika (Tomoyuki Chikanaga) almost 10 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.

Updated by usa (Usaku NAKAMURA) almost 10 years ago

backported into ruby_2_0_0 at r46738.

Updated by usa (Usaku NAKAMURA) almost 10 years ago

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0