Add an feof callback to Prism stream parsing#3602
Merged
Merged
Conversation
kddnewton
approved these changes
Jul 18, 2025
kddnewton
left a comment
Collaborator
There was a problem hiding this comment.
Looks right, though I think the FFI build is having issues.
Member
Author
Ya, I'm trying to figure out the FFI issues :| |
Collaborator
|
Looks like we just need documentation on the new callback (https://github.com/ruby/prism/actions/runs/16603543403/job/46969381276?pr=3602#step:8:153). memcheck is an expected failure, and the test-all failure is telling us we need to merge this into ruby/ruby first. |
Checking the return value of `fgets` isn't good enough to determine whether the input stream has reached EOF or not. `fgets` could have run in to an error and returned NULL. Additionally, we can't just check the buffer contents for `\n` because `fgets` could have read the maximum buffer size (which may not have ended with a `\n`). I want to use this callback to implement a fix for: https://bugs.ruby-lang.org/issues/21188
tenderlove
force-pushed
the
eof-callback
branch
from
August 1, 2025 17:36
1be6ad9 to
802a123
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checking the return value of
fgetsisn't good enough to determine whether the input stream has reached EOF or not.fgetscould have run in to an error and returned NULL. Additionally, we can't just check the buffer contents for\nbecausefgetscould have read the maximum buffer size (which may not have ended with a\n).I want to use this callback to implement a fix for:
https://bugs.ruby-lang.org/issues/21188