Skip to content

Conversation

@nhz2
Copy link
Member

@nhz2 nhz2 commented Mar 31, 2024

No description provided.

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
@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.

3 participants