From 3f91138f3a9fec0250f46d1849cdd42cb9254faf Mon Sep 17 00:00:00 2001 From: AF <33097027+f3fora@users.noreply.github.com> Date: Mon, 6 Jan 2025 19:29:31 +0100 Subject: [PATCH] fix: correct edge values of window_bits (#60) * fix: correct edge values of window_bits see https://docs.python.org/3/library/zlib.html * Update src/compression.jl * Update src/compression.jl * Update src/decompression.jl * Update src/decompression.jl * Make docstring match error. --------- Co-authored-by: Nathan Zimmerberg <39104088+nhz2@users.noreply.github.com> --- src/compression.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compression.jl b/src/compression.jl index 08ed23d..82955fc 100644 --- a/src/compression.jl +++ b/src/compression.jl @@ -25,14 +25,14 @@ Create a gzip compression codec. Arguments --------- - `level`: compression level (-1..9) -- `windowbits`: size of history buffer (8..15) +- `windowbits`: size of history buffer (9..15) """ function GzipCompressor(;level::Integer=Z_DEFAULT_COMPRESSION, windowbits::Integer=Z_DEFAULT_WINDOWBITS) if !(-1 ≤ level ≤ 9) throw(ArgumentError("compression level must be within -1..9")) - elseif !(8 ≤ windowbits ≤ 15) - throw(ArgumentError("windowbits must be within 8..15")) + elseif !(9 ≤ windowbits ≤ 15) + throw(ArgumentError("windowbits must be within 9..15")) end return GzipCompressor(ZStream(), level, windowbits+16) end @@ -67,14 +67,14 @@ Create a zlib compression codec. Arguments --------- - `level`: compression level (-1..9) -- `windowbits`: size of history buffer (8..15) +- `windowbits`: size of history buffer (9..15) """ function ZlibCompressor(;level::Integer=Z_DEFAULT_COMPRESSION, windowbits::Integer=Z_DEFAULT_WINDOWBITS) if !(-1 ≤ level ≤ 9) throw(ArgumentError("compression level must be within -1..9")) - elseif !(8 ≤ windowbits ≤ 15) - throw(ArgumentError("windowbits must be within 8..15")) + elseif !(9 ≤ windowbits ≤ 15) + throw(ArgumentError("windowbits must be within 9..15")) end return ZlibCompressor(ZStream(), level, windowbits) end @@ -109,14 +109,14 @@ Create a deflate compression codec. Arguments --------- - `level`: compression level (-1..9) -- `windowbits`: size of history buffer (8..15) +- `windowbits`: size of history buffer (9..15) """ function DeflateCompressor(;level::Integer=Z_DEFAULT_COMPRESSION, windowbits::Integer=Z_DEFAULT_WINDOWBITS) if !(-1 ≤ level ≤ 9) throw(ArgumentError("compression level must be within -1..9")) - elseif !(8 ≤ windowbits ≤ 15) - throw(ArgumentError("windowbits must be within 8..15")) + elseif !(9 ≤ windowbits ≤ 15) + throw(ArgumentError("windowbits must be within 9..15")) end return DeflateCompressor(ZStream(), level, -Int(windowbits)) end