Skip to content

Commit

Permalink
CHANGE: list Brotli compression in system/catalog/compressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jun 28, 2023
1 parent 3d23ed3 commit 3fa4a0b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/boot/sysobj.reb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ catalog: object [
quoted-printable: #[bitset! #{FFFFFFFFFFFFFFFBFFFFFFFFFFFFFFFF}]
]
checksums: [adler32 crc24 crc32 tcp md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd160]
compressions: [gzip deflate zlib lzma crush]
compressions: [gzip deflate zlib lzma crush brotli]
elliptic-curves: [
; will be filled on boot from `Init_Crypt` in `n-crypt.c`
]
Expand Down
4 changes: 2 additions & 2 deletions src/core/n-strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static struct digest {
// compress: native [
// {Compresses data.}
// data [binary! string!] {If string, it will be UTF8 encoded}
// method [word!] "zlib deflate gzip lzma"
// method [word!] {One of `system/catalog/compressions`}
// /part length {Length of source data}
// /level lvl [integer!] {Compression level 0-9}
// ]
Expand Down Expand Up @@ -413,7 +413,7 @@ static struct digest {
// decompress: native [
// {Decompresses data.}
// data [binary!] {Source data to decompress}
// method [word!] "zlib deflate gzip lzma"
// method [word!] {One of `system/catalog/compressions`}
// /part "Limits source data to a given length or position"
// length [number! series!] {Length of compressed data (must match end marker)}
// /size
Expand Down
2 changes: 1 addition & 1 deletion src/core/u-compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
** REBOL [R3] Language Interpreter and Run-time Environment
**
** Copyright 2012 REBOL Technologies
** Copyright 2012-2021 Rebol Open Source Contributors
** Copyright 2012-2023 Rebol Open Source Contributors
** REBOL is a trademark of REBOL Technologies
**
** Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
29 changes: 29 additions & 0 deletions src/tests/test-compression.r3
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Rebol [
Title: "Test compression"
Date: 28-Jun-2023
Author: "Oldes"
File: %test-compression.r3
Version: 0.0.1
;; Requires: 3.11.0
Note: {}
]

bin: to binary! mold system

foreach level [1 5 9][
print ajoin ["^/Testing compression of " length? bin " bytes with level " level ".^/"]

sum: checksum bin 'sha256

foreach m system/catalog/compressions [
t1: attempt [ dt [out: compress/level bin m level] ]
sz: attempt [ length? out ]
t2: attempt [ dt [out: decompress out m] ]
ok: attempt [ equal? sum checksum out 'sha256 ]
printf [10 10 20 20] reduce [m sz t1 t2 ok]
]
print "------------------------"
]

if system/options/script [ask "DONE"]
total

0 comments on commit 3fa4a0b

Please sign in to comment.