Skip to content
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

Make mark consistent with skip and IOBuffer #201

Merged
merged 5 commits into from
Mar 31, 2024
Merged

Conversation

nhz2
Copy link
Member

@nhz2 nhz2 commented Mar 31, 2024

No description provided.

ok &= eof(stream)
ok &= isreadable(stream)
close(stream)
end
# read without stop_on_end should read the full data.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test isn't related to this PR but was something I noticed wasn't covered by current tests.

checkmode(stream)
return mark!(stream.buffer1)
function Base.mark(stream::TranscodingStream)::Int64
ready_to_read!(stream)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This throws an error if mark is used on a stream in write, close, or panic modes.

if mode === :read || mode === :stop
while !eof(stream) && buffersize(buffer1) < offset - skipped
n = buffersize(buffer1)
emptybuffer!(buffer1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of emptybuffer! here was discarding potentially marked data.

skipbuffer!(buffer1, offset - skipped)
end
else
# TODO: support skip in write mode
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this TODO means, but I add a docstring to clarify that skip behaves like a read that ignores eof and discards the read bytes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also moved the skip to be near the other read functions

@nhz2 nhz2 marked this pull request as ready for review March 31, 2024 00:30
@nhz2 nhz2 requested a review from mkitti March 31, 2024 00:32
Copy link
Member

@mkitti mkitti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@nhz2 nhz2 merged commit 9617908 into master Mar 31, 2024
23 checks passed
@nhz2 nhz2 deleted the fix-skip-with-mark branch March 31, 2024 15:06
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.

2 participants