1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

cat: cleanup write_tab_to_end duplication of logic

The logic for '\n' and '\r' about the number of written characters was duplicated
This commit is contained in:
Michael Lohmann 2022-02-01 21:57:52 +01:00 committed by Michael Lohmann
parent 67cee26abe
commit 34b18351e2

View file

@ -560,13 +560,12 @@ fn write_tab_to_end<W: Write>(mut in_buf: &[u8], writer: &mut W) -> usize {
{
Some(p) => {
writer.write_all(&in_buf[..p]).unwrap();
if in_buf[p] == b'\n' {
return count + p;
} else if in_buf[p] == b'\t' {
if in_buf[p] == b'\t' {
writer.write_all(b"^I").unwrap();
in_buf = &in_buf[p + 1..];
count += p + 1;
} else {
// b'\n' or b'\r'
return count + p;
}
}