Skip to content

fix std.Io.Reader delimiter functions - #25162

Closed
truly-not-taken wants to merge 11 commits into
ziglang:masterfrom
truly-not-taken:take_delimiter_exclusive
Closed

truly-not-taken wants to merge 11 commits into
ziglang:masterfrom
truly-not-taken:take_delimiter_exclusive

Conversation

@truly-not-taken

@truly-not-taken truly-not-taken commented Sep 6, 2025 •

Copy link
Copy Markdown

I finally feel good about this fix. No more hacks or tricks. Just call stream() one more time to detect end of stream in fixed Reader.

The performance should not suffer. Normal reading from a file line by line only triggers this if the buffer is shorter than the line. This should be a rare condition.

fixes #24950
fixes #25132

pancelor and others added 8 commits September 3, 2025 03:44
these would catch the problems that takeDelimiter had,
if those problems were present in the other functions (they weren't)
call vtable.rebase() to discriminate error.StreamTooLong from error.EndOfStream
@truly-not-taken truly-not-taken changed the title fix https://github.com/ziglang/zig/issues/24950 and https://github.com/ziglang/zig/issues/25132 fix std.Io.Reader delimiter functions Sep 6, 2025
andrewrk added a commit that referenced this pull request Oct 9, 2025
Now it's based on calling fillMore rather than an illegal aliased stream
into the Reader buffer.

This commit also includes a disambiguation block inspired by #25162. If
`StreamTooLong` was added to `RebaseError` then this logic could be
replaced by removing the exit condition from the while loop. That error
code would represent when `buffer` capacity is too small for an
operation, replacing the current use of asserts.
@andrewrk

andrewrk commented Oct 9, 2025

Copy link
Copy Markdown
Member

Nice, that's a decent strategy. I made some changes inspired by this in #25512. After that lands, the next step will be to rebase this and check in on the status of issues and added unit tests.

andrewrk added a commit that referenced this pull request Oct 9, 2025
Now it's based on calling fillMore rather than an illegal aliased stream
into the Reader buffer.

This commit also includes a disambiguation block inspired by #25162. If
`StreamTooLong` was added to `RebaseError` then this logic could be
replaced by removing the exit condition from the while loop. That error
code would represent when `buffer` capacity is too small for an
operation, replacing the current use of asserts.
@truly-not-taken truly-not-taken closed this by deleting the head repository Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

std.Io.takeDelimiter tosses too many characters std.Io.Reader.takeDelimiterExclusive() return error.StreamTooLong instead of error.EndOfStream

3 participants