Skip to content

Commit

Permalink
Improve encoding of repeated followed by literal.
Browse files Browse the repository at this point in the history
Update test suite and allow alternate encodings as long as they are the same
length.
  • Loading branch information
michaelrsweet committed Nov 21, 2024
1 parent b87ff2a commit 8c7aa92
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lprint-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ lprintPackBitsCompress(
}

// Encode repeated byte sequences...
while (srcrcount > 0)
while (srcrcount > 1)
{
if (srcrcount > 128)
count = 128;
Expand All @@ -803,7 +803,7 @@ lprintPackBitsCompress(
}

// Reset the literal pointer and continue...
srclptr = srcptr;
srclptr = srcptr - srcrcount;
}

return ((size_t)(dstptr - dst));
Expand Down
12 changes: 1 addition & 11 deletions testpackbits.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,9 @@ main(int argc, // I - Number of command-line arguments
if ((dstlen = lprintPackBitsCompress(dst, (unsigned char *)cases[i].input, cases[i].inlen)) == cases[i].outlen)
{
if (!memcmp(dst, cases[i].output, cases[i].outlen))
{
testEnd(true);
}
else
{
testEndMessage(false, "compressed bytes don't match");
testError("\nSource Buffer:");
testHexDump((unsigned char *)cases[i].input, cases[i].inlen);
testError("\nDestination Buffer:");
testHexDump(dst, dstlen);
testError("\nExpected Buffer:");
testHexDump((unsigned char *)cases[i].output, cases[i].outlen);
}
testEndMessage(true, "alternate bytes OK");
}
else
{
Expand Down

0 comments on commit 8c7aa92

Please sign in to comment.