zopfli 0.0.2 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitmodules +1 -1
- data/.travis.yml +23 -0
- data/Gemfile +2 -0
- data/README.md +6 -1
- data/Rakefile +8 -10
- data/ext/extconf.rb +2 -1
- data/ext/zopfli.c +39 -20
- data/lib/zopfli/version.rb +1 -1
- data/smoke.sh +9 -0
- data/{test → spec}/fixtures/alice29.txt +0 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/zopfli_spec.rb +68 -0
- data/vendor/zopfli/{blocksplitter.c → src/zopfli/blocksplitter.c} +41 -53
- data/vendor/zopfli/{blocksplitter.h → src/zopfli/blocksplitter.h} +2 -6
- data/vendor/zopfli/{cache.c → src/zopfli/cache.c} +6 -0
- data/vendor/zopfli/{cache.h → src/zopfli/cache.h} +0 -0
- data/vendor/zopfli/src/zopfli/deflate.c +931 -0
- data/vendor/zopfli/{deflate.h → src/zopfli/deflate.h} +17 -2
- data/vendor/zopfli/src/zopfli/gzip_container.c +124 -0
- data/vendor/zopfli/{gzip_container.h → src/zopfli/gzip_container.h} +8 -0
- data/vendor/zopfli/{hash.c → src/zopfli/hash.c} +18 -10
- data/vendor/zopfli/{hash.h → src/zopfli/hash.h} +10 -7
- data/vendor/zopfli/{katajainen.c → src/zopfli/katajainen.c} +73 -62
- data/vendor/zopfli/{katajainen.h → src/zopfli/katajainen.h} +1 -1
- data/vendor/zopfli/{lz77.c → src/zopfli/lz77.c} +190 -42
- data/vendor/zopfli/{lz77.h → src/zopfli/lz77.h} +39 -23
- data/vendor/zopfli/{squeeze.c → src/zopfli/squeeze.c} +75 -61
- data/vendor/zopfli/{squeeze.h → src/zopfli/squeeze.h} +1 -0
- data/vendor/zopfli/{util.c → src/zopfli/symbols.h} +49 -23
- data/vendor/zopfli/{tree.c → src/zopfli/tree.c} +0 -0
- data/vendor/zopfli/{tree.h → src/zopfli/tree.h} +0 -0
- data/vendor/zopfli/src/zopfli/util.c +35 -0
- data/vendor/zopfli/{util.h → src/zopfli/util.h} +6 -23
- data/vendor/zopfli/{zlib_container.c → src/zopfli/zlib_container.c} +1 -1
- data/vendor/zopfli/{zlib_container.h → src/zopfli/zlib_container.h} +8 -0
- data/vendor/zopfli/{zopfli.h → src/zopfli/zopfli.h} +10 -4
- data/vendor/zopfli/{zopfli_bin.c → src/zopfli/zopfli_bin.c} +31 -15
- data/vendor/zopfli/{zopfli_lib.c → src/zopfli/zopfli_lib.c} +1 -2
- data/zopfli.gemspec +9 -28
- metadata +51 -50
- data/test/test_zopfli_deflate.rb +0 -47
- data/vendor/zopfli/CONTRIBUTORS +0 -6
- data/vendor/zopfli/README +0 -25
- data/vendor/zopfli/deflate.c +0 -698
- data/vendor/zopfli/gzip_container.c +0 -117
- data/vendor/zopfli/makefile +0 -5
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
Copyright
|
2
|
+
Copyright 2016 Google Inc. All Rights Reserved.
|
3
3
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
you may not use this file except in compliance with the License.
|
@@ -17,16 +17,26 @@ Author: lode.vandevenne@gmail.com (Lode Vandevenne)
|
|
17
17
|
Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
|
18
18
|
*/
|
19
19
|
|
20
|
-
|
20
|
+
/*
|
21
|
+
Utilities for using the lz77 symbols of the deflate spec.
|
22
|
+
*/
|
21
23
|
|
22
|
-
#
|
24
|
+
#ifndef ZOPFLI_SYMBOLS_H_
|
25
|
+
#define ZOPFLI_SYMBOLS_H_
|
23
26
|
|
24
|
-
|
25
|
-
#
|
26
|
-
#
|
27
|
+
/* __has_builtin available in clang */
|
28
|
+
#ifdef __has_builtin
|
29
|
+
# if __has_builtin(__builtin_clz)
|
30
|
+
# define ZOPFLI_HAS_BUILTIN_CLZ
|
31
|
+
# endif
|
32
|
+
/* __builtin_clz available beginning with GCC 3.4 */
|
33
|
+
#elif __GNUC__ * 100 + __GNUC_MINOR__ >= 304
|
34
|
+
# define ZOPFLI_HAS_BUILTIN_CLZ
|
35
|
+
#endif
|
27
36
|
|
28
|
-
|
29
|
-
|
37
|
+
/* Gets the amount of extra bits for the given dist, cfr. the DEFLATE spec. */
|
38
|
+
static int ZopfliGetDistExtraBits(int dist) {
|
39
|
+
#ifdef ZOPFLI_HAS_BUILTIN_CLZ
|
30
40
|
if (dist < 5) return 0;
|
31
41
|
return (31 ^ __builtin_clz(dist - 1)) - 1; /* log2(dist - 1) - 1 */
|
32
42
|
#else
|
@@ -47,8 +57,9 @@ int ZopfliGetDistExtraBits(int dist) {
|
|
47
57
|
#endif
|
48
58
|
}
|
49
59
|
|
50
|
-
|
51
|
-
|
60
|
+
/* Gets value of the extra bits for the given dist, cfr. the DEFLATE spec. */
|
61
|
+
static int ZopfliGetDistExtraBitsValue(int dist) {
|
62
|
+
#ifdef ZOPFLI_HAS_BUILTIN_CLZ
|
52
63
|
if (dist < 5) {
|
53
64
|
return 0;
|
54
65
|
} else {
|
@@ -73,8 +84,9 @@ int ZopfliGetDistExtraBitsValue(int dist) {
|
|
73
84
|
#endif
|
74
85
|
}
|
75
86
|
|
76
|
-
|
77
|
-
|
87
|
+
/* Gets the symbol for the given dist, cfr. the DEFLATE spec. */
|
88
|
+
static int ZopfliGetDistSymbol(int dist) {
|
89
|
+
#ifdef ZOPFLI_HAS_BUILTIN_CLZ
|
78
90
|
if (dist < 5) {
|
79
91
|
return dist - 1;
|
80
92
|
} else {
|
@@ -122,7 +134,8 @@ int ZopfliGetDistSymbol(int dist) {
|
|
122
134
|
#endif
|
123
135
|
}
|
124
136
|
|
125
|
-
|
137
|
+
/* Gets the amount of extra bits for the given length, cfr. the DEFLATE spec. */
|
138
|
+
static int ZopfliGetLengthExtraBits(int l) {
|
126
139
|
static const int table[259] = {
|
127
140
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
128
141
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
@@ -144,7 +157,8 @@ int ZopfliGetLengthExtraBits(int l) {
|
|
144
157
|
return table[l];
|
145
158
|
}
|
146
159
|
|
147
|
-
|
160
|
+
/* Gets value of the extra bits for the given length, cfr. the DEFLATE spec. */
|
161
|
+
static int ZopfliGetLengthExtraBitsValue(int l) {
|
148
162
|
static const int table[259] = {
|
149
163
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 0,
|
150
164
|
1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5,
|
@@ -163,9 +177,10 @@ int ZopfliGetLengthExtraBitsValue(int l) {
|
|
163
177
|
}
|
164
178
|
|
165
179
|
/*
|
166
|
-
|
180
|
+
Gets the symbol for the given length, cfr. the DEFLATE spec.
|
181
|
+
Returns the symbol in the range [257-285] (inclusive)
|
167
182
|
*/
|
168
|
-
int ZopfliGetLengthSymbol(int l) {
|
183
|
+
static int ZopfliGetLengthSymbol(int l) {
|
169
184
|
static const int table[259] = {
|
170
185
|
0, 0, 0, 257, 258, 259, 260, 261, 262, 263, 264,
|
171
186
|
265, 265, 266, 266, 267, 267, 268, 268,
|
@@ -203,11 +218,22 @@ int ZopfliGetLengthSymbol(int l) {
|
|
203
218
|
return table[l];
|
204
219
|
}
|
205
220
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
221
|
+
/* Gets the amount of extra bits for the given length symbol. */
|
222
|
+
static int ZopfliGetLengthSymbolExtraBits(int s) {
|
223
|
+
static const int table[29] = {
|
224
|
+
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
225
|
+
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0
|
226
|
+
};
|
227
|
+
return table[s - 257];
|
228
|
+
}
|
229
|
+
|
230
|
+
/* Gets the amount of extra bits for the given distance symbol. */
|
231
|
+
static int ZopfliGetDistSymbolExtraBits(int s) {
|
232
|
+
static const int table[30] = {
|
233
|
+
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8,
|
234
|
+
9, 9, 10, 10, 11, 11, 12, 12, 13, 13
|
235
|
+
};
|
236
|
+
return table[s];
|
213
237
|
}
|
238
|
+
|
239
|
+
#endif /* ZOPFLI_SYMBOLS_H_ */
|
File without changes
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/*
|
2
|
+
Copyright 2011 Google Inc. All Rights Reserved.
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
you may not use this file except in compliance with the License.
|
6
|
+
You may obtain a copy of the License at
|
7
|
+
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
See the License for the specific language governing permissions and
|
14
|
+
limitations under the License.
|
15
|
+
|
16
|
+
Author: lode.vandevenne@gmail.com (Lode Vandevenne)
|
17
|
+
Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
|
18
|
+
*/
|
19
|
+
|
20
|
+
#include "util.h"
|
21
|
+
|
22
|
+
#include "zopfli.h"
|
23
|
+
|
24
|
+
#include <assert.h>
|
25
|
+
#include <stdio.h>
|
26
|
+
#include <stdlib.h>
|
27
|
+
|
28
|
+
void ZopfliInitOptions(ZopfliOptions* options) {
|
29
|
+
options->verbose = 0;
|
30
|
+
options->verbose_more = 0;
|
31
|
+
options->numiterations = 15;
|
32
|
+
options->blocksplitting = 1;
|
33
|
+
options->blocksplittinglast = 0;
|
34
|
+
options->blocksplittingmax = 15;
|
35
|
+
}
|
@@ -32,6 +32,10 @@ basic deflate specification values and generic program options.
|
|
32
32
|
#define ZOPFLI_MAX_MATCH 258
|
33
33
|
#define ZOPFLI_MIN_MATCH 3
|
34
34
|
|
35
|
+
/* Number of distinct literal/length and distance symbols in DEFLATE */
|
36
|
+
#define ZOPFLI_NUM_LL 288
|
37
|
+
#define ZOPFLI_NUM_D 32
|
38
|
+
|
35
39
|
/*
|
36
40
|
The window size for deflate. Must be a power of two. This should be 32768, the
|
37
41
|
maximum possible by the deflate spec. Anything less hurts compression more than
|
@@ -51,9 +55,9 @@ operating on huge files without exceeding memory, such as the 1GB wiki9 corpus.
|
|
51
55
|
The whole compression algorithm, including the smarter block splitting, will
|
52
56
|
be executed independently on each huge block.
|
53
57
|
Dividing into huge blocks hurts compression, but not much relative to the size.
|
54
|
-
Set
|
58
|
+
Set it to 0 to disable master blocks.
|
55
59
|
*/
|
56
|
-
#define ZOPFLI_MASTER_BLOCK_SIZE
|
60
|
+
#define ZOPFLI_MASTER_BLOCK_SIZE 1000000
|
57
61
|
|
58
62
|
/*
|
59
63
|
Used to initialize costs for example
|
@@ -116,27 +120,6 @@ varies from file to file.
|
|
116
120
|
*/
|
117
121
|
#define ZOPFLI_LAZY_MATCHING
|
118
122
|
|
119
|
-
/*
|
120
|
-
Gets the symbol for the given length, cfr. the DEFLATE spec.
|
121
|
-
Returns the symbol in the range [257-285] (inclusive)
|
122
|
-
*/
|
123
|
-
int ZopfliGetLengthSymbol(int l);
|
124
|
-
|
125
|
-
/* Gets the amount of extra bits for the given length, cfr. the DEFLATE spec. */
|
126
|
-
int ZopfliGetLengthExtraBits(int l);
|
127
|
-
|
128
|
-
/* Gets value of the extra bits for the given length, cfr. the DEFLATE spec. */
|
129
|
-
int ZopfliGetLengthExtraBitsValue(int l);
|
130
|
-
|
131
|
-
/* Gets the symbol for the given dist, cfr. the DEFLATE spec. */
|
132
|
-
int ZopfliGetDistSymbol(int dist);
|
133
|
-
|
134
|
-
/* Gets the amount of extra bits for the given dist, cfr. the DEFLATE spec. */
|
135
|
-
int ZopfliGetDistExtraBits(int dist);
|
136
|
-
|
137
|
-
/* Gets value of the extra bits for the given dist, cfr. the DEFLATE spec. */
|
138
|
-
int ZopfliGetDistExtraBitsValue(int dist);
|
139
|
-
|
140
123
|
/*
|
141
124
|
Appends value to dynamically allocated memory, doubling its allocation size
|
142
125
|
whenever needed.
|
@@ -53,7 +53,7 @@ void ZopfliZlibCompress(const ZopfliOptions* options,
|
|
53
53
|
unsigned char bitpointer = 0;
|
54
54
|
unsigned checksum = adler32(in, (unsigned)insize);
|
55
55
|
unsigned cmf = 120; /* CM 8, CINFO 7. See zlib spec.*/
|
56
|
-
unsigned flevel =
|
56
|
+
unsigned flevel = 3;
|
57
57
|
unsigned fdict = 0;
|
58
58
|
unsigned cmfflg = 256 * cmf + fdict * 32 + flevel * 64;
|
59
59
|
unsigned fcheck = 31 - cmfflg % 31;
|
@@ -26,6 +26,10 @@ Functions to compress according to the Zlib specification.
|
|
26
26
|
|
27
27
|
#include "zopfli.h"
|
28
28
|
|
29
|
+
#ifdef __cplusplus
|
30
|
+
extern "C" {
|
31
|
+
#endif
|
32
|
+
|
29
33
|
/*
|
30
34
|
Compresses according to the zlib specification and append the compressed
|
31
35
|
result to the output.
|
@@ -39,4 +43,8 @@ void ZopfliZlibCompress(const ZopfliOptions* options,
|
|
39
43
|
const unsigned char* in, size_t insize,
|
40
44
|
unsigned char** out, size_t* outsize);
|
41
45
|
|
46
|
+
#ifdef __cplusplus
|
47
|
+
} // extern "C"
|
48
|
+
#endif
|
49
|
+
|
42
50
|
#endif /* ZOPFLI_ZLIB_H_ */
|
@@ -20,8 +20,13 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
|
|
20
20
|
#ifndef ZOPFLI_ZOPFLI_H_
|
21
21
|
#define ZOPFLI_ZOPFLI_H_
|
22
22
|
|
23
|
+
#include <stddef.h>
|
23
24
|
#include <stdlib.h> /* for size_t */
|
24
25
|
|
26
|
+
#ifdef __cplusplus
|
27
|
+
extern "C" {
|
28
|
+
#endif
|
29
|
+
|
25
30
|
/*
|
26
31
|
Options used throughout the program.
|
27
32
|
*/
|
@@ -47,10 +52,7 @@ typedef struct ZopfliOptions {
|
|
47
52
|
int blocksplitting;
|
48
53
|
|
49
54
|
/*
|
50
|
-
|
51
|
-
LZ77 compression. If false, chooses the block split points first, then does
|
52
|
-
iterative LZ77 on each individual block. Depending on the file, either first
|
53
|
-
or last gives the best compression. Default: false (0).
|
55
|
+
No longer used, left for compatibility.
|
54
56
|
*/
|
55
57
|
int blocksplittinglast;
|
56
58
|
|
@@ -85,4 +87,8 @@ void ZopfliCompress(const ZopfliOptions* options, ZopfliFormat output_type,
|
|
85
87
|
const unsigned char* in, size_t insize,
|
86
88
|
unsigned char** out, size_t* outsize);
|
87
89
|
|
90
|
+
#ifdef __cplusplus
|
91
|
+
} // extern "C"
|
92
|
+
#endif
|
93
|
+
|
88
94
|
#endif /* ZOPFLI_ZOPFLI_H_ */
|
@@ -33,20 +33,30 @@ decompressor.
|
|
33
33
|
#include "gzip_container.h"
|
34
34
|
#include "zlib_container.h"
|
35
35
|
|
36
|
+
/* Windows workaround for stdout output. */
|
37
|
+
#if _WIN32
|
38
|
+
#include <fcntl.h>
|
39
|
+
#endif
|
40
|
+
|
36
41
|
/*
|
37
|
-
Loads a file into a memory array.
|
42
|
+
Loads a file into a memory array. Returns 1 on success, 0 if file doesn't exist
|
43
|
+
or couldn't be opened.
|
38
44
|
*/
|
39
|
-
static
|
40
|
-
|
45
|
+
static int LoadFile(const char* filename,
|
46
|
+
unsigned char** out, size_t* outsize) {
|
41
47
|
FILE* file;
|
42
48
|
|
43
49
|
*out = 0;
|
44
50
|
*outsize = 0;
|
45
51
|
file = fopen(filename, "rb");
|
46
|
-
if (!file) return;
|
52
|
+
if (!file) return 0;
|
47
53
|
|
48
54
|
fseek(file , 0 , SEEK_END);
|
49
55
|
*outsize = ftell(file);
|
56
|
+
if(*outsize > 2147483647) {
|
57
|
+
fprintf(stderr,"Files larger than 2GB are not supported.\n");
|
58
|
+
exit(EXIT_FAILURE);
|
59
|
+
}
|
50
60
|
rewind(file);
|
51
61
|
|
52
62
|
*out = (unsigned char*)malloc(*outsize);
|
@@ -58,11 +68,14 @@ static void LoadFile(const char* filename,
|
|
58
68
|
free(*out);
|
59
69
|
*out = 0;
|
60
70
|
*outsize = 0;
|
71
|
+
fclose(file);
|
72
|
+
return 0;
|
61
73
|
}
|
62
74
|
}
|
63
75
|
|
64
76
|
assert(!(*outsize) || out); /* If size is not zero, out must be allocated. */
|
65
77
|
fclose(file);
|
78
|
+
return 1;
|
66
79
|
}
|
67
80
|
|
68
81
|
/*
|
@@ -71,6 +84,10 @@ Saves a file from a memory array, overwriting the file if it existed.
|
|
71
84
|
static void SaveFile(const char* filename,
|
72
85
|
const unsigned char* in, size_t insize) {
|
73
86
|
FILE* file = fopen(filename, "wb" );
|
87
|
+
if (file == NULL) {
|
88
|
+
fprintf(stderr,"Error: Cannot write to output file, terminating.\n");
|
89
|
+
exit (EXIT_FAILURE);
|
90
|
+
}
|
74
91
|
assert(file);
|
75
92
|
fwrite((char*)in, 1, insize, file);
|
76
93
|
fclose(file);
|
@@ -87,8 +104,7 @@ static void CompressFile(const ZopfliOptions* options,
|
|
87
104
|
size_t insize;
|
88
105
|
unsigned char* out = 0;
|
89
106
|
size_t outsize = 0;
|
90
|
-
LoadFile(infilename, &in, &insize)
|
91
|
-
if (insize == 0) {
|
107
|
+
if (!LoadFile(infilename, &in, &insize)) {
|
92
108
|
fprintf(stderr, "Invalid filename: %s\n", infilename);
|
93
109
|
return;
|
94
110
|
}
|
@@ -98,11 +114,11 @@ static void CompressFile(const ZopfliOptions* options,
|
|
98
114
|
if (outfilename) {
|
99
115
|
SaveFile(outfilename, out, outsize);
|
100
116
|
} else {
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
117
|
+
#if _WIN32
|
118
|
+
/* Windows workaround for stdout output. */
|
119
|
+
_setmode(_fileno(stdout), _O_BINARY);
|
120
|
+
#endif
|
121
|
+
fwrite(out, 1, outsize, stdout);
|
106
122
|
}
|
107
123
|
|
108
124
|
free(out);
|
@@ -143,14 +159,14 @@ int main(int argc, char* argv[]) {
|
|
143
159
|
}
|
144
160
|
else if (StringsEqual(arg, "--zlib")) output_type = ZOPFLI_FORMAT_ZLIB;
|
145
161
|
else if (StringsEqual(arg, "--gzip")) output_type = ZOPFLI_FORMAT_GZIP;
|
146
|
-
else if (StringsEqual(arg, "--splitlast"))
|
162
|
+
else if (StringsEqual(arg, "--splitlast")) /* Ignore */;
|
147
163
|
else if (arg[0] == '-' && arg[1] == '-' && arg[2] == 'i'
|
148
164
|
&& arg[3] >= '0' && arg[3] <= '9') {
|
149
165
|
options.numiterations = atoi(arg + 3);
|
150
166
|
}
|
151
167
|
else if (StringsEqual(arg, "-h")) {
|
152
168
|
fprintf(stderr,
|
153
|
-
"Usage: zopfli [OPTION]... FILE
|
169
|
+
"Usage: zopfli [OPTION]... FILE...\n"
|
154
170
|
" -h gives this help\n"
|
155
171
|
" -c write the result on standard output, instead of disk"
|
156
172
|
" filename + '.gz'\n"
|
@@ -162,13 +178,13 @@ int main(int argc, char* argv[]) {
|
|
162
178
|
" --gzip output to gzip format (default)\n"
|
163
179
|
" --zlib output to zlib format instead of gzip\n"
|
164
180
|
" --deflate output to deflate format instead of gzip\n"
|
165
|
-
" --splitlast
|
181
|
+
" --splitlast ignored, left for backwards compatibility\n");
|
166
182
|
return 0;
|
167
183
|
}
|
168
184
|
}
|
169
185
|
|
170
186
|
if (options.numiterations < 1) {
|
171
|
-
fprintf(stderr, "Error: must have 1 or more iterations");
|
187
|
+
fprintf(stderr, "Error: must have 1 or more iterations\n");
|
172
188
|
return 0;
|
173
189
|
}
|
174
190
|
|
@@ -27,8 +27,7 @@ Author: jyrki.alakuijala@gmail.com (Jyrki Alakuijala)
|
|
27
27
|
|
28
28
|
void ZopfliCompress(const ZopfliOptions* options, ZopfliFormat output_type,
|
29
29
|
const unsigned char* in, size_t insize,
|
30
|
-
unsigned char** out, size_t* outsize)
|
31
|
-
{
|
30
|
+
unsigned char** out, size_t* outsize) {
|
32
31
|
if (output_type == ZOPFLI_FORMAT_GZIP) {
|
33
32
|
ZopfliGzipCompress(options, in, insize, out, outsize);
|
34
33
|
} else if (output_type == ZOPFLI_FORMAT_ZLIB) {
|
data/zopfli.gemspec
CHANGED
@@ -13,37 +13,18 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "http://github.com/miyucy/zopfli"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.
|
16
|
+
spec.test_files = `git ls-files -z -- spec`.split("\x0")
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.files -= spec.test_files
|
19
|
+
spec.files -= ['vendor/zopfli']
|
20
|
+
spec.files += Dir['vendor/zopfli/src/zopfli/**/*']
|
21
|
+
spec.files += ['vendor/zopfli/COPYING']
|
22
|
+
|
17
23
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
24
|
spec.require_paths = ["lib"]
|
20
25
|
spec.extensions = ["ext/extconf.rb"]
|
21
26
|
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.1.4"
|
23
28
|
spec.add_development_dependency "rake"
|
24
|
-
spec.add_development_dependency "
|
25
|
-
|
26
|
-
# get an array of submodule dirs by executing 'pwd' inside each submodule
|
27
|
-
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
|
28
|
-
# for each submodule, change working directory to that submodule
|
29
|
-
Dir.chdir(submodule_path) do
|
30
|
-
|
31
|
-
# issue git ls-files in submodule's directory
|
32
|
-
submodule_files = `git ls-files`.split($\)
|
33
|
-
|
34
|
-
# prepend the submodule path to create absolute file paths
|
35
|
-
submodule_files_fullpaths = submodule_files.map do |filename|
|
36
|
-
"#{submodule_path}/#{filename}"
|
37
|
-
end
|
38
|
-
|
39
|
-
# remove leading path parts to get paths relative to the gem's root dir
|
40
|
-
# (this assumes, that the gemspec resides in the gem's root dir)
|
41
|
-
submodule_files_paths = submodule_files_fullpaths.map do |filename|
|
42
|
-
filename.gsub "#{File.dirname(__FILE__)}/", ""
|
43
|
-
end
|
44
|
-
|
45
|
-
# add relative paths to gem.files
|
46
|
-
spec.files += submodule_files_paths
|
47
|
-
end
|
48
|
-
end
|
29
|
+
spec.add_development_dependency "rspec"
|
49
30
|
end
|