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

Utilities: Support reading arbitrarily long lines #24311

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tcl3
Copy link
Member

@tcl3 tcl3 commented May 13, 2024

This PR adds support for reading arbitrarily long lines in the comm, cut, grep and sed 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.

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label May 13, 2024
Copy link
Member

@LucasChollet LucasChollet left a 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;
Copy link
Member

Choose a reason for hiding this comment

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

Why using a pointer?

Comment on lines +671 to +672
m_buffer = make<ByteBuffer>();
TRY(m_buffer->try_resize(PAGE_SIZE));
Copy link
Member

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-flakiness 👀 pr-needs-review PR needs review from a maintainer or community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants