fix hedu limit offset
cargo devel CI / cargo CI (push) Has been cancelled Details

This commit is contained in:
Christoph J. Scherr 2024-01-17 16:21:41 +01:00
parent 9f27db1ce3
commit d1e888c138
Signed by: cscherrNT
GPG Key ID: 8E2B45BC51A27EA7
1 changed files with 5 additions and 8 deletions

View File

@ -158,19 +158,14 @@ fn mask_chars(c: char) -> char {
} }
fn rd_data(data: &mut dyn DataSource, config: &mut HeduConfig) -> Result<()> { 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]) { match data.read(&mut config.buf[config.alt_buf]) {
Ok(mut len) => { Ok(mut len) => {
debug!( trace!(
conf = format!("{:?}", config), conf = format!("{:?}", config),
dif = (config.rd_counter as i64 - config.skip as i64), eval = config.limit != 0 && config.rd_counter >= config.limit,
eval = (config.rd_counter as i64 - config.skip as i64) as usize >= config.limit,
"reached limit?" "reached limit?"
); );
if config.limit != 0 if config.limit != 0 && config.rd_counter + (BYTES_PER_LINE - 1) >= config.limit {
&& (config.rd_counter as i64 - config.skip as i64) as usize >= config.limit
{
trace!( trace!(
conf = format!("{:?}", config), conf = format!("{:?}", config),
nlen = (config.limit % BYTES_PER_LINE), 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.stop = true;
} }
config.len = len; config.len = len;
config.rd_counter += config.len;
config.data_idx += config.len;
return Ok(()); return Ok(());
} }
Err(err) => { Err(err) => {