From d1e888c1388b840bd033e0fc25aec3d7b2cdf1b5 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Wed, 17 Jan 2024 16:21:41 +0100 Subject: [PATCH] fix hedu limit offset --- members/libpt-bintols/src/hedu/mod.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/members/libpt-bintols/src/hedu/mod.rs b/members/libpt-bintols/src/hedu/mod.rs index b4b3f33..1428a96 100644 --- a/members/libpt-bintols/src/hedu/mod.rs +++ b/members/libpt-bintols/src/hedu/mod.rs @@ -158,19 +158,14 @@ fn mask_chars(c: char) -> char { } fn rd_data(data: &mut dyn DataSource, config: &mut HeduConfig) -> Result<()> { - config.rd_counter += config.len; - config.data_idx += config.len; match data.read(&mut config.buf[config.alt_buf]) { Ok(mut len) => { - debug!( + trace!( conf = format!("{:?}", config), - dif = (config.rd_counter as i64 - config.skip as i64), - eval = (config.rd_counter as i64 - config.skip as i64) as usize >= config.limit, + eval = config.limit != 0 && config.rd_counter >= config.limit, "reached limit?" ); - if config.limit != 0 - && (config.rd_counter as i64 - config.skip as i64) as usize >= config.limit - { + if config.limit != 0 && config.rd_counter + (BYTES_PER_LINE - 1) >= config.limit { trace!( conf = format!("{:?}", config), nlen = (config.limit % BYTES_PER_LINE), @@ -180,6 +175,8 @@ fn rd_data(data: &mut dyn DataSource, config: &mut HeduConfig) -> Result<()> { config.stop = true; } config.len = len; + config.rd_counter += config.len; + config.data_idx += config.len; return Ok(()); } Err(err) => {