Skip to content

Commit b7fb49b

Browse files
committed
FEAT: optional custom LZ77-based compression algorithm (crush)
1 parent c33ff26 commit b7fb49b

File tree

6 files changed

+460
-2
lines changed

6 files changed

+460
-2
lines changed

NOTICE

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ Credits for Non-REBOL orginated C files and modules
4242
Copyright (C) 2018, Igor Pavlov
4343
Public domain - https://www.7-zip.org/sdk.html
4444

45+
* CRUSH (optional):
46+
Copyright (C) 2013, Ilya Muravyov
47+
Public domain - https://compressme.net/
48+
4549
* JPEG decoder:
4650
Copyright 1994-1996, Thomas G. Lane.
4751
This file is part of the Independent JPEG Group's software.

make/rebol3.nest

+6
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ include-lzma-compression: [
467467
core-files: %core/u-lzma.c
468468
]
469469

470+
include-crush-compression: [
471+
config: INCLUDE_CRUSH
472+
core-files: %core/u-crush.c
473+
]
474+
470475
include-png-filter-native: [
471476
config: INCLUDE_PNG_FILTER
472477
core-files: %core/u-png-filter.c
@@ -584,6 +589,7 @@ include-rebol-bulk: [
584589
:include-optional-checksums
585590
:include-image-natives
586591
:include-lzma-compression
592+
:include-crush-compression
587593
:include-base85-encoding
588594
:include-view
589595
:include-midi

src/boot/sysobj.reb

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ catalog: object [
6060
uri-component: #[bitset! #{0000000041E6FFC07FFFFFE17FFFFFE2}] ;A-Z a-z 0-9 !'()*-._~
6161
]
6262
checksums: [adler32 crc24 crc32 tcp md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd160]
63+
compressions: [gzip deflate zlib lzma crush]
6364
]
6465

6566
contexts: construct [

src/core/n-strings.c

+15-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6+
** Copyright 2012-2021 Rebol Open Source Contributors
67
** REBOL is a trademark of REBOL Technologies
78
**
89
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -298,7 +299,13 @@ static struct digest {
298299
Trap0(RE_FEATURE_NA);
299300
#endif
300301
break;
301-
302+
case SYM_CRUSH:
303+
#ifdef INCLUDE_CRUSH
304+
Set_Binary(D_RET, CompressCrush(ser, index, (REBINT)len, ref_level ? VAL_INT32(level) : 2));
305+
#else
306+
Trap0(RE_FEATURE_NA);
307+
#endif
308+
break;
302309
default:
303310
Trap1(RE_INVALID_ARG, D_ARG(2));
304311
}
@@ -358,7 +365,13 @@ static struct digest {
358365
Trap0(RE_FEATURE_NA);
359366
#endif
360367
break;
361-
368+
case SYM_CRUSH:
369+
#ifdef INCLUDE_CRUSH
370+
Set_Binary(D_RET, DecompressCrush(VAL_SERIES(data), VAL_INDEX(data), (REBINT)len, limit));
371+
#else
372+
Trap0(RE_FEATURE_NA);
373+
#endif
374+
break;
362375
default:
363376
Trap1(RE_INVALID_ARG, D_ARG(2));
364377
}

0 commit comments

Comments
 (0)