Skip to content

Fixed IO#read with buf.#6118

Merged
matz merged 1 commit into
mruby:masterfrom
dearblue:io.read
Dec 18, 2023
Merged

Fixed IO#read with buf.#6118
matz merged 1 commit into
mruby:masterfrom
dearblue:io.read

Conversation

@dearblue

Copy link
Copy Markdown
Contributor

I hit the following two problems.

  • io.read(0, buf) always returned a new empty string object.
  • io.read(num, buf) was appending data to the given buf. This also meant that buf was never empty if EOF was reached.

I hit the following two problems.

  - `io.read(0, buf)` always returned a new empty string object.
  - `io.read(num, buf)` was appending data to the given `buf`.
    This also meant that `buf` was never empty if EOF was reached.
@dearblue dearblue requested a review from matz as a code owner December 16, 2023 05:50
@matz matz merged commit 82ed1c2 into mruby:master Dec 18, 2023
matz added a commit that referenced this pull request Dec 20, 2023
If `outbuf` is `nil` we allocate a buffer string, if `outbuf` is a
string, we resize it to zero length. In the function `io_read`, this
condition is done twice, so we refactor out to `io_reset_outbuf()`.
@dearblue dearblue deleted the io.read branch December 24, 2023 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants