-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Utilities: Support reading arbitrarily long lines #24311
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpick, but otherwise LGTM!
@@ -711,8 +715,7 @@ class File { | |||
OwnPtr<FileSystem::TempFile> m_output_temp_file; | |||
size_t m_line_number { 0 }; | |||
ByteString m_current_line; | |||
constexpr static size_t MAX_SUPPORTED_LINE_SIZE = 4096; | |||
Array<u8, MAX_SUPPORTED_LINE_SIZE> m_buffer; | |||
OwnPtr<ByteBuffer> m_buffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using a pointer?
m_buffer = make<ByteBuffer>(); | ||
TRY(m_buffer->try_resize(PAGE_SIZE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then this can be a create_uninitialized()
This PR adds support for reading arbitrarily long lines in the
comm
,cut
,grep
andsed
utilities.Previously, these utilities wouldn't behave correctly when working with input containing lines longer than 4KiB.
I've also included a drive-by commit to fix an off-by-one error in
cut
, which led to the last character on each line being skipped when the-b
or-c
option was used.