Skip to content

public-domain/hwzip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is hwzip 2.3 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 hwzip 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 hwzip 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 detailed description of how the program works, see the web page above.


Version history:

2024-05-20      Version 2.3
                - Fix incorrect comment about the "copy 11--138 zeros" symbol
                  in deflate.c and deflate_test.c, spotted by Nico Weber.
                - Update the Makefile to suppress new warning in Clang 18.

2023-06-10      Version 2.2
                - The Zip file format can only represent dates in the 1980--2107
                  range. Therefore, clamp the year to this range in ctime2dos().
                  This bug was found by Hadrien Dorio in his Zig translation.
                - Minor warning fixes prompted by Clang 16.
                - Update the Makefile for Clang 16, 32-bit builds, and more
                  convenient fuzzing.

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.