BenWiederhake / splaycompress

Compression utility using Splay Trees, named ".jan" after Robert Tarjan, to enable the file extension ".tar.jan".
MIT License
3 stars 1 forks source link

Wrong output from `jan` CLI #8

Open funny-falcon opened 4 days ago

funny-falcon commented 4 days ago
$ echo "This is a simple example" | cargo run -q --features="binary" | hd
00000000  54 52 34 4c 51 0d 05 0b  04 00 00 00 00 02 00 01  |TR4LQ...........|
00000010  02 00 00 00 03 03 02 01  00 00 01 03 09 0b 03 09  |................|
00000020  04 09 03 00 00 04 08 07  07 05 05 03 02 01 00 03  |................|
00000030  00 04 06 06 04 01 00 01                           |........|
00000038
funny-falcon commented 4 days ago

It was broken at 9395f6176b4e876ec5685bff58c65482191ca29a

BenWiederhake commented 3 days ago

What other output did you expect?

Note that the round-trip still works as expected:

$ echo "This is a simple example" | cargo run -q --features=binary | cargo run -q --features=binary -- -d | hd
00000000  54 68 69 73 20 69 73 20  61 20 73 69 6d 70 6c 65  |This is a simple|
00000010  20 65 78 61 6d 70 6c 65  0a                       | example.|
00000019
$
funny-falcon commented 3 days ago

I've expected result from README:

$ echo "This is a simple example" | cargo run -q | hd
00000000  54 a8 8c 60 41 3c 1a c5  6d a5 c0 c5 a3 87 fc 05  |T..`A<..m.......|
00000010  ad a8 74 c2 a2                                    |..t..|
00000015

If not exact match, I at least expected "compression" result is not twice larger than plain text.

BenWiederhake commented 3 days ago

That is indeed a problem o.O

BenWiederhake commented 3 days ago

Oh geez, what a silly bug:

-        decompress8(r, w).unwrap();
+        compress(flavor, r, w).unwrap()

Compression and decompression is swapped :D