diff --git a/src/fmt/fmt.rs b/src/fmt/fmt.rs index 9efd0f302..79c4f7fad 100644 --- a/src/fmt/fmt.rs +++ b/src/fmt/fmt.rs @@ -206,7 +206,10 @@ pub fn uumain(args: Vec) -> i32 { let p_stream = ParagraphStream::new(&fmt_opts, &mut fp); for para_result in p_stream { match para_result { - Err(s) => silent_unwrap!(ostream.write_all(s.as_bytes())), + Err(s) => { + silent_unwrap!(ostream.write_all(s.as_bytes())); + silent_unwrap!(ostream.write_all("\n".as_bytes())); + }, Ok(para) => break_lines(¶, &fmt_opts, &mut ostream) } } diff --git a/src/fmt/parasplit.rs b/src/fmt/parasplit.rs index c02bf3961..857a9b0f2 100644 --- a/src/fmt/parasplit.rs +++ b/src/fmt/parasplit.rs @@ -100,11 +100,9 @@ impl<'a> FileLines<'a> { if !exact { // we do it this way rather than byte indexing to support unicode whitespace chars for (i, char) in line.char_indices() { - if char.is_whitespace() { - if line[i..].starts_with(pfx) { - return (true, i); - } - } else { + if line[i..].starts_with(pfx) { + return (true, i); + } else if !char.is_whitespace() { break; } } @@ -157,7 +155,7 @@ impl<'a> Iterator for FileLines<'a> { // Err(true) indicates that this was a linebreak, // which is important to know when detecting mail headers if n.chars().all(|c| c.is_whitespace()) { - return Some(Line::NoFormatLine("\n".to_owned(), true)); + return Some(Line::NoFormatLine("".to_owned(), true)); } // if this line does not match the prefix,