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

fixes #56
This commit is contained in:
Christoph J. Scherr 2024-01-17 18:08:56 +01:00
parent 714db3a9e6
commit 6e161eca5f
Signed by: PlexSheep
GPG Key ID: 7CDD0B14851A08EF
3 changed files with 10 additions and 3 deletions

View File

@ -16,8 +16,8 @@ authors = ["Christoph J. Scherr <software@cscherr.de>"]
license = "MIT" license = "MIT"
description = "Personal multitool" description = "Personal multitool"
readme = "README.md" readme = "README.md"
homepage = "https://git.cscherr.de/PlexSheep/libpt" homepage = "https://git.cscherr.de/PlexSheep/pt"
repository = "https://git.cscherr.de/PlexSheep/libpt" repository = "https://git.cscherr.de/PlexSheep/pt"
keywords = ["cli", "library"] keywords = ["cli", "library"]
categories = [ categories = [
"command-line-utilities", "command-line-utilities",

View File

@ -69,6 +69,7 @@ pub fn dump(data: &mut dyn DataSource, mut config: HeduConfig) -> Result<()> {
if config.skip > 0 { if config.skip > 0 {
data.skip(config.skip)?; data.skip(config.skip)?;
config.data_idx += config.skip; config.data_idx += config.skip;
adjust_data_idx(&mut config);
debug!("Skipped {}", humanbytes(config.skip)); debug!("Skipped {}", humanbytes(config.skip));
} }
@ -157,6 +158,11 @@ fn mask_chars(c: char) -> char {
} }
} }
#[inline]
fn adjust_data_idx(config: &mut HeduConfig) {
config.data_idx += BYTES_PER_LINE - config.data_idx % BYTES_PER_LINE;
}
fn rd_data(data: &mut dyn DataSource, config: &mut HeduConfig) -> Result<()> { fn rd_data(data: &mut dyn DataSource, config: &mut HeduConfig) -> Result<()> {
match data.read(&mut config.buf[config.alt_buf]) { match data.read(&mut config.buf[config.alt_buf]) {
Ok(mut len) => { Ok(mut len) => {
@ -177,6 +183,7 @@ fn rd_data(data: &mut dyn DataSource, config: &mut HeduConfig) -> Result<()> {
config.len = len; config.len = len;
config.rd_counter += config.len; config.rd_counter += config.len;
config.data_idx += config.len; config.data_idx += config.len;
adjust_data_idx(config);
return Ok(()); return Ok(());
} }
Err(err) => { Err(err) => {

View File

@ -6,5 +6,5 @@ NEW_VERSION=$(cat Cargo.toml | rg '^\s*version\s*=\s*"([^"]*)"\s*$' -or '$1')
bash scripts/set_all_versions.sh $NEW_VERSION bash scripts/set_all_versions.sh $NEW_VERSION
git add -A git add -A
git commit -m "Release v$NEW_VERSION" git commit -m "Release v$NEW_VERSION"
cargo ws publish --registry cscherr --amend --publish-as-is || cargo publish --registry cscherr -p libpt cargo ws publish --registry cscherr --no-git-push --publish-as-is || cargo publish --registry cscherr -p libpt
git push git push