Repository navigation
Conversation
The input and output callbacks deal in bytes, not ASCII character codes. output gets each byte as a signed value (from HEAP8) and is never called with null. input returns 0-255, null for end of input, or undefined for no data yet. Fixes emscripten-core#17117.
There was a problem hiding this comment.
Code Review
This pull request updates the Filesystem API documentation in Filesystem-API.rst to clarify the behavior of the input and output callbacks. Specifically, it explains that these callbacks are executed once per byte, details the expected return values and ranges (including handling of undefined for EAGAIN and signed integers for output), and provides instructions on how to retrieve unsigned bytes. There are no review comments, and I have no feedback to provide.
This branch has not been deployed
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.
Fixes #17117.
The
FS.init()docs say the callbacks deal in "ASCII character codes" and thatoutputgetsnullto flush. Testing with emcc 6.0.13 on Node, that's not what happens:outputgets one call per byte, as a signed value, becausefd_writepassesHEAP8. Writing "é" gives-61, -87.outputis never called withnull, even afterfflush,fsync, or exit.inputcan return any byte 0-255.nullmeans end of input (readreturns 0), andundefinedwith nothing read yet givesEAGAIN.This only updates the docs to match. Switching
outputto unsigned bytes would change what existing callbacks see, so I left that alone, but I'm happy to look at it if you'd prefer.