Merge pull request #406 from Arcterus/fold-fix

Pass the Busybox's Unicode test for fold
This commit is contained in:
Heather 2014-09-29 10:08:30 +04:00
commit f96764fc2d

View file

@ -140,19 +140,11 @@ fn fold_file<T: io::Reader>(file: BufferedReader<T>, bytes: bool, spaces: bool,
} }
} else { } else {
let mut len = line.char_len(); let mut len = line.char_len();
let newline = let newline = line.ends_with("\n");
if len == 0 { if newline {
continue;
} else if len == 1 && line.char_at(len - 1) == '\n' {
println!("");
continue;
} else if line.char_at(len - 1) == '\n' {
line = line.slice_to(line.len() - 1); line = line.slice_to(line.len() - 1);
len -= 1; len -= 1;
true }
} else {
false
};
let mut output = String::new(); let mut output = String::new();
let mut count = 0; let mut count = 0;
for (i, ch) in line.chars().enumerate() { for (i, ch) in line.chars().enumerate() {