Skip to content

Commit

Permalink
fix: correct edge values of window_bits (#60)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
f3fora and nhz2 authored Jan 6, 2025
1 parent 3192d0f commit 3f91138
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/compression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3f91138

Please sign in to comment.