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

paste: permit the delimiter list to be empty #6714

Merged

Conversation

andrewliebenow
Copy link
Contributor

Also: refactored the delimiter processing logic

Also: refactored the delimiter processing logic
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
GNU test failed: tests/timeout/timeout. tests/timeout/timeout is passing on 'main'. Maybe you have to rebase?

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
GNU test failed: tests/timeout/timeout. tests/timeout/timeout is passing on 'main'. Maybe you have to rebase?

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
GNU test failed: tests/timeout/timeout. tests/timeout/timeout is passing on 'main'. Maybe you have to rebase?

@andrewliebenow andrewliebenow force-pushed the paste-accept-empty-delimiter-list branch 2 times, most recently from f2928fc to a302d62 Compare September 27, 2024 19:38
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
GNU test failed: tests/timeout/timeout. tests/timeout/timeout is passing on 'main'. Maybe you have to rebase?

Comment on lines 108 to 112
// Is `map_err_context` correct here?
let file = File::open(path).map_err_context(String::new)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

map_err_context itself looks correct to me, but not the String::new passed to it. I think it should be || name instead.

src/uu/paste/src/paste.rs Outdated Show resolved Hide resolved
Comment on lines 268 to 301
OneDelimiter {
delimiter: &'a [u8],
},
MultipleDelimiters {
current_delimiter: &'a [u8],
delimiters: &'a [Box<[u8]>],
delimiters_iter: Cycle<Iter<'a, Box<[u8]>>>,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to distinguish between a single delimiter and multiple delimiters? At least conceptually you could say there is no single delimiter, only an infinite list of delimiters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It just allows that case to be handled in a slightly cleaner/more efficient way, because we don't have to bother uselessly advancing a cycling iterator over a single element slice, and constantly recomputing the length of that single element. If you have a strong objection, I'm fine with removing it.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I don't have a strong objection, it's fine.

@andrewliebenow andrewliebenow force-pushed the paste-accept-empty-delimiter-list branch 2 times, most recently from 11af996 to f096a21 Compare October 8, 2024 11:41
Copy link

github-actions bot commented Oct 8, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1 (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/rm/rm2 is no longer failing!

@andrewliebenow andrewliebenow force-pushed the paste-accept-empty-delimiter-list branch from 8bb8a26 to 5a54253 Compare October 8, 2024 15:41
Copy link

github-actions bot commented Oct 8, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1 (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/rm/rm2 is no longer failing!

Copy link

github-actions bot commented Oct 9, 2024

GNU testsuite comparison:

Skip an intermittent issue tests/rm/rm1 (fails in this run but passes in the 'main' branch)
GNU test failed: tests/timeout/timeout. tests/timeout/timeout is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/rm/rm2 is no longer failing!

Comment on lines +253 to +262
#[test]
fn test_non_utf8_input() {
// 0xC0 is not valid UTF-8
const INPUT: &[u8] = b"Non-UTF-8 test: \xC0\x00\xC0.\n";

new_ucmd!()
.pipe_in(INPUT)
.succeeds()
.stdout_only_bytes(INPUT);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Great improvement compared to the previous version with all its consts :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cakebaker cakebaker merged commit c41c601 into uutils:main Oct 10, 2024
66 of 68 checks passed
@cakebaker
Copy link
Contributor

Thanks!

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