Skip to content

Commit d39f073

Browse files
committed
fix small bug w/ 16-bit RLE, adjust some printfs
1 parent e473e62 commit d39f073

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

compress.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ size_t unpack(uint8_t *packed, uint8_t *unpacked) {
218218
printf("Backref (rotate) : %i\n", methoduse[5]);
219219
printf("Backref (reverse): %i\n", methoduse[6]);
220220

221-
printf("Compressed size: %d bytes\n", inpos);
221+
printf("\nCompressed size: % zd bytes\n", inpos);
222222
#endif
223223

224224
return (size_t)outpos;
@@ -273,7 +273,7 @@ rle_t rle_check (uint8_t *start, uint8_t *current, uint32_t insize, int fast) {
273273

274274
// check for possible 16-bit RLE
275275
uint16_t first = current[0] | (current[1] << 8);
276-
for (size = 0; size <= LONG_RUN_SIZE && current + size < start + insize; size += 2) {
276+
for (size = 0; size <= LONG_RUN_SIZE && current + size < start + insize - 1; size += 2) {
277277
uint16_t next = current[size] | (current[size + 1] << 8);
278278
if (next != first) break;
279279
}

exhal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int main (int argc, char **argv) {
5151
fseek(outfile, 0, SEEK_SET);
5252
fwrite((const void*)unpacked, 1, outputsize, outfile);
5353

54-
printf("\nUncompressed size: %zd bytes\n", outputsize);
54+
printf("Uncompressed size: % zd bytes\n", outputsize);
5555

5656
fclose(infile);
5757
fclose(outfile);

inhal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ int main (int argc, char **argv) {
7575
fseek(infile, 0, SEEK_END);
7676
inputsize = ftell(infile);
7777

78-
printf("Uncompressed size: %zd bytes\n", inputsize);
78+
printf("Uncompressed size: % zd bytes\n", inputsize);
7979

8080
if (inputsize > DATA_SIZE) {
8181
printf("Error: File must be a maximum of 65,536 bytes!\n");
@@ -94,9 +94,9 @@ int main (int argc, char **argv) {
9494
fseek(outfile, fileoffset, SEEK_SET);
9595
fwrite((const void*)packed, 1, outputsize, outfile);
9696

97-
printf("Compressed size: %zd bytes\n", outputsize);
98-
printf("Compression ratio: %4.2f%%\n", 100 * (double)outputsize / inputsize);
99-
printf("Compression time: %4.3f seconds\n\n", (double)time / CLOCKS_PER_SEC);
97+
printf("Compressed size: % zd bytes\n", outputsize);
98+
printf("Compression ratio: %4.2f%%\n", 100 * (double)outputsize / inputsize);
99+
printf("Compression time: %4.3f seconds\n\n", (double)time / CLOCKS_PER_SEC);
100100

101101
printf("Inserted at 0x%06X - 0x%06lX\n", fileoffset, ftell(outfile) - 1);
102102

0 commit comments

Comments
 (0)