1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

expand: all perl tests passing

This commit is contained in:
Sebastian Bentmar Holgersson 2023-01-03 20:49:20 +00:00 committed by Sylvestre Ledru
parent cbab8677e6
commit ddc6fabca0
2 changed files with 22 additions and 3 deletions

View file

@ -348,7 +348,16 @@ fn next_tabstop(tabstops: &[usize], col: usize, remaining_mode: &RemainingMode)
match remaining_mode { match remaining_mode {
RemainingMode::Plus => match tabstops[0..num_tabstops - 1].iter().find(|&&t| t > col) { RemainingMode::Plus => match tabstops[0..num_tabstops - 1].iter().find(|&&t| t > col) {
Some(t) => t - col, Some(t) => t - col,
None => tabstops[num_tabstops - 1] - 1, None => {
let step_size = tabstops[num_tabstops - 1];
let last_before_repeating = tabstops[num_tabstops-2];
let mut r = last_before_repeating+step_size;
while col >= r {
r += step_size;
}
r - col
}
}, },
RemainingMode::Slash => match tabstops[0..num_tabstops - 1].iter().find(|&&t| t > col) { RemainingMode::Slash => match tabstops[0..num_tabstops - 1].iter().find(|&&t| t > col) {
Some(t) => t - col, Some(t) => t - col,
@ -376,7 +385,7 @@ enum CharType {
fn expand(options: &Options) -> std::io::Result<()> { fn expand(options: &Options) -> std::io::Result<()> {
use self::CharType::*; use self::CharType::*;
println!("{:?}", options);
let mut output = BufWriter::new(stdout()); let mut output = BufWriter::new(stdout());
let ts = options.tabstops.as_ref(); let ts = options.tabstops.as_ref();
let mut buf = Vec::new(); let mut buf = Vec::new();

View file

@ -353,7 +353,17 @@ fn test_ignore_initial_plus_slash_combination() {
fn test_comma_with_plus_and_multi_character_values() { fn test_comma_with_plus_and_multi_character_values() {
new_ucmd!() new_ucmd!()
.args(&["--tabs=3,+6"]) .args(&["--tabs=3,+6"])
.pipe_in("\taaa\tbbbb\tcccc") .pipe_in("\taaa\tbbb\tccc")
.succeeds()
// 01234567890
.stdout_is(" aaa bbb ccc");
}
#[test]
fn test_comma_with_plus_and_multi_character_values() {
new_ucmd!()
.args(&["--tabs=3,+6"])
.pipe_in("\taaa\tbbb\tccc")
.succeeds() .succeeds()
// 01234567890 // 01234567890
.stdout_is(" aaa bbb ccc"); .stdout_is(" aaa bbb ccc");