This is hwzip 2.1 from https://www.hanshq.net/zip.html
Written by Hans Wennborg.

It is put in the public domain; see the LICENSE file for details.


To build it on a Unix-like system:

$ clang generate_tables.c && ./a.out > tables.c
$ clang -O3 -DNDEBUG -march=native -o hwzip crc32.c deflate.c huffman.c \
        hwzip.c implode.c lz77.c reduce.c shrink.c tables.c zip.c

To build it on Windows, in a Visual Studio Developer Command Prompt:

cl /TC generate_tables.c && generate_tables > tables.c
cl /O2 /DNDEBUG /MT /Fehwzip.exe /TC crc32.c deflate.c huffman.c hwzip.c
        implode.c lz77.c reduce.c shrink.c tables.c zip.c /link setargv.obj


For a very detailed description of how it works, see the URL above.


Version history:

2022-04-30      Version 2.1
                - Fix bugs spotted by Hadrien Dorio: the compression ratio
                  computation in zip_callback() could overflow, and the tests
                  had a number of instances of CHECK(foo = bar) instead of
                  CHECK(foo == bar).
                - Fix the CHECK macro to not suppress the compiler's warning
                  about using an assignment as a condition, which would have
                  found the CHECK bugs above.
                - Fix some -Wunused-but-set warnings from Clang 14.

2021-03-12      Version 2.0
                - Added support for Shrink, Reduce, and Implode compression and
                  decompression. See https://www.hanshq.net/zip2.html
                  To support that, the Huffman decoder now handles 16-bit
                  codewords, and LZ77 has parameters for maximum back reference
                  distance, length, and whether self-overlap is allowed.
                - Integrated the fuzzers in the Makefile.
                - Wildcard matching of test/benchmark names.
                - Various touch-ups.

2020-10-11      Version 1.4
                - Split the distance2dist table into two smaller tables,
                  reducing the hwzip binary size by 32 KB.
                - Always emit at least two non-zero dist codeword lengths for
                  Deflate blocks. This is to ensure compatibility with old zlib
                  versions and possibly other software.

2020-06-14      Version 1.3
                - Changed the minimum LZ77 backref length from 3 to 4 bytes, and
                  switched from a rolling hash to hashing 4 bytes at a time.
                  This made Deflate compression more than twice as fast on my
                  machine.

2020-05-01      Version 1.2
                - Removed use of %zu" from printfs in generate_tables.c, as that
                  would lead to generating a broken tables.c file on systems
                  where libc doesn't support the "z" length modifier.
                - Removed call to hwdeflate with NULL src argument in
                  deflate_test.c; even with zero src_len it is not valid.
                - Fixed -Wshorten-64-to-32 and -Wsign-compare warnings in 32-bit
                  builds.
                - Disabled -Wc99-extensions (new warning in Clang 10) in the
                  Makefile.

2020-03-04      Version 1.1
                - Fixed -Wextra-semi-stmt warnings reported by Horst von Brand.
                - Removed -Werror from the Makefile by default.

2020-02-25      Version 1.0
                - Initial release.
