rugged 0.21.4 → 0.22.0b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -5
- data/ext/rugged/extconf.rb +9 -9
- data/ext/rugged/rugged.c +4 -2
- data/ext/rugged/rugged.h +3 -7
- data/ext/rugged/rugged_blob.c +57 -0
- data/ext/rugged/rugged_cred.c +23 -0
- data/ext/rugged/rugged_index.c +6 -2
- data/ext/rugged/rugged_remote.c +65 -52
- data/ext/rugged/rugged_remote_collection.c +59 -10
- data/ext/rugged/rugged_repo.c +345 -11
- data/ext/rugged/rugged_revwalk.c +10 -0
- data/ext/rugged/rugged_submodule.c +1042 -0
- data/ext/rugged/rugged_submodule_collection.c +236 -0
- data/ext/rugged/rugged_tag_collection.c +70 -2
- data/ext/rugged/rugged_tree.c +29 -10
- data/lib/rugged.rb +3 -0
- data/lib/rugged/attributes.rb +41 -0
- data/lib/rugged/blob.rb +28 -0
- data/lib/rugged/diff.rb +0 -1
- data/lib/rugged/diff/line.rb +1 -3
- data/lib/rugged/patch.rb +12 -2
- data/lib/rugged/repository.rb +7 -0
- data/lib/rugged/submodule_collection.rb +48 -0
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +27 -3
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +324 -0
- data/vendor/libgit2/deps/http-parser/http_parser.h +2 -0
- data/vendor/libgit2/deps/zlib/adler32.c +39 -29
- data/vendor/libgit2/deps/zlib/crc32.c +33 -50
- data/vendor/libgit2/deps/zlib/crc32.h +1 -1
- data/vendor/libgit2/deps/zlib/deflate.c +198 -65
- data/vendor/libgit2/deps/zlib/deflate.h +8 -4
- data/vendor/libgit2/deps/zlib/infback.c +640 -0
- data/vendor/libgit2/deps/zlib/inffast.c +3 -3
- data/vendor/libgit2/deps/zlib/inffixed.h +3 -3
- data/vendor/libgit2/deps/zlib/inflate.c +84 -52
- data/vendor/libgit2/deps/zlib/inftrees.c +15 -39
- data/vendor/libgit2/deps/zlib/trees.c +18 -36
- data/vendor/libgit2/deps/zlib/zconf.h +4 -0
- data/vendor/libgit2/deps/zlib/zlib.h +250 -95
- data/vendor/libgit2/deps/zlib/zutil.c +13 -10
- data/vendor/libgit2/deps/zlib/zutil.h +41 -62
- data/vendor/libgit2/include/git2.h +4 -0
- data/vendor/libgit2/include/git2/annotated_commit.h +99 -0
- data/vendor/libgit2/include/git2/attr.h +16 -13
- data/vendor/libgit2/include/git2/branch.h +11 -0
- data/vendor/libgit2/include/git2/buffer.h +16 -0
- data/vendor/libgit2/include/git2/checkout.h +12 -12
- data/vendor/libgit2/include/git2/cherrypick.h +15 -15
- data/vendor/libgit2/include/git2/clone.h +77 -69
- data/vendor/libgit2/include/git2/common.h +13 -1
- data/vendor/libgit2/include/git2/config.h +0 -14
- data/vendor/libgit2/include/git2/describe.h +162 -0
- data/vendor/libgit2/include/git2/diff.h +13 -8
- data/vendor/libgit2/include/git2/errors.h +5 -0
- data/vendor/libgit2/include/git2/global.h +38 -0
- data/vendor/libgit2/include/git2/merge.h +38 -64
- data/vendor/libgit2/include/git2/net.h +2 -2
- data/vendor/libgit2/include/git2/notes.h +17 -0
- data/vendor/libgit2/include/git2/oid.h +8 -4
- data/vendor/libgit2/include/git2/oidarray.h +40 -0
- data/vendor/libgit2/include/git2/rebase.h +261 -0
- data/vendor/libgit2/include/git2/reflog.h +1 -1
- data/vendor/libgit2/include/git2/remote.h +25 -47
- data/vendor/libgit2/include/git2/repository.h +4 -1
- data/vendor/libgit2/include/git2/reset.h +10 -1
- data/vendor/libgit2/include/git2/revert.h +1 -1
- data/vendor/libgit2/include/git2/revwalk.h +28 -23
- data/vendor/libgit2/include/git2/status.h +19 -15
- data/vendor/libgit2/include/git2/submodule.h +18 -0
- data/vendor/libgit2/include/git2/sys/config.h +0 -1
- data/vendor/libgit2/{src → include/git2/sys}/hashsig.h +11 -7
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +13 -0
- data/vendor/libgit2/include/git2/sys/refs.h +0 -11
- data/vendor/libgit2/include/git2/sys/repository.h +13 -0
- data/vendor/libgit2/include/git2/sys/transport.h +352 -0
- data/vendor/libgit2/include/git2/threads.h +10 -20
- data/vendor/libgit2/include/git2/transaction.h +111 -0
- data/vendor/libgit2/include/git2/transport.h +79 -313
- data/vendor/libgit2/include/git2/tree.h +4 -2
- data/vendor/libgit2/include/git2/types.h +77 -8
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/src/annotated_commit.c +121 -0
- data/vendor/libgit2/src/annotated_commit.h +22 -0
- data/vendor/libgit2/src/attr.c +8 -4
- data/vendor/libgit2/src/attr_file.c +24 -2
- data/vendor/libgit2/src/blame.c +0 -1
- data/vendor/libgit2/src/branch.c +32 -3
- data/vendor/libgit2/src/buf_text.c +9 -5
- data/vendor/libgit2/src/buf_text.h +3 -2
- data/vendor/libgit2/src/buffer.c +67 -10
- data/vendor/libgit2/src/buffer.h +4 -2
- data/vendor/libgit2/src/cache.c +9 -9
- data/vendor/libgit2/src/cache.h +1 -1
- data/vendor/libgit2/src/cc-compat.h +2 -0
- data/vendor/libgit2/src/checkout.c +263 -82
- data/vendor/libgit2/src/checkout.h +1 -0
- data/vendor/libgit2/src/cherrypick.c +41 -44
- data/vendor/libgit2/src/clone.c +96 -58
- data/vendor/libgit2/src/commit.c +5 -31
- data/vendor/libgit2/src/commit_list.h +3 -1
- data/vendor/libgit2/src/config.c +0 -17
- data/vendor/libgit2/src/config_cache.c +0 -2
- data/vendor/libgit2/src/config_file.c +12 -15
- data/vendor/libgit2/src/crlf.c +2 -1
- data/vendor/libgit2/src/describe.c +886 -0
- data/vendor/libgit2/src/diff.c +29 -3
- data/vendor/libgit2/src/diff_file.c +1 -0
- data/vendor/libgit2/src/diff_patch.c +2 -3
- data/vendor/libgit2/src/diff_print.c +11 -9
- data/vendor/libgit2/src/diff_tform.c +4 -4
- data/vendor/libgit2/src/errors.c +9 -7
- data/vendor/libgit2/src/fetch.c +6 -6
- data/vendor/libgit2/src/fetchhead.h +2 -4
- data/vendor/libgit2/src/filebuf.c +0 -2
- data/vendor/libgit2/src/filebuf.h +2 -3
- data/vendor/libgit2/src/fileops.c +9 -7
- data/vendor/libgit2/src/global.c +44 -35
- data/vendor/libgit2/src/global.h +2 -0
- data/vendor/libgit2/src/graph.c +2 -2
- data/vendor/libgit2/src/hash.h +3 -1
- data/vendor/libgit2/src/hash/hash_common_crypto.h +44 -0
- data/vendor/libgit2/src/hash/hash_win32.c +1 -1
- data/vendor/libgit2/src/hashsig.c +1 -1
- data/vendor/libgit2/src/ignore.c +5 -88
- data/vendor/libgit2/src/index.c +70 -57
- data/vendor/libgit2/src/index.h +1 -0
- data/vendor/libgit2/src/indexer.c +16 -5
- data/vendor/libgit2/src/iterator.c +70 -1
- data/vendor/libgit2/src/iterator.h +5 -1
- data/vendor/libgit2/src/map.h +0 -1
- data/vendor/libgit2/src/merge.c +203 -327
- data/vendor/libgit2/src/merge.h +3 -13
- data/vendor/libgit2/src/mwindow.c +119 -8
- data/vendor/libgit2/src/mwindow.h +9 -1
- data/vendor/libgit2/src/netops.c +7 -8
- data/vendor/libgit2/src/netops.h +6 -16
- data/vendor/libgit2/src/notes.c +31 -4
- data/vendor/libgit2/src/notes.h +3 -0
- data/vendor/libgit2/src/odb.c +23 -1
- data/vendor/libgit2/src/odb_loose.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +6 -3
- data/vendor/libgit2/src/oid.c +9 -1
- data/vendor/libgit2/src/oid.h +11 -0
- data/vendor/libgit2/src/oidarray.c +21 -0
- data/vendor/libgit2/src/oidarray.h +18 -0
- data/vendor/libgit2/src/oidmap.h +16 -0
- data/vendor/libgit2/src/pack.c +20 -7
- data/vendor/libgit2/src/pack.h +3 -0
- data/vendor/libgit2/src/path.c +120 -293
- data/vendor/libgit2/src/path.h +21 -44
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/pool.c +5 -11
- data/vendor/libgit2/src/pool.h +0 -2
- data/vendor/libgit2/src/posix.c +6 -6
- data/vendor/libgit2/src/posix.h +48 -28
- data/vendor/libgit2/src/push.c +19 -48
- data/vendor/libgit2/src/push.h +2 -4
- data/vendor/libgit2/src/rebase.c +1125 -0
- data/vendor/libgit2/src/refdb.c +19 -0
- data/vendor/libgit2/src/refdb.h +2 -1
- data/vendor/libgit2/src/refdb_fs.c +101 -29
- data/vendor/libgit2/src/reflog.c +1 -1
- data/vendor/libgit2/src/refs.c +38 -3
- data/vendor/libgit2/src/refs.h +13 -2
- data/vendor/libgit2/src/refspec.c +20 -2
- data/vendor/libgit2/src/remote.c +288 -154
- data/vendor/libgit2/src/remote.h +5 -1
- data/vendor/libgit2/src/repository.c +75 -36
- data/vendor/libgit2/src/repository.h +3 -25
- data/vendor/libgit2/src/reset.c +5 -1
- data/vendor/libgit2/src/revert.c +4 -6
- data/vendor/libgit2/src/revparse.c +15 -18
- data/vendor/libgit2/src/revwalk.c +96 -22
- data/vendor/libgit2/src/revwalk.h +5 -4
- data/vendor/libgit2/src/settings.c +22 -0
- data/vendor/libgit2/src/signature.c +37 -2
- data/vendor/libgit2/src/signature.h +3 -0
- data/vendor/libgit2/src/stash.c +17 -12
- data/vendor/libgit2/src/status.c +13 -3
- data/vendor/libgit2/src/strnlen.h +2 -1
- data/vendor/libgit2/src/submodule.c +75 -35
- data/vendor/libgit2/src/thread-utils.h +4 -9
- data/vendor/libgit2/src/trace.h +9 -1
- data/vendor/libgit2/src/transaction.c +352 -0
- data/vendor/libgit2/src/transport.c +91 -97
- data/vendor/libgit2/src/transports/auth.c +71 -0
- data/vendor/libgit2/src/transports/auth.h +63 -0
- data/vendor/libgit2/src/transports/auth_negotiate.c +275 -0
- data/vendor/libgit2/src/transports/auth_negotiate.h +27 -0
- data/vendor/libgit2/src/transports/cred.c +58 -0
- data/vendor/libgit2/src/transports/cred.h +14 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +3 -0
- data/vendor/libgit2/src/transports/git.c +1 -0
- data/vendor/libgit2/src/transports/http.c +208 -82
- data/vendor/libgit2/src/transports/local.c +2 -2
- data/vendor/libgit2/src/transports/smart.c +2 -0
- data/vendor/libgit2/src/transports/smart.h +2 -0
- data/vendor/libgit2/src/transports/smart_protocol.c +10 -10
- data/vendor/libgit2/src/transports/ssh.c +243 -57
- data/vendor/libgit2/src/transports/winhttp.c +139 -35
- data/vendor/libgit2/src/tree-cache.c +118 -31
- data/vendor/libgit2/src/tree-cache.h +12 -7
- data/vendor/libgit2/src/tree.c +83 -64
- data/vendor/libgit2/src/tree.h +2 -3
- data/vendor/libgit2/src/unix/map.c +8 -2
- data/vendor/libgit2/src/unix/posix.h +23 -9
- data/vendor/libgit2/src/unix/realpath.c +8 -7
- data/vendor/libgit2/src/userdiff.h +3 -3
- data/vendor/libgit2/src/util.c +2 -92
- data/vendor/libgit2/src/util.h +3 -15
- data/vendor/libgit2/src/win32/findfile.c +0 -1
- data/vendor/libgit2/src/win32/map.c +3 -2
- data/vendor/libgit2/src/win32/mingw-compat.h +5 -12
- data/vendor/libgit2/src/win32/msvc-compat.h +3 -32
- data/vendor/libgit2/src/win32/posix.h +20 -32
- data/vendor/libgit2/src/win32/posix_w32.c +103 -31
- data/vendor/libgit2/src/win32/utf-conv.c +6 -36
- data/vendor/libgit2/src/win32/utf-conv.h +39 -0
- data/vendor/libgit2/src/win32/w32_util.h +0 -1
- metadata +32 -7
- data/vendor/libgit2/src/win32/path_w32.c +0 -305
- data/vendor/libgit2/src/win32/path_w32.h +0 -82
@@ -1,5 +1,5 @@
|
|
1
1
|
/* inffast.c -- fast decoding
|
2
|
-
* Copyright (C) 1995-2008, 2010 Mark Adler
|
2
|
+
* Copyright (C) 1995-2008, 2010, 2013 Mark Adler
|
3
3
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
4
|
*/
|
5
5
|
|
@@ -69,8 +69,8 @@ z_streamp strm;
|
|
69
69
|
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
70
70
|
{
|
71
71
|
struct inflate_state FAR *state;
|
72
|
-
unsigned char FAR *in; /* local strm->next_in */
|
73
|
-
unsigned char FAR *last; /* while in < last
|
72
|
+
z_const unsigned char FAR *in; /* local strm->next_in */
|
73
|
+
z_const unsigned char FAR *last; /* have enough input while in < last */
|
74
74
|
unsigned char FAR *out; /* local strm->next_out */
|
75
75
|
unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
|
76
76
|
unsigned char FAR *end; /* while out < end, enough space available */
|
@@ -2,9 +2,9 @@
|
|
2
2
|
* Generated automatically by makefixed().
|
3
3
|
*/
|
4
4
|
|
5
|
-
/* WARNING: this file should *not* be used by applications.
|
6
|
-
is part of the implementation of
|
7
|
-
|
5
|
+
/* WARNING: this file should *not* be used by applications.
|
6
|
+
It is part of the implementation of this library and is
|
7
|
+
subject to change. Applications should only use zlib.h.
|
8
8
|
*/
|
9
9
|
|
10
10
|
static const code lenfix[512] = {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* inflate.c -- zlib decompression
|
2
|
-
* Copyright (C) 1995-
|
2
|
+
* Copyright (C) 1995-2012 Mark Adler
|
3
3
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
4
|
*/
|
5
5
|
|
@@ -93,14 +93,15 @@
|
|
93
93
|
|
94
94
|
/* function prototypes */
|
95
95
|
local void fixedtables OF((struct inflate_state FAR *state));
|
96
|
-
local int updatewindow OF((z_streamp strm, unsigned
|
96
|
+
local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
|
97
|
+
unsigned copy));
|
97
98
|
#ifdef BUILDFIXED
|
98
99
|
void makefixed OF((void));
|
99
100
|
#endif
|
100
|
-
local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
|
101
|
+
local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
|
101
102
|
unsigned len));
|
102
103
|
|
103
|
-
int ZEXPORT
|
104
|
+
int ZEXPORT inflateResetKeep(strm)
|
104
105
|
z_streamp strm;
|
105
106
|
{
|
106
107
|
struct inflate_state FAR *state;
|
@@ -109,15 +110,13 @@ z_streamp strm;
|
|
109
110
|
state = (struct inflate_state FAR *)strm->state;
|
110
111
|
strm->total_in = strm->total_out = state->total = 0;
|
111
112
|
strm->msg = Z_NULL;
|
112
|
-
|
113
|
+
if (state->wrap) /* to support ill-conceived Java test suite */
|
114
|
+
strm->adler = state->wrap & 1;
|
113
115
|
state->mode = HEAD;
|
114
116
|
state->last = 0;
|
115
117
|
state->havedict = 0;
|
116
118
|
state->dmax = 32768U;
|
117
119
|
state->head = Z_NULL;
|
118
|
-
state->wsize = 0;
|
119
|
-
state->whave = 0;
|
120
|
-
state->wnext = 0;
|
121
120
|
state->hold = 0;
|
122
121
|
state->bits = 0;
|
123
122
|
state->lencode = state->distcode = state->next = state->codes;
|
@@ -127,6 +126,19 @@ z_streamp strm;
|
|
127
126
|
return Z_OK;
|
128
127
|
}
|
129
128
|
|
129
|
+
int ZEXPORT inflateReset(strm)
|
130
|
+
z_streamp strm;
|
131
|
+
{
|
132
|
+
struct inflate_state FAR *state;
|
133
|
+
|
134
|
+
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
135
|
+
state = (struct inflate_state FAR *)strm->state;
|
136
|
+
state->wsize = 0;
|
137
|
+
state->whave = 0;
|
138
|
+
state->wnext = 0;
|
139
|
+
return inflateResetKeep(strm);
|
140
|
+
}
|
141
|
+
|
130
142
|
int ZEXPORT inflateReset2(strm, windowBits)
|
131
143
|
z_streamp strm;
|
132
144
|
int windowBits;
|
@@ -180,10 +192,19 @@ int stream_size;
|
|
180
192
|
if (strm == Z_NULL) return Z_STREAM_ERROR;
|
181
193
|
strm->msg = Z_NULL; /* in case we return an error */
|
182
194
|
if (strm->zalloc == (alloc_func)0) {
|
195
|
+
#ifdef Z_SOLO
|
196
|
+
return Z_STREAM_ERROR;
|
197
|
+
#else
|
183
198
|
strm->zalloc = zcalloc;
|
184
199
|
strm->opaque = (voidpf)0;
|
200
|
+
#endif
|
185
201
|
}
|
186
|
-
if (strm->zfree == (free_func)0)
|
202
|
+
if (strm->zfree == (free_func)0)
|
203
|
+
#ifdef Z_SOLO
|
204
|
+
return Z_STREAM_ERROR;
|
205
|
+
#else
|
206
|
+
strm->zfree = zcfree;
|
207
|
+
#endif
|
187
208
|
state = (struct inflate_state FAR *)
|
188
209
|
ZALLOC(strm, 1, sizeof(struct inflate_state));
|
189
210
|
if (state == Z_NULL) return Z_MEM_ERROR;
|
@@ -321,8 +342,8 @@ void makefixed()
|
|
321
342
|
low = 0;
|
322
343
|
for (;;) {
|
323
344
|
if ((low % 7) == 0) printf("\n ");
|
324
|
-
printf("{%u,%u,%d}",
|
325
|
-
state.lencode[low].val);
|
345
|
+
printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
|
346
|
+
state.lencode[low].bits, state.lencode[low].val);
|
326
347
|
if (++low == size) break;
|
327
348
|
putchar(',');
|
328
349
|
}
|
@@ -355,12 +376,13 @@ void makefixed()
|
|
355
376
|
output will fall in the output data, making match copies simpler and faster.
|
356
377
|
The advantage may be dependent on the size of the processor's data caches.
|
357
378
|
*/
|
358
|
-
local int updatewindow(strm,
|
379
|
+
local int updatewindow(strm, end, copy)
|
359
380
|
z_streamp strm;
|
360
|
-
|
381
|
+
const Bytef *end;
|
382
|
+
unsigned copy;
|
361
383
|
{
|
362
384
|
struct inflate_state FAR *state;
|
363
|
-
unsigned
|
385
|
+
unsigned dist;
|
364
386
|
|
365
387
|
state = (struct inflate_state FAR *)strm->state;
|
366
388
|
|
@@ -380,19 +402,18 @@ unsigned out;
|
|
380
402
|
}
|
381
403
|
|
382
404
|
/* copy state->wsize or less output bytes into the circular window */
|
383
|
-
copy = out - strm->avail_out;
|
384
405
|
if (copy >= state->wsize) {
|
385
|
-
zmemcpy(state->window,
|
406
|
+
zmemcpy(state->window, end - state->wsize, state->wsize);
|
386
407
|
state->wnext = 0;
|
387
408
|
state->whave = state->wsize;
|
388
409
|
}
|
389
410
|
else {
|
390
411
|
dist = state->wsize - state->wnext;
|
391
412
|
if (dist > copy) dist = copy;
|
392
|
-
zmemcpy(state->window + state->wnext,
|
413
|
+
zmemcpy(state->window + state->wnext, end - copy, dist);
|
393
414
|
copy -= dist;
|
394
415
|
if (copy) {
|
395
|
-
zmemcpy(state->window,
|
416
|
+
zmemcpy(state->window, end - copy, copy);
|
396
417
|
state->wnext = copy;
|
397
418
|
state->whave = state->wsize;
|
398
419
|
}
|
@@ -499,11 +520,6 @@ unsigned out;
|
|
499
520
|
bits -= bits & 7; \
|
500
521
|
} while (0)
|
501
522
|
|
502
|
-
/* Reverse the bytes in a 32-bit value */
|
503
|
-
#define REVERSE(q) \
|
504
|
-
((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
505
|
-
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
506
|
-
|
507
523
|
/*
|
508
524
|
inflate() uses a state machine to process as much input data and generate as
|
509
525
|
much output data as possible before returning. The state machine is
|
@@ -591,7 +607,7 @@ z_streamp strm;
|
|
591
607
|
int flush;
|
592
608
|
{
|
593
609
|
struct inflate_state FAR *state;
|
594
|
-
unsigned char FAR *next; /* next input */
|
610
|
+
z_const unsigned char FAR *next; /* next input */
|
595
611
|
unsigned char FAR *put; /* next output */
|
596
612
|
unsigned have, left; /* available input and output */
|
597
613
|
unsigned long hold; /* bit buffer */
|
@@ -797,7 +813,7 @@ int flush;
|
|
797
813
|
#endif
|
798
814
|
case DICTID:
|
799
815
|
NEEDBITS(32);
|
800
|
-
strm->adler = state->check =
|
816
|
+
strm->adler = state->check = ZSWAP32(hold);
|
801
817
|
INITBITS();
|
802
818
|
state->mode = DICT;
|
803
819
|
case DICT:
|
@@ -905,7 +921,7 @@ int flush;
|
|
905
921
|
while (state->have < 19)
|
906
922
|
state->lens[order[state->have++]] = 0;
|
907
923
|
state->next = state->codes;
|
908
|
-
state->lencode = (code
|
924
|
+
state->lencode = (const code FAR *)(state->next);
|
909
925
|
state->lenbits = 7;
|
910
926
|
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
911
927
|
&(state->lenbits), state->work);
|
@@ -925,7 +941,6 @@ int flush;
|
|
925
941
|
PULLBYTE();
|
926
942
|
}
|
927
943
|
if (here.val < 16) {
|
928
|
-
NEEDBITS(here.bits);
|
929
944
|
DROPBITS(here.bits);
|
930
945
|
state->lens[state->have++] = here.val;
|
931
946
|
}
|
@@ -980,7 +995,7 @@ int flush;
|
|
980
995
|
values here (9 and 6) without reading the comments in inftrees.h
|
981
996
|
concerning the ENOUGH constants, which depend on those values */
|
982
997
|
state->next = state->codes;
|
983
|
-
state->lencode = (code
|
998
|
+
state->lencode = (const code FAR *)(state->next);
|
984
999
|
state->lenbits = 9;
|
985
1000
|
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
986
1001
|
&(state->lenbits), state->work);
|
@@ -989,7 +1004,7 @@ int flush;
|
|
989
1004
|
state->mode = BAD;
|
990
1005
|
break;
|
991
1006
|
}
|
992
|
-
state->distcode = (code
|
1007
|
+
state->distcode = (const code FAR *)(state->next);
|
993
1008
|
state->distbits = 6;
|
994
1009
|
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
995
1010
|
&(state->next), &(state->distbits), state->work);
|
@@ -1170,7 +1185,7 @@ int flush;
|
|
1170
1185
|
#ifdef GUNZIP
|
1171
1186
|
state->flags ? hold :
|
1172
1187
|
#endif
|
1173
|
-
|
1188
|
+
ZSWAP32(hold)) != state->check) {
|
1174
1189
|
strm->msg = (char *)"incorrect data check";
|
1175
1190
|
state->mode = BAD;
|
1176
1191
|
break;
|
@@ -1214,8 +1229,9 @@ int flush;
|
|
1214
1229
|
*/
|
1215
1230
|
inf_leave:
|
1216
1231
|
RESTORE();
|
1217
|
-
if (state->wsize || (state->mode <
|
1218
|
-
|
1232
|
+
if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
|
1233
|
+
(state->mode < CHECK || flush != Z_FINISH)))
|
1234
|
+
if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
|
1219
1235
|
state->mode = MEM;
|
1220
1236
|
return Z_MEM_ERROR;
|
1221
1237
|
}
|
@@ -1249,13 +1265,37 @@ z_streamp strm;
|
|
1249
1265
|
return Z_OK;
|
1250
1266
|
}
|
1251
1267
|
|
1268
|
+
int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
|
1269
|
+
z_streamp strm;
|
1270
|
+
Bytef *dictionary;
|
1271
|
+
uInt *dictLength;
|
1272
|
+
{
|
1273
|
+
struct inflate_state FAR *state;
|
1274
|
+
|
1275
|
+
/* check state */
|
1276
|
+
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
1277
|
+
state = (struct inflate_state FAR *)strm->state;
|
1278
|
+
|
1279
|
+
/* copy dictionary */
|
1280
|
+
if (state->whave && dictionary != Z_NULL) {
|
1281
|
+
zmemcpy(dictionary, state->window + state->wnext,
|
1282
|
+
state->whave - state->wnext);
|
1283
|
+
zmemcpy(dictionary + state->whave - state->wnext,
|
1284
|
+
state->window, state->wnext);
|
1285
|
+
}
|
1286
|
+
if (dictLength != Z_NULL)
|
1287
|
+
*dictLength = state->whave;
|
1288
|
+
return Z_OK;
|
1289
|
+
}
|
1290
|
+
|
1252
1291
|
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
|
1253
1292
|
z_streamp strm;
|
1254
1293
|
const Bytef *dictionary;
|
1255
1294
|
uInt dictLength;
|
1256
1295
|
{
|
1257
1296
|
struct inflate_state FAR *state;
|
1258
|
-
unsigned long
|
1297
|
+
unsigned long dictid;
|
1298
|
+
int ret;
|
1259
1299
|
|
1260
1300
|
/* check state */
|
1261
1301
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
@@ -1263,29 +1303,21 @@ uInt dictLength;
|
|
1263
1303
|
if (state->wrap != 0 && state->mode != DICT)
|
1264
1304
|
return Z_STREAM_ERROR;
|
1265
1305
|
|
1266
|
-
/* check for correct dictionary
|
1306
|
+
/* check for correct dictionary identifier */
|
1267
1307
|
if (state->mode == DICT) {
|
1268
|
-
|
1269
|
-
|
1270
|
-
if (
|
1308
|
+
dictid = adler32(0L, Z_NULL, 0);
|
1309
|
+
dictid = adler32(dictid, dictionary, dictLength);
|
1310
|
+
if (dictid != state->check)
|
1271
1311
|
return Z_DATA_ERROR;
|
1272
1312
|
}
|
1273
1313
|
|
1274
|
-
/* copy dictionary to window
|
1275
|
-
|
1314
|
+
/* copy dictionary to window using updatewindow(), which will amend the
|
1315
|
+
existing dictionary if appropriate */
|
1316
|
+
ret = updatewindow(strm, dictionary + dictLength, dictLength);
|
1317
|
+
if (ret) {
|
1276
1318
|
state->mode = MEM;
|
1277
1319
|
return Z_MEM_ERROR;
|
1278
1320
|
}
|
1279
|
-
if (dictLength > state->wsize) {
|
1280
|
-
zmemcpy(state->window, dictionary + dictLength - state->wsize,
|
1281
|
-
state->wsize);
|
1282
|
-
state->whave = state->wsize;
|
1283
|
-
}
|
1284
|
-
else {
|
1285
|
-
zmemcpy(state->window + state->wsize - dictLength, dictionary,
|
1286
|
-
dictLength);
|
1287
|
-
state->whave = dictLength;
|
1288
|
-
}
|
1289
1321
|
state->havedict = 1;
|
1290
1322
|
Tracev((stderr, "inflate: dictionary set\n"));
|
1291
1323
|
return Z_OK;
|
@@ -1321,7 +1353,7 @@ gz_headerp head;
|
|
1321
1353
|
*/
|
1322
1354
|
local unsigned syncsearch(have, buf, len)
|
1323
1355
|
unsigned FAR *have;
|
1324
|
-
unsigned char FAR *buf;
|
1356
|
+
const unsigned char FAR *buf;
|
1325
1357
|
unsigned len;
|
1326
1358
|
{
|
1327
1359
|
unsigned got;
|
@@ -1433,8 +1465,8 @@ z_streamp source;
|
|
1433
1465
|
}
|
1434
1466
|
|
1435
1467
|
/* copy state */
|
1436
|
-
zmemcpy(dest, source, sizeof(z_stream));
|
1437
|
-
zmemcpy(copy, state, sizeof(struct inflate_state));
|
1468
|
+
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
|
1469
|
+
zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
|
1438
1470
|
if (state->lencode >= state->codes &&
|
1439
1471
|
state->lencode <= state->codes + ENOUGH - 1) {
|
1440
1472
|
copy->lencode = copy->codes + (state->lencode - state->codes);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
2
|
-
* Copyright (C) 1995-
|
2
|
+
* Copyright (C) 1995-2013 Mark Adler
|
3
3
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
4
|
*/
|
5
5
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
#define MAXBITS 15
|
10
10
|
|
11
11
|
const char inflate_copyright[] =
|
12
|
-
" inflate 1.2.
|
12
|
+
" inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
|
13
13
|
/*
|
14
14
|
If you use the zlib library in a product, an acknowledgment is welcome
|
15
15
|
in the documentation of your product. If for some reason you cannot
|
@@ -62,7 +62,7 @@ unsigned short FAR *work;
|
|
62
62
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
63
63
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
64
64
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
65
|
-
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16,
|
65
|
+
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
|
66
66
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
67
67
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
68
68
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
@@ -208,8 +208,8 @@ unsigned short FAR *work;
|
|
208
208
|
mask = used - 1; /* mask for comparing low */
|
209
209
|
|
210
210
|
/* check available table space */
|
211
|
-
if ((type == LENS && used
|
212
|
-
(type == DISTS && used
|
211
|
+
if ((type == LENS && used > ENOUGH_LENS) ||
|
212
|
+
(type == DISTS && used > ENOUGH_DISTS))
|
213
213
|
return 1;
|
214
214
|
|
215
215
|
/* process all codes and make table entries */
|
@@ -277,8 +277,8 @@ unsigned short FAR *work;
|
|
277
277
|
|
278
278
|
/* check for enough space */
|
279
279
|
used += 1U << curr;
|
280
|
-
if ((type == LENS && used
|
281
|
-
(type == DISTS && used
|
280
|
+
if ((type == LENS && used > ENOUGH_LENS) ||
|
281
|
+
(type == DISTS && used > ENOUGH_DISTS))
|
282
282
|
return 1;
|
283
283
|
|
284
284
|
/* point entry in root table to sub-table */
|
@@ -289,38 +289,14 @@ unsigned short FAR *work;
|
|
289
289
|
}
|
290
290
|
}
|
291
291
|
|
292
|
-
/*
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
here.bits = (unsigned char)(len - drop);
|
301
|
-
here.val = (unsigned short)0;
|
302
|
-
while (huff != 0) {
|
303
|
-
/* when done with sub-table, drop back to root table */
|
304
|
-
if (drop != 0 && (huff & mask) != low) {
|
305
|
-
drop = 0;
|
306
|
-
len = root;
|
307
|
-
next = *table;
|
308
|
-
here.bits = (unsigned char)len;
|
309
|
-
}
|
310
|
-
|
311
|
-
/* put invalid code marker in table */
|
312
|
-
next[huff >> drop] = here;
|
313
|
-
|
314
|
-
/* backwards increment the len-bit code huff */
|
315
|
-
incr = 1U << (len - 1);
|
316
|
-
while (huff & incr)
|
317
|
-
incr >>= 1;
|
318
|
-
if (incr != 0) {
|
319
|
-
huff &= incr - 1;
|
320
|
-
huff += incr;
|
321
|
-
}
|
322
|
-
else
|
323
|
-
huff = 0;
|
292
|
+
/* fill in remaining table entry if code is incomplete (guaranteed to have
|
293
|
+
at most one remaining entry, since if the code is incomplete, the
|
294
|
+
maximum code length that was allowed to get this far is one bit) */
|
295
|
+
if (huff != 0) {
|
296
|
+
here.op = (unsigned char)64; /* invalid code marker */
|
297
|
+
here.bits = (unsigned char)(len - drop);
|
298
|
+
here.val = (unsigned short)0;
|
299
|
+
next[huff] = here;
|
324
300
|
}
|
325
301
|
|
326
302
|
/* set return parameters */
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* trees.c -- output deflated data using Huffman coding
|
2
|
-
* Copyright (C) 1995-
|
2
|
+
* Copyright (C) 1995-2012 Jean-loup Gailly
|
3
3
|
* detect_data_type() function provided freely by Cosmin Truta, 2006
|
4
4
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
5
5
|
*/
|
@@ -74,11 +74,6 @@ local const uch bl_order[BL_CODES]
|
|
74
74
|
* probability, to avoid transmitting the lengths for unused bit length codes.
|
75
75
|
*/
|
76
76
|
|
77
|
-
#define Buf_size (8 * 2*sizeof(char))
|
78
|
-
/* Number of bits used within bi_buf. (bi_buf might be implemented on
|
79
|
-
* more than 16 bits on some systems.)
|
80
|
-
*/
|
81
|
-
|
82
77
|
/* ===========================================================================
|
83
78
|
* Local data. These are initialized only once.
|
84
79
|
*/
|
@@ -151,8 +146,8 @@ local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
|
151
146
|
local int build_bl_tree OF((deflate_state *s));
|
152
147
|
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
153
148
|
int blcodes));
|
154
|
-
local void compress_block OF((deflate_state *s, ct_data *ltree,
|
155
|
-
ct_data *dtree));
|
149
|
+
local void compress_block OF((deflate_state *s, const ct_data *ltree,
|
150
|
+
const ct_data *dtree));
|
156
151
|
local int detect_data_type OF((deflate_state *s));
|
157
152
|
local unsigned bi_reverse OF((unsigned value, int length));
|
158
153
|
local void bi_windup OF((deflate_state *s));
|
@@ -399,7 +394,6 @@ void ZLIB_INTERNAL _tr_init(s)
|
|
399
394
|
|
400
395
|
s->bi_buf = 0;
|
401
396
|
s->bi_valid = 0;
|
402
|
-
s->last_eob_len = 8; /* enough lookahead for inflate */
|
403
397
|
#ifdef DEBUG
|
404
398
|
s->compressed_len = 0L;
|
405
399
|
s->bits_sent = 0L;
|
@@ -882,16 +876,18 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
|
|
882
876
|
copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
|
883
877
|
}
|
884
878
|
|
879
|
+
/* ===========================================================================
|
880
|
+
* Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
|
881
|
+
*/
|
882
|
+
void ZLIB_INTERNAL _tr_flush_bits(s)
|
883
|
+
deflate_state *s;
|
884
|
+
{
|
885
|
+
bi_flush(s);
|
886
|
+
}
|
887
|
+
|
885
888
|
/* ===========================================================================
|
886
889
|
* Send one empty static block to give enough lookahead for inflate.
|
887
890
|
* This takes 10 bits, of which 7 may remain in the bit buffer.
|
888
|
-
* The current inflate code requires 9 bits of lookahead. If the
|
889
|
-
* last two codes for the previous block (real code plus EOB) were coded
|
890
|
-
* on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
|
891
|
-
* the last real code. In this case we send two empty static blocks instead
|
892
|
-
* of one. (There are no problems if the previous block is stored or fixed.)
|
893
|
-
* To simplify the code, we assume the worst case of last real code encoded
|
894
|
-
* on one bit only.
|
895
891
|
*/
|
896
892
|
void ZLIB_INTERNAL _tr_align(s)
|
897
893
|
deflate_state *s;
|
@@ -902,20 +898,6 @@ void ZLIB_INTERNAL _tr_align(s)
|
|
902
898
|
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
|
903
899
|
#endif
|
904
900
|
bi_flush(s);
|
905
|
-
/* Of the 10 bits for the empty block, we have already sent
|
906
|
-
* (10 - bi_valid) bits. The lookahead for the last real code (before
|
907
|
-
* the EOB of the previous block) was thus at least one plus the length
|
908
|
-
* of the EOB plus what we have just sent of the empty static block.
|
909
|
-
*/
|
910
|
-
if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
|
911
|
-
send_bits(s, STATIC_TREES<<1, 3);
|
912
|
-
send_code(s, END_BLOCK, static_ltree);
|
913
|
-
#ifdef DEBUG
|
914
|
-
s->compressed_len += 10L;
|
915
|
-
#endif
|
916
|
-
bi_flush(s);
|
917
|
-
}
|
918
|
-
s->last_eob_len = 7;
|
919
901
|
}
|
920
902
|
|
921
903
|
/* ===========================================================================
|
@@ -990,7 +972,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|
990
972
|
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
991
973
|
#endif
|
992
974
|
send_bits(s, (STATIC_TREES<<1)+last, 3);
|
993
|
-
compress_block(s, (ct_data *)static_ltree,
|
975
|
+
compress_block(s, (const ct_data *)static_ltree,
|
976
|
+
(const ct_data *)static_dtree);
|
994
977
|
#ifdef DEBUG
|
995
978
|
s->compressed_len += 3 + s->static_len;
|
996
979
|
#endif
|
@@ -998,7 +981,8 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|
998
981
|
send_bits(s, (DYN_TREES<<1)+last, 3);
|
999
982
|
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
|
1000
983
|
max_blindex+1);
|
1001
|
-
compress_block(s, (ct_data *)s->dyn_ltree,
|
984
|
+
compress_block(s, (const ct_data *)s->dyn_ltree,
|
985
|
+
(const ct_data *)s->dyn_dtree);
|
1002
986
|
#ifdef DEBUG
|
1003
987
|
s->compressed_len += 3 + s->opt_len;
|
1004
988
|
#endif
|
@@ -1075,8 +1059,8 @@ int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
|
1075
1059
|
*/
|
1076
1060
|
local void compress_block(s, ltree, dtree)
|
1077
1061
|
deflate_state *s;
|
1078
|
-
ct_data *ltree; /* literal tree */
|
1079
|
-
ct_data *dtree; /* distance tree */
|
1062
|
+
const ct_data *ltree; /* literal tree */
|
1063
|
+
const ct_data *dtree; /* distance tree */
|
1080
1064
|
{
|
1081
1065
|
unsigned dist; /* distance of matched string */
|
1082
1066
|
int lc; /* match length or unmatched char (if dist == 0) */
|
@@ -1118,7 +1102,6 @@ local void compress_block(s, ltree, dtree)
|
|
1118
1102
|
} while (lx < s->last_lit);
|
1119
1103
|
|
1120
1104
|
send_code(s, END_BLOCK, ltree);
|
1121
|
-
s->last_eob_len = ltree[END_BLOCK].Len;
|
1122
1105
|
}
|
1123
1106
|
|
1124
1107
|
/* ===========================================================================
|
@@ -1226,7 +1209,6 @@ local void copy_block(s, buf, len, header)
|
|
1226
1209
|
int header; /* true if block header must be written */
|
1227
1210
|
{
|
1228
1211
|
bi_windup(s); /* align on byte boundary */
|
1229
|
-
s->last_eob_len = 8; /* enough lookahead for inflate */
|
1230
1212
|
|
1231
1213
|
if (header) {
|
1232
1214
|
put_short(s, (ush)len);
|