1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2026-01-17 10:41:03 +00:00

Merge pull request #2007 from drocco007/fold-preserve-blank-lines

fold: preserve blank lines
This commit is contained in:
Sylvestre Ledru 2021-04-02 20:00:05 +02:00 committed by GitHub
commit 4934af0c3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View file

@ -100,7 +100,10 @@ fn fold(filenames: Vec<String>, bytes: bool, spaces: bool, width: usize) {
fn fold_file<T: Read>(file: BufReader<T>, bytes: bool, spaces: bool, width: usize) {
for line_result in file.lines() {
let mut line = safe_unwrap!(line_result);
if bytes {
if line.is_empty() {
println!();
} else if bytes {
let len = line.len();
let mut i = 0;
while i < len {