From 73bd34c78dfa6112220aaa39af7b518840a1cc45 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Thu, 18 Jan 2024 12:04:20 +0100 Subject: [PATCH] fix line counter for skipped lines --- members/libpt-bintols/src/hedu/mod.rs | 21 ++++----------------- src/hedu/mod.rs | 4 ++-- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/members/libpt-bintols/src/hedu/mod.rs b/members/libpt-bintols/src/hedu/mod.rs index 27742f4..a9b50f3 100644 --- a/members/libpt-bintols/src/hedu/mod.rs +++ b/members/libpt-bintols/src/hedu/mod.rs @@ -150,6 +150,7 @@ pub fn dump(data: &mut dyn DataSource, config: &mut HeduConfig) -> Result<()> { if config.stop || config.len == 0 { break; } + rd_data(data, config)?; // after line logic if config.buf[0] == config.buf[1] && config.len == BYTES_PER_LINE && !config.show_identical @@ -164,7 +165,7 @@ pub fn dump(data: &mut dyn DataSource, config: &mut HeduConfig) -> Result<()> { } config.display_buf += &format!( "^^^^^^^^ {LINE_SEP_VERT} (repeats {} lines){:32}", - (config.data_idx - start_line) / (BYTES_PER_LINE * 2), + (config.data_idx - start_line) / (BYTES_PER_LINE) + 1, "" ); if config.chars { @@ -177,28 +178,14 @@ pub fn dump(data: &mut dyn DataSource, config: &mut HeduConfig) -> Result<()> { config.alt_buf ^= 1; // read into the other buf, so we can check for sameness config.display(); } - rd_data(data, config)?; } - config.data_idx += config.len; config.sep(); config.display_buf += &format!( - "{:08X} {LINE_SEP_VERT} dumped total:\t{:<8} {:<16}{:3}", - config.data_idx, - humanbytes(config.data_idx), - format!("({} B)", config.data_idx), - "" - ); - if config.chars { - config.display_buf += &format!("{LINE_SEP_VERT}"); - } - config.display(); - config.display_buf += &format!( - "{:08X} {LINE_SEP_VERT} read total:\t\t{:<8} {:<16}{:3}", + "{:08X} {LINE_SEP_VERT} read total:\t\t {:<8} {:<15}", config.rd_counter, humanbytes(config.rd_counter), - format!("({} B)", config.rd_counter), - "" + format!("({} B)", config.rd_counter) ); if config.chars { config.display_buf += &format!("{LINE_SEP_VERT}"); diff --git a/src/hedu/mod.rs b/src/hedu/mod.rs index 301fd42..05b5d34 100644 --- a/src/hedu/mod.rs +++ b/src/hedu/mod.rs @@ -101,8 +101,8 @@ fn main() { if cli.data_source.len() > 0 && cli.data_source[0] != "-" { for data_source in &cli.data_source { let data_source: PathBuf = PathBuf::from(data_source); - if !data_source.is_file() { - warn!("Not a regular file {:?}, skipping", data_source); + if data_source.is_dir() { + warn!("Not a file {:?}, skipping", data_source); // std::process::exit(1); continue; }