mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
head: add abstractions for "all but last n lines"
Add some abstractions to simplify the `rbuf_but_last_n_lines()` function, which implements the "take all but the last `n` lines" functionality of the `head` program. This commit adds - `RingBuffer`, a fixed-size ring buffer, - `ZLines`, an iterator over zero-terminated "lines", - `TakeAllBut`, an iterator over all but the last `n` elements of an iterator. These three together make the implementation of `rbuf_but_last_n_lines()` concise.
This commit is contained in:
parent
70e65c419f
commit
bc9db289e8
12 changed files with 333 additions and 91 deletions
|
@ -129,6 +129,15 @@ fn test_zero_terminated_syntax_2() {
|
|||
.stdout_is("x\0y");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_zero_terminated_negative_lines() {
|
||||
new_ucmd!()
|
||||
.args(&["-z", "-n", "-1"])
|
||||
.pipe_in("x\0y\0z\0")
|
||||
.run()
|
||||
.stdout_is("x\0y\0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_negative_byte_syntax() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue