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:
parent
67cee26abe
commit
34b18351e2
1 changed files with 2 additions and 3 deletions
|
@ -560,13 +560,12 @@ fn write_tab_to_end<W: Write>(mut in_buf: &[u8], writer: &mut W) -> usize {
|
||||||
{
|
{
|
||||||
Some(p) => {
|
Some(p) => {
|
||||||
writer.write_all(&in_buf[..p]).unwrap();
|
writer.write_all(&in_buf[..p]).unwrap();
|
||||||
if in_buf[p] == b'\n' {
|
if in_buf[p] == b'\t' {
|
||||||
return count + p;
|
|
||||||
} else if in_buf[p] == b'\t' {
|
|
||||||
writer.write_all(b"^I").unwrap();
|
writer.write_all(b"^I").unwrap();
|
||||||
in_buf = &in_buf[p + 1..];
|
in_buf = &in_buf[p + 1..];
|
||||||
count += p + 1;
|
count += p + 1;
|
||||||
} else {
|
} else {
|
||||||
|
// b'\n' or b'\r'
|
||||||
return count + p;
|
return count + p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue