Skip to content

Fixed IO#read with buf. #6118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2023
Merged

Fixed IO#read with buf. #6118

merged 1 commit into from
Dec 18, 2023

Conversation

dearblue
Copy link
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