rugged 0.19.0 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.md +184 -33
- data/ext/rugged/extconf.rb +111 -28
- data/ext/rugged/rugged.c +327 -89
- data/ext/rugged/rugged.h +64 -28
- data/ext/rugged/rugged_allocator.c +89 -0
- data/ext/rugged/rugged_backend.c +17 -0
- data/ext/rugged/rugged_blame.c +278 -0
- data/ext/rugged/rugged_blob.c +301 -75
- data/ext/rugged/rugged_branch.c +92 -242
- data/ext/rugged/rugged_branch_collection.c +388 -0
- data/ext/rugged/rugged_commit.c +575 -79
- data/ext/rugged/rugged_config.c +129 -36
- data/ext/rugged/rugged_cred.c +131 -0
- data/ext/rugged/rugged_diff.c +291 -122
- data/ext/rugged/rugged_diff_delta.c +16 -22
- data/ext/rugged/rugged_diff_hunk.c +35 -51
- data/ext/rugged/rugged_diff_line.c +23 -36
- data/ext/rugged/rugged_index.c +289 -152
- data/ext/rugged/rugged_note.c +50 -60
- data/ext/rugged/rugged_object.c +13 -30
- data/ext/rugged/rugged_patch.c +400 -0
- data/ext/rugged/rugged_rebase.c +397 -0
- data/ext/rugged/rugged_reference.c +76 -346
- data/ext/rugged/rugged_reference_collection.c +423 -0
- data/ext/rugged/rugged_remote.c +438 -461
- data/ext/rugged/rugged_remote_collection.c +435 -0
- data/ext/rugged/rugged_repo.c +1548 -365
- data/ext/rugged/rugged_revwalk.c +378 -99
- data/ext/rugged/rugged_settings.c +86 -23
- data/ext/rugged/rugged_signature.c +47 -37
- data/ext/rugged/rugged_submodule.c +835 -0
- data/ext/rugged/rugged_submodule_collection.c +366 -0
- data/ext/rugged/rugged_tag.c +88 -210
- data/ext/rugged/rugged_tag_collection.c +326 -0
- data/ext/rugged/rugged_tree.c +460 -217
- data/lib/rugged/attributes.rb +46 -0
- data/lib/rugged/blob.rb +33 -0
- data/lib/rugged/branch.rb +12 -16
- data/lib/rugged/commit.rb +9 -0
- data/lib/rugged/console.rb +5 -0
- data/lib/rugged/credentials.rb +48 -0
- data/lib/rugged/diff/delta.rb +6 -2
- data/lib/rugged/diff/hunk.rb +9 -9
- data/lib/rugged/diff/line.rb +28 -5
- data/lib/rugged/diff.rb +7 -1
- data/lib/rugged/index.rb +120 -0
- data/lib/rugged/object.rb +5 -0
- data/lib/rugged/patch.rb +41 -0
- data/lib/rugged/reference.rb +6 -3
- data/lib/rugged/remote.rb +5 -9
- data/lib/rugged/repository.rb +126 -14
- data/lib/rugged/submodule_collection.rb +53 -0
- data/lib/rugged/tag.rb +45 -16
- data/lib/rugged/tree.rb +163 -1
- data/lib/rugged/version.rb +6 -1
- data/lib/rugged/walker.rb +5 -0
- data/lib/rugged.rb +16 -1
- data/vendor/libgit2/AUTHORS +77 -0
- data/vendor/libgit2/CMakeLists.txt +317 -0
- data/vendor/libgit2/COPYING +993 -0
- data/vendor/libgit2/cmake/Modules/AddCFlagIfSupported.cmake +30 -0
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +29 -0
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +96 -0
- data/vendor/libgit2/cmake/Modules/EnableWarnings.cmake +11 -0
- data/vendor/libgit2/cmake/Modules/FindCoreFoundation.cmake +26 -0
- data/vendor/libgit2/cmake/Modules/FindGSSAPI.cmake +324 -0
- data/vendor/libgit2/cmake/Modules/FindHTTP_Parser.cmake +39 -0
- data/vendor/libgit2/cmake/Modules/FindIconv.cmake +45 -0
- data/vendor/libgit2/cmake/Modules/FindPkgLibraries.cmake +28 -0
- data/vendor/libgit2/cmake/Modules/FindSecurity.cmake +28 -0
- data/vendor/libgit2/cmake/Modules/FindStatNsec.cmake +20 -0
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/cmake/Modules/IdeSplitSources.cmake +22 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +5 -0
- data/vendor/libgit2/deps/http-parser/COPYING +23 -0
- data/vendor/libgit2/deps/http-parser/http_parser.c +5 -2
- data/vendor/libgit2/deps/http-parser/http_parser.h +2 -0
- data/vendor/libgit2/deps/regex/CMakeLists.txt +2 -0
- data/vendor/libgit2/deps/regex/COPYING +502 -0
- data/vendor/libgit2/deps/regex/regex.c +10 -3
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +26 -0
- data/vendor/libgit2/deps/winhttp/COPYING.GPL +993 -0
- data/vendor/libgit2/deps/winhttp/COPYING.LGPL +502 -0
- data/vendor/libgit2/deps/winhttp/urlmon.h +45 -0
- data/vendor/libgit2/deps/winhttp/winhttp.def +29 -0
- data/vendor/libgit2/deps/winhttp/winhttp.h +594 -0
- data/vendor/libgit2/deps/winhttp/winhttp64.def +29 -0
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +5 -0
- data/vendor/libgit2/deps/zlib/COPYING +27 -0
- data/vendor/libgit2/deps/zlib/adler32.c +51 -34
- data/vendor/libgit2/deps/zlib/crc32.c +61 -61
- data/vendor/libgit2/deps/zlib/crc32.h +1 -1
- data/vendor/libgit2/deps/zlib/deflate.c +681 -352
- data/vendor/libgit2/deps/zlib/deflate.h +25 -18
- data/vendor/libgit2/deps/zlib/gzguts.h +218 -0
- data/vendor/libgit2/deps/zlib/infback.c +640 -0
- data/vendor/libgit2/deps/zlib/inffast.c +36 -53
- data/vendor/libgit2/deps/zlib/inffixed.h +3 -3
- data/vendor/libgit2/deps/zlib/inflate.c +167 -86
- data/vendor/libgit2/deps/zlib/inflate.h +7 -4
- data/vendor/libgit2/deps/zlib/inftrees.c +24 -50
- data/vendor/libgit2/deps/zlib/trees.c +55 -96
- data/vendor/libgit2/deps/zlib/zconf.h +499 -19
- data/vendor/libgit2/deps/zlib/zlib.h +526 -227
- data/vendor/libgit2/deps/zlib/zutil.c +39 -32
- data/vendor/libgit2/deps/zlib/zutil.h +75 -78
- data/vendor/libgit2/include/git2/annotated_commit.h +125 -0
- data/vendor/libgit2/include/git2/apply.h +129 -0
- data/vendor/libgit2/include/git2/attr.h +36 -21
- data/vendor/libgit2/include/git2/blame.h +229 -0
- data/vendor/libgit2/include/git2/blob.h +81 -44
- data/vendor/libgit2/include/git2/branch.h +81 -42
- data/vendor/libgit2/include/git2/buffer.h +128 -0
- data/vendor/libgit2/include/git2/checkout.h +141 -67
- data/vendor/libgit2/include/git2/cherrypick.h +92 -0
- data/vendor/libgit2/include/git2/clone.h +157 -58
- data/vendor/libgit2/include/git2/commit.h +231 -12
- data/vendor/libgit2/include/git2/common.h +216 -30
- data/vendor/libgit2/include/git2/config.h +274 -48
- data/vendor/libgit2/include/git2/cred_helpers.h +4 -4
- data/vendor/libgit2/include/git2/deprecated.h +253 -0
- data/vendor/libgit2/include/git2/describe.h +189 -0
- data/vendor/libgit2/include/git2/diff.h +985 -575
- data/vendor/libgit2/include/git2/errors.h +93 -52
- data/vendor/libgit2/include/git2/filter.h +217 -0
- data/vendor/libgit2/include/git2/global.h +44 -0
- data/vendor/libgit2/include/git2/graph.h +17 -0
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/index.h +269 -94
- data/vendor/libgit2/include/git2/indexer.h +44 -12
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +501 -64
- data/vendor/libgit2/include/git2/message.h +52 -17
- data/vendor/libgit2/include/git2/net.h +11 -5
- data/vendor/libgit2/include/git2/notes.h +120 -16
- data/vendor/libgit2/include/git2/object.h +62 -23
- data/vendor/libgit2/include/git2/odb.h +140 -24
- data/vendor/libgit2/include/git2/odb_backend.h +56 -12
- data/vendor/libgit2/include/git2/oid.h +17 -18
- data/vendor/libgit2/include/git2/oidarray.h +40 -0
- data/vendor/libgit2/include/git2/pack.h +86 -7
- data/vendor/libgit2/include/git2/patch.h +274 -0
- data/vendor/libgit2/include/git2/pathspec.h +280 -0
- data/vendor/libgit2/include/git2/proxy.h +96 -0
- data/vendor/libgit2/include/git2/rebase.h +323 -0
- data/vendor/libgit2/include/git2/reflog.h +12 -9
- data/vendor/libgit2/include/git2/refs.h +241 -46
- data/vendor/libgit2/include/git2/refspec.h +20 -4
- data/vendor/libgit2/include/git2/remote.h +636 -209
- data/vendor/libgit2/include/git2/repository.h +267 -57
- data/vendor/libgit2/include/git2/reset.h +36 -6
- data/vendor/libgit2/include/git2/revert.h +91 -0
- data/vendor/libgit2/include/git2/revparse.h +27 -16
- data/vendor/libgit2/include/git2/revwalk.h +78 -35
- data/vendor/libgit2/include/git2/signature.h +32 -5
- data/vendor/libgit2/include/git2/stash.h +160 -21
- data/vendor/libgit2/include/git2/status.h +92 -30
- data/vendor/libgit2/include/git2/submodule.h +226 -133
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/commit.h +38 -4
- data/vendor/libgit2/include/git2/sys/config.h +68 -9
- data/vendor/libgit2/include/git2/sys/diff.h +94 -0
- data/vendor/libgit2/include/git2/sys/filter.h +332 -0
- data/vendor/libgit2/include/git2/sys/hashsig.h +106 -0
- data/vendor/libgit2/include/git2/sys/index.h +6 -5
- data/vendor/libgit2/include/git2/sys/mempack.h +86 -0
- data/vendor/libgit2/include/git2/sys/merge.h +182 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +66 -28
- data/vendor/libgit2/include/git2/sys/openssl.h +38 -0
- data/vendor/libgit2/include/git2/sys/path.h +64 -0
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +79 -19
- data/vendor/libgit2/include/git2/sys/reflog.h +21 -0
- data/vendor/libgit2/include/git2/sys/refs.h +13 -2
- data/vendor/libgit2/include/git2/sys/repository.h +64 -1
- data/vendor/libgit2/include/git2/sys/stream.h +138 -0
- data/vendor/libgit2/include/git2/sys/time.h +31 -0
- data/vendor/libgit2/include/git2/sys/transport.h +439 -0
- data/vendor/libgit2/include/git2/tag.h +11 -2
- data/vendor/libgit2/include/git2/trace.h +1 -1
- data/vendor/libgit2/include/git2/transaction.h +121 -0
- data/vendor/libgit2/include/git2/transport.h +261 -292
- data/vendor/libgit2/include/git2/tree.h +111 -21
- data/vendor/libgit2/include/git2/types.h +244 -32
- data/vendor/libgit2/include/git2/version.h +5 -2
- data/vendor/libgit2/include/git2/worktree.h +255 -0
- data/vendor/libgit2/include/git2.h +50 -40
- data/vendor/libgit2/libgit2.pc.in +13 -0
- data/vendor/libgit2/src/CMakeLists.txt +525 -0
- data/vendor/libgit2/src/alloc.c +55 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/annotated_commit.c +228 -0
- data/vendor/libgit2/src/annotated_commit.h +52 -0
- data/vendor/libgit2/src/apply.c +855 -0
- data/vendor/libgit2/src/apply.h +25 -0
- data/vendor/libgit2/src/array.h +74 -16
- data/vendor/libgit2/src/attr.c +239 -408
- data/vendor/libgit2/src/attr.h +3 -33
- data/vendor/libgit2/src/attr_file.c +424 -156
- data/vendor/libgit2/src/attr_file.h +95 -23
- data/vendor/libgit2/src/attrcache.c +469 -0
- data/vendor/libgit2/src/attrcache.h +37 -5
- data/vendor/libgit2/src/bitvec.h +75 -0
- data/vendor/libgit2/src/blame.c +532 -0
- data/vendor/libgit2/src/blame.h +95 -0
- data/vendor/libgit2/src/blame_git.c +668 -0
- data/vendor/libgit2/src/blame_git.h +22 -0
- data/vendor/libgit2/src/blob.c +233 -129
- data/vendor/libgit2/src/blob.h +29 -1
- data/vendor/libgit2/src/branch.c +295 -197
- data/vendor/libgit2/src/branch.h +2 -0
- data/vendor/libgit2/src/buf_text.c +52 -27
- data/vendor/libgit2/src/buf_text.h +7 -7
- data/vendor/libgit2/src/buffer.c +609 -52
- data/vendor/libgit2/src/buffer.h +68 -23
- data/vendor/libgit2/src/cache.c +48 -51
- data/vendor/libgit2/src/cache.h +6 -4
- data/vendor/libgit2/src/cc-compat.h +35 -7
- data/vendor/libgit2/src/checkout.c +1827 -483
- data/vendor/libgit2/src/checkout.h +4 -1
- data/vendor/libgit2/src/cherrypick.c +230 -0
- data/vendor/libgit2/src/clone.c +338 -258
- data/vendor/libgit2/src/{compress.h → clone.h} +5 -5
- data/vendor/libgit2/src/commit.c +711 -124
- data/vendor/libgit2/src/commit.h +10 -3
- data/vendor/libgit2/src/commit_list.c +21 -14
- data/vendor/libgit2/src/commit_list.h +9 -3
- data/vendor/libgit2/src/common.h +153 -13
- data/vendor/libgit2/src/config.c +871 -242
- data/vendor/libgit2/src/config.h +58 -14
- data/vendor/libgit2/src/config_backend.h +84 -0
- data/vendor/libgit2/src/config_cache.c +44 -18
- data/vendor/libgit2/src/config_entries.c +259 -0
- data/vendor/libgit2/src/config_entries.h +23 -0
- data/vendor/libgit2/src/config_file.c +837 -1113
- data/vendor/libgit2/src/config_mem.c +224 -0
- data/vendor/libgit2/src/config_parse.c +558 -0
- data/vendor/libgit2/src/config_parse.h +64 -0
- data/vendor/libgit2/src/crlf.c +290 -195
- data/vendor/libgit2/src/date.c +35 -7
- data/vendor/libgit2/src/delta.c +275 -71
- data/vendor/libgit2/src/delta.h +80 -58
- data/vendor/libgit2/src/describe.c +893 -0
- data/vendor/libgit2/src/diff.c +330 -1128
- data/vendor/libgit2/src/diff.h +25 -67
- data/vendor/libgit2/src/diff_driver.c +225 -109
- data/vendor/libgit2/src/diff_driver.h +5 -2
- data/vendor/libgit2/src/diff_file.c +128 -103
- data/vendor/libgit2/src/diff_file.h +17 -12
- data/vendor/libgit2/src/diff_generate.c +1622 -0
- data/vendor/libgit2/src/diff_generate.h +128 -0
- data/vendor/libgit2/src/diff_parse.c +108 -0
- data/vendor/libgit2/src/diff_parse.h +20 -0
- data/vendor/libgit2/src/diff_print.c +578 -218
- data/vendor/libgit2/src/diff_stats.c +362 -0
- data/vendor/libgit2/src/diff_tform.c +429 -257
- data/vendor/libgit2/src/diff_tform.h +25 -0
- data/vendor/libgit2/src/diff_xdiff.c +143 -46
- data/vendor/libgit2/src/diff_xdiff.h +12 -5
- data/vendor/libgit2/src/errors.c +150 -34
- data/vendor/libgit2/src/features.h.in +37 -0
- data/vendor/libgit2/src/fetch.c +69 -46
- data/vendor/libgit2/src/fetch.h +6 -12
- data/vendor/libgit2/src/fetchhead.c +40 -33
- data/vendor/libgit2/src/fetchhead.h +5 -4
- data/vendor/libgit2/src/filebuf.c +163 -61
- data/vendor/libgit2/src/filebuf.h +13 -7
- data/vendor/libgit2/src/fileops.c +549 -407
- data/vendor/libgit2/src/fileops.h +97 -106
- data/vendor/libgit2/src/filter.c +989 -46
- data/vendor/libgit2/src/filter.h +21 -70
- data/vendor/libgit2/src/fnmatch.c +67 -11
- data/vendor/libgit2/src/fnmatch.h +27 -7
- data/vendor/libgit2/src/global.c +257 -63
- data/vendor/libgit2/src/global.h +19 -0
- data/vendor/libgit2/src/graph.c +39 -23
- data/vendor/libgit2/src/hash/hash_collisiondetect.h +51 -0
- data/vendor/libgit2/src/hash/hash_common_crypto.h +61 -0
- data/vendor/libgit2/src/hash/hash_generic.c +3 -3
- data/vendor/libgit2/src/hash/hash_generic.h +10 -5
- data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.h +24 -0
- data/vendor/libgit2/src/hash/hash_openssl.h +26 -8
- data/vendor/libgit2/src/hash/hash_win32.c +71 -43
- data/vendor/libgit2/src/hash/hash_win32.h +4 -3
- data/vendor/libgit2/src/hash/sha1dc/sha1.c +1900 -0
- data/vendor/libgit2/src/hash/sha1dc/sha1.h +110 -0
- data/vendor/libgit2/src/hash/sha1dc/ubc_check.c +372 -0
- data/vendor/libgit2/src/hash/sha1dc/ubc_check.h +52 -0
- data/vendor/libgit2/src/hash.c +0 -1
- data/vendor/libgit2/src/hash.h +13 -6
- data/vendor/libgit2/src/hashsig.c +121 -126
- data/vendor/libgit2/src/ident.c +129 -0
- data/vendor/libgit2/src/idxmap.c +153 -0
- data/vendor/libgit2/src/idxmap.h +41 -0
- data/vendor/libgit2/src/ignore.c +362 -123
- data/vendor/libgit2/src/ignore.h +16 -4
- data/vendor/libgit2/src/index.c +2131 -692
- data/vendor/libgit2/src/index.h +138 -6
- data/vendor/libgit2/src/indexer.c +866 -266
- data/vendor/libgit2/src/indexer.h +16 -0
- data/vendor/libgit2/src/integer.h +106 -0
- data/vendor/libgit2/src/iterator.c +1888 -967
- data/vendor/libgit2/src/iterator.h +130 -67
- data/vendor/libgit2/src/khash.h +43 -29
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- data/vendor/libgit2/src/map.h +1 -1
- data/vendor/libgit2/src/merge.c +1679 -479
- data/vendor/libgit2/src/merge.h +89 -22
- data/vendor/libgit2/src/merge_driver.c +426 -0
- data/vendor/libgit2/src/merge_driver.h +62 -0
- data/vendor/libgit2/src/merge_file.c +238 -101
- data/vendor/libgit2/src/message.c +4 -28
- data/vendor/libgit2/src/message.h +3 -1
- data/vendor/libgit2/src/mwindow.c +123 -15
- data/vendor/libgit2/src/mwindow.h +10 -1
- data/vendor/libgit2/src/netops.c +178 -499
- data/vendor/libgit2/src/netops.h +51 -27
- data/vendor/libgit2/src/notes.c +251 -94
- data/vendor/libgit2/src/notes.h +5 -2
- data/vendor/libgit2/src/object.c +253 -67
- data/vendor/libgit2/src/object.h +40 -2
- data/vendor/libgit2/src/object_api.c +30 -11
- data/vendor/libgit2/src/odb.c +765 -201
- data/vendor/libgit2/src/odb.h +40 -8
- data/vendor/libgit2/src/odb_loose.c +560 -346
- data/vendor/libgit2/src/odb_mempack.c +185 -0
- data/vendor/libgit2/src/odb_pack.c +117 -73
- data/vendor/libgit2/src/offmap.c +113 -0
- data/vendor/libgit2/src/offmap.h +32 -42
- data/vendor/libgit2/src/oid.c +45 -25
- data/vendor/libgit2/src/oid.h +26 -8
- data/vendor/libgit2/src/oidarray.c +34 -0
- data/vendor/libgit2/src/oidarray.h +20 -0
- data/vendor/libgit2/src/oidmap.c +125 -0
- data/vendor/libgit2/src/oidmap.h +30 -17
- data/vendor/libgit2/src/pack-objects.c +688 -265
- data/vendor/libgit2/src/pack-objects.h +27 -13
- data/vendor/libgit2/src/pack.c +418 -202
- data/vendor/libgit2/src/pack.h +25 -16
- data/vendor/libgit2/src/parse.c +124 -0
- data/vendor/libgit2/src/parse.h +61 -0
- data/vendor/libgit2/src/patch.c +223 -0
- data/vendor/libgit2/src/patch.h +68 -0
- data/vendor/libgit2/src/patch_generate.c +901 -0
- data/vendor/libgit2/src/patch_generate.h +69 -0
- data/vendor/libgit2/src/patch_parse.c +1136 -0
- data/vendor/libgit2/src/patch_parse.h +51 -0
- data/vendor/libgit2/src/path.c +1247 -241
- data/vendor/libgit2/src/path.h +353 -57
- data/vendor/libgit2/src/pathspec.c +586 -58
- data/vendor/libgit2/src/pathspec.h +37 -15
- data/vendor/libgit2/src/pool.c +134 -221
- data/vendor/libgit2/src/pool.h +38 -50
- data/vendor/libgit2/src/posix.c +76 -10
- data/vendor/libgit2/src/posix.h +74 -32
- data/vendor/libgit2/src/pqueue.c +79 -117
- data/vendor/libgit2/src/pqueue.h +38 -82
- data/vendor/libgit2/src/proxy.c +39 -0
- data/vendor/libgit2/src/proxy.h +17 -0
- data/vendor/libgit2/src/push.c +178 -279
- data/vendor/libgit2/src/push.h +93 -4
- data/vendor/libgit2/src/reader.c +265 -0
- data/vendor/libgit2/src/reader.h +107 -0
- data/vendor/libgit2/src/rebase.c +1364 -0
- data/vendor/libgit2/src/refdb.c +74 -19
- data/vendor/libgit2/src/refdb.h +16 -3
- data/vendor/libgit2/src/refdb_fs.c +1472 -603
- data/vendor/libgit2/src/refdb_fs.h +4 -0
- data/vendor/libgit2/src/reflog.c +40 -330
- data/vendor/libgit2/src/reflog.h +8 -2
- data/vendor/libgit2/src/refs.c +641 -225
- data/vendor/libgit2/src/refs.h +53 -6
- data/vendor/libgit2/src/refspec.c +175 -62
- data/vendor/libgit2/src/refspec.h +10 -25
- data/vendor/libgit2/src/remote.c +1741 -723
- data/vendor/libgit2/src/remote.h +17 -5
- data/vendor/libgit2/src/repository.c +1505 -421
- data/vendor/libgit2/src/repository.h +95 -15
- data/vendor/libgit2/src/reset.c +63 -26
- data/vendor/libgit2/src/revert.c +232 -0
- data/vendor/libgit2/src/revparse.c +94 -80
- data/vendor/libgit2/src/revwalk.c +427 -194
- data/vendor/libgit2/src/revwalk.h +14 -5
- data/vendor/libgit2/src/settings.c +290 -0
- data/vendor/libgit2/src/sha1_lookup.c +16 -159
- data/vendor/libgit2/src/sha1_lookup.h +5 -4
- data/vendor/libgit2/src/signature.c +138 -26
- data/vendor/libgit2/src/signature.h +5 -0
- data/vendor/libgit2/src/sortedcache.c +395 -0
- data/vendor/libgit2/src/sortedcache.h +180 -0
- data/vendor/libgit2/src/stash.c +629 -168
- data/vendor/libgit2/src/status.c +125 -75
- data/vendor/libgit2/src/status.h +4 -2
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/stdalloc.h +17 -0
- data/vendor/libgit2/src/stream.h +86 -0
- data/vendor/libgit2/src/streams/mbedtls.c +483 -0
- data/vendor/libgit2/src/streams/mbedtls.h +23 -0
- data/vendor/libgit2/src/streams/openssl.c +789 -0
- data/vendor/libgit2/src/streams/openssl.h +23 -0
- data/vendor/libgit2/src/streams/registry.c +118 -0
- data/vendor/libgit2/src/streams/registry.h +19 -0
- data/vendor/libgit2/src/streams/socket.c +235 -0
- data/vendor/libgit2/src/streams/socket.h +23 -0
- data/vendor/libgit2/src/streams/stransport.c +323 -0
- data/vendor/libgit2/src/streams/stransport.h +21 -0
- data/vendor/libgit2/src/streams/tls.c +73 -0
- data/vendor/libgit2/src/streams/tls.h +31 -0
- data/vendor/libgit2/src/strmap.c +147 -0
- data/vendor/libgit2/src/strmap.h +46 -51
- data/vendor/libgit2/src/strnlen.h +24 -0
- data/vendor/libgit2/src/submodule.c +1633 -877
- data/vendor/libgit2/src/submodule.h +83 -21
- data/vendor/libgit2/src/sysdir.c +355 -0
- data/vendor/libgit2/src/sysdir.h +119 -0
- data/vendor/libgit2/src/tag.c +87 -62
- data/vendor/libgit2/src/tag.h +4 -1
- data/vendor/libgit2/src/thread-utils.c +3 -0
- data/vendor/libgit2/src/thread-utils.h +71 -35
- data/vendor/libgit2/src/trace.c +4 -4
- data/vendor/libgit2/src/trace.h +11 -3
- data/vendor/libgit2/src/trailer.c +416 -0
- data/vendor/libgit2/src/transaction.c +382 -0
- data/vendor/libgit2/src/transaction.h +14 -0
- data/vendor/libgit2/src/transport.c +133 -67
- data/vendor/libgit2/src/transports/auth.c +75 -0
- data/vendor/libgit2/src/transports/auth.h +64 -0
- data/vendor/libgit2/src/transports/auth_negotiate.c +277 -0
- data/vendor/libgit2/src/transports/auth_negotiate.h +27 -0
- data/vendor/libgit2/src/transports/cred.c +296 -68
- data/vendor/libgit2/src/transports/cred.h +16 -0
- data/vendor/libgit2/src/transports/cred_helpers.c +4 -0
- data/vendor/libgit2/src/transports/git.c +108 -90
- data/vendor/libgit2/src/transports/http.c +803 -258
- data/vendor/libgit2/src/transports/http.h +25 -0
- data/vendor/libgit2/src/transports/local.c +265 -169
- data/vendor/libgit2/src/transports/smart.c +255 -45
- data/vendor/libgit2/src/transports/smart.h +42 -22
- data/vendor/libgit2/src/transports/smart_pkt.c +250 -159
- data/vendor/libgit2/src/transports/smart_protocol.c +414 -196
- data/vendor/libgit2/src/transports/ssh.c +645 -236
- data/vendor/libgit2/src/transports/ssh.h +14 -0
- data/vendor/libgit2/src/transports/winhttp.c +809 -353
- data/vendor/libgit2/src/tree-cache.c +138 -52
- data/vendor/libgit2/src/tree-cache.h +14 -7
- data/vendor/libgit2/src/tree.c +620 -259
- data/vendor/libgit2/src/tree.h +12 -19
- data/vendor/libgit2/src/tsort.c +3 -2
- data/vendor/libgit2/src/unix/map.c +25 -7
- data/vendor/libgit2/src/unix/posix.h +77 -12
- data/vendor/libgit2/src/unix/pthread.h +56 -0
- data/vendor/libgit2/src/unix/realpath.c +12 -8
- data/vendor/libgit2/src/userdiff.h +208 -0
- data/vendor/libgit2/src/util.c +349 -165
- data/vendor/libgit2/src/util.h +167 -85
- data/vendor/libgit2/src/varint.c +43 -0
- data/vendor/libgit2/src/varint.h +17 -0
- data/vendor/libgit2/src/vector.c +156 -33
- data/vendor/libgit2/src/vector.h +41 -5
- data/vendor/libgit2/src/win32/dir.c +22 -42
- data/vendor/libgit2/src/win32/dir.h +7 -5
- data/vendor/libgit2/src/win32/error.c +6 -32
- data/vendor/libgit2/src/win32/error.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +62 -69
- data/vendor/libgit2/src/win32/findfile.h +5 -13
- data/vendor/libgit2/src/win32/git2.rc +44 -0
- data/vendor/libgit2/src/win32/map.c +39 -11
- data/vendor/libgit2/src/win32/mingw-compat.h +10 -11
- data/vendor/libgit2/src/win32/msvc-compat.h +10 -33
- data/vendor/libgit2/src/win32/path_w32.c +476 -0
- data/vendor/libgit2/src/win32/path_w32.h +104 -0
- data/vendor/libgit2/src/win32/posix.h +35 -30
- data/vendor/libgit2/src/win32/posix_w32.c +659 -327
- data/vendor/libgit2/src/win32/precompiled.h +7 -2
- data/vendor/libgit2/src/win32/reparse.h +57 -0
- data/vendor/libgit2/src/win32/thread.c +258 -0
- data/vendor/libgit2/src/win32/thread.h +64 -0
- data/vendor/libgit2/src/win32/utf-conv.c +127 -62
- data/vendor/libgit2/src/win32/utf-conv.h +47 -6
- data/vendor/libgit2/src/win32/version.h +21 -4
- data/vendor/libgit2/src/win32/w32_buffer.c +54 -0
- data/vendor/libgit2/src/win32/w32_buffer.h +20 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +438 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +129 -0
- data/vendor/libgit2/src/win32/w32_stack.c +193 -0
- data/vendor/libgit2/src/win32/w32_stack.h +140 -0
- data/vendor/libgit2/src/win32/w32_util.c +95 -0
- data/vendor/libgit2/src/win32/w32_util.h +170 -0
- data/vendor/libgit2/src/win32/win32-compat.h +52 -0
- data/vendor/libgit2/src/worktree.c +578 -0
- data/vendor/libgit2/src/worktree.h +39 -0
- data/vendor/libgit2/src/xdiff/xdiff.h +33 -18
- data/vendor/libgit2/src/xdiff/xdiffi.c +578 -88
- data/vendor/libgit2/src/xdiff/xdiffi.h +3 -2
- data/vendor/libgit2/src/xdiff/xemit.c +106 -45
- data/vendor/libgit2/src/xdiff/xemit.h +3 -3
- data/vendor/libgit2/src/xdiff/xhistogram.c +5 -4
- data/vendor/libgit2/src/xdiff/xinclude.h +3 -2
- data/vendor/libgit2/src/xdiff/xmacros.h +2 -2
- data/vendor/libgit2/src/xdiff/xmerge.c +167 -48
- data/vendor/libgit2/src/xdiff/xpatience.c +42 -10
- data/vendor/libgit2/src/xdiff/xprepare.c +14 -14
- data/vendor/libgit2/src/xdiff/xprepare.h +2 -2
- data/vendor/libgit2/src/xdiff/xtypes.h +2 -2
- data/vendor/libgit2/src/xdiff/xutils.c +60 -56
- data/vendor/libgit2/src/xdiff/xutils.h +3 -5
- data/vendor/libgit2/src/zstream.c +205 -0
- data/vendor/libgit2/src/zstream.h +53 -0
- metadata +281 -233
- data/Rakefile +0 -61
- data/ext/rugged/rugged_diff_patch.c +0 -169
- data/lib/rugged/diff/patch.rb +0 -28
- data/test/blob_test.rb +0 -341
- data/test/branch_test.rb +0 -199
- data/test/commit_test.rb +0 -104
- data/test/config_test.rb +0 -45
- data/test/coverage/cover.rb +0 -133
- data/test/diff_test.rb +0 -777
- data/test/errors_test.rb +0 -34
- data/test/fixtures/alternate/objects/14/6ae76773c91e3b1d00cf7a338ec55ae58297e2 +0 -0
- data/test/fixtures/alternate/objects/14/9c32d47e99d0a3572ff1e70a2e0051bbf347a9 +0 -0
- data/test/fixtures/alternate/objects/14/fb3108588f9421bf764041e5e3ac305eb6277f +0 -0
- data/test/fixtures/archive.tar.gz +0 -0
- data/test/fixtures/attr/attr0 +0 -1
- data/test/fixtures/attr/attr1 +0 -29
- data/test/fixtures/attr/attr2 +0 -21
- data/test/fixtures/attr/attr3 +0 -4
- data/test/fixtures/attr/binfile +0 -1
- data/test/fixtures/attr/dir/file +0 -0
- data/test/fixtures/attr/file +0 -1
- data/test/fixtures/attr/gitattributes +0 -29
- data/test/fixtures/attr/gitignore +0 -2
- data/test/fixtures/attr/ign +0 -1
- data/test/fixtures/attr/macro_bad +0 -1
- data/test/fixtures/attr/macro_test +0 -1
- data/test/fixtures/attr/root_test1 +0 -1
- data/test/fixtures/attr/root_test2 +0 -6
- data/test/fixtures/attr/root_test3 +0 -19
- data/test/fixtures/attr/root_test4.txt +0 -14
- data/test/fixtures/attr/sub/abc +0 -37
- data/test/fixtures/attr/sub/dir/file +0 -0
- data/test/fixtures/attr/sub/file +0 -1
- data/test/fixtures/attr/sub/ign/file +0 -1
- data/test/fixtures/attr/sub/ign/sub/file +0 -1
- data/test/fixtures/attr/sub/sub/dir +0 -0
- data/test/fixtures/attr/sub/sub/file +0 -1
- data/test/fixtures/attr/sub/sub/subsub.txt +0 -1
- data/test/fixtures/attr/sub/subdir_test1 +0 -2
- data/test/fixtures/attr/sub/subdir_test2.txt +0 -1
- data/test/fixtures/diff/another.txt +0 -38
- data/test/fixtures/diff/readme.txt +0 -36
- data/test/fixtures/mergedrepo/conflicts-one.txt +0 -5
- data/test/fixtures/mergedrepo/conflicts-two.txt +0 -5
- data/test/fixtures/mergedrepo/one.txt +0 -10
- data/test/fixtures/mergedrepo/two.txt +0 -12
- data/test/fixtures/status/current_file +0 -1
- data/test/fixtures/status/ignored_file +0 -1
- data/test/fixtures/status/modified_file +0 -2
- data/test/fixtures/status/new_file +0 -1
- data/test/fixtures/status/staged_changes +0 -2
- data/test/fixtures/status/staged_changes_modified_file +0 -3
- data/test/fixtures/status/staged_delete_modified_file +0 -1
- data/test/fixtures/status/staged_new_file +0 -1
- data/test/fixtures/status/staged_new_file_modified_file +0 -2
- data/test/fixtures/status/subdir/current_file +0 -1
- data/test/fixtures/status/subdir/modified_file +0 -2
- data/test/fixtures/status/subdir/new_file +0 -1
- data/test/fixtures/status/subdir.txt +0 -2
- data/test/fixtures/status//350/277/231 +0 -1
- data/test/fixtures/testrepo.git/HEAD +0 -1
- data/test/fixtures/testrepo.git/config +0 -13
- data/test/fixtures/testrepo.git/description +0 -1
- data/test/fixtures/testrepo.git/index +0 -0
- data/test/fixtures/testrepo.git/info/exclude +0 -6
- data/test/fixtures/testrepo.git/logs/HEAD +0 -3
- data/test/fixtures/testrepo.git/logs/refs/heads/master +0 -3
- data/test/fixtures/testrepo.git/logs/refs/notes/commits +0 -1
- data/test/fixtures/testrepo.git/objects/0c/37a5391bbff43c37f0d0371823a5509eed5b1d +0 -0
- data/test/fixtures/testrepo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 +0 -0
- data/test/fixtures/testrepo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7 +0 -0
- data/test/fixtures/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd +0 -0
- data/test/fixtures/testrepo.git/objects/2d/2eff63372b08adf0a9eb84109ccf7d19e2f3a2 +0 -0
- data/test/fixtures/testrepo.git/objects/36/060c58702ed4c2a40832c51758d5344201d89a +0 -2
- data/test/fixtures/testrepo.git/objects/44/1034f860c1d5d90e4188d11ae0d325176869a8 +0 -1
- data/test/fixtures/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 +0 -0
- data/test/fixtures/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 +0 -2
- data/test/fixtures/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 +0 -2
- data/test/fixtures/testrepo.git/objects/60/d415052a33de2150bf68757f6461df4f563ae4 +0 -0
- data/test/fixtures/testrepo.git/objects/61/9f9935957e010c419cb9d15621916ddfcc0b96 +0 -0
- data/test/fixtures/testrepo.git/objects/68/8a8f4ef7496901d15322972f96e212a9e466cc +0 -1
- data/test/fixtures/testrepo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a +0 -0
- data/test/fixtures/testrepo.git/objects/77/71329dfa3002caf8c61a0ceb62a31d09023f37 +0 -0
- data/test/fixtures/testrepo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d +0 -0
- data/test/fixtures/testrepo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479 +0 -0
- data/test/fixtures/testrepo.git/objects/94/eca2de348d5f672faf56b0decafa5937e3235e +0 -0
- data/test/fixtures/testrepo.git/objects/9b/7384fe1676186192842f5d3e129457b62db9e3 +0 -0
- data/test/fixtures/testrepo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a +0 -3
- data/test/fixtures/testrepo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f +0 -2
- data/test/fixtures/testrepo.git/objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd +0 -0
- data/test/fixtures/testrepo.git/objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6 +0 -0
- data/test/fixtures/testrepo.git/objects/b7/4713326bc972cc15751ed504dca6f6f3b91f7a +0 -3
- data/test/fixtures/testrepo.git/objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644 +0 -3
- data/test/fixtures/testrepo.git/objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd +0 -3
- data/test/fixtures/testrepo.git/objects/c4/dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b +0 -0
- data/test/fixtures/testrepo.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/test/fixtures/testrepo.git/objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1 +0 -0
- data/test/fixtures/testrepo.git/objects/fa/49b077972391ad58037050f2a75f74e3671e92 +0 -0
- data/test/fixtures/testrepo.git/objects/fd/093bff70906175335656e6ce6ae05783708765 +0 -0
- data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx +0 -0
- data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack +0 -0
- data/test/fixtures/testrepo.git/packed-refs +0 -2
- data/test/fixtures/testrepo.git/refs/heads/master +0 -1
- data/test/fixtures/testrepo.git/refs/notes/commits +0 -1
- data/test/fixtures/testrepo.git/refs/tags/v0.9 +0 -1
- data/test/fixtures/testrepo.git/refs/tags/v1.0 +0 -1
- data/test/fixtures/text_file.md +0 -464
- data/test/fixtures/unsymlinked.git/HEAD +0 -1
- data/test/fixtures/unsymlinked.git/config +0 -6
- data/test/fixtures/unsymlinked.git/description +0 -1
- data/test/fixtures/unsymlinked.git/info/exclude +0 -2
- data/test/fixtures/unsymlinked.git/objects/08/8b64704e0d6b8bd061dea879418cb5442a3fbf +0 -0
- data/test/fixtures/unsymlinked.git/objects/13/a5e939bca25940c069fd2169d993dba328e30b +0 -0
- data/test/fixtures/unsymlinked.git/objects/19/bf568e59e3a0b363cafb4106226e62d4a4c41c +0 -0
- data/test/fixtures/unsymlinked.git/objects/58/1fadd35b4cf320d102a152f918729011604773 +0 -0
- data/test/fixtures/unsymlinked.git/objects/5c/87b6791e8b13da658a14d1ef7e09b5dc3bac8c +0 -0
- data/test/fixtures/unsymlinked.git/objects/6f/e5f5398af85fb3de8a6aba0339b6d3bfa26a27 +0 -0
- data/test/fixtures/unsymlinked.git/objects/7f/ccd75616ec188b8f1b23d67506a334cc34a49d +0 -0
- data/test/fixtures/unsymlinked.git/objects/80/6999882bf91d24241e4077906b9017605eb1f3 +0 -0
- data/test/fixtures/unsymlinked.git/objects/83/7d176303c5005505ec1e4a30231c40930c0230 +0 -0
- data/test/fixtures/unsymlinked.git/objects/a8/595ccca04f40818ae0155c8f9c77a230e597b6 +0 -2
- data/test/fixtures/unsymlinked.git/objects/cf/8f1cf5cce859c438d6cc067284cb5e161206e7 +0 -0
- data/test/fixtures/unsymlinked.git/objects/d5/278d05c8607ec420bfee4cf219fbc0eeebfd6a +0 -0
- data/test/fixtures/unsymlinked.git/objects/f4/e16fb76536591a41454194058d048d8e4dd2e9 +0 -0
- data/test/fixtures/unsymlinked.git/objects/f9/e65619d93fdf2673882e0a261c5e93b1a84006 +0 -0
- data/test/fixtures/unsymlinked.git/refs/heads/exe-file +0 -1
- data/test/fixtures/unsymlinked.git/refs/heads/master +0 -1
- data/test/fixtures/unsymlinked.git/refs/heads/reg-file +0 -1
- data/test/index_test.rb +0 -333
- data/test/lib_test.rb +0 -127
- data/test/note_test.rb +0 -158
- data/test/object_test.rb +0 -43
- data/test/reference_test.rb +0 -207
- data/test/remote_test.rb +0 -324
- data/test/repo_pack_test.rb +0 -24
- data/test/repo_reset_test.rb +0 -82
- data/test/repo_test.rb +0 -402
- data/test/tag_test.rb +0 -68
- data/test/test_helper.rb +0 -92
- data/test/tree_test.rb +0 -91
- data/test/walker_test.rb +0 -88
- data/vendor/libgit2/Makefile.embed +0 -42
- data/vendor/libgit2/include/git2/push.h +0 -131
- data/vendor/libgit2/include/git2/threads.h +0 -50
- data/vendor/libgit2/src/amiga/map.c +0 -48
- data/vendor/libgit2/src/bswap.h +0 -97
- data/vendor/libgit2/src/compress.c +0 -53
- data/vendor/libgit2/src/config_file.h +0 -60
- data/vendor/libgit2/src/delta-apply.c +0 -134
- data/vendor/libgit2/src/delta-apply.h +0 -50
- data/vendor/libgit2/src/diff_patch.c +0 -995
- data/vendor/libgit2/src/diff_patch.h +0 -46
- data/vendor/libgit2/src/hashsig.h +0 -72
- data/vendor/libgit2/src/merge_file.h +0 -71
- data/vendor/libgit2/src/win32/pthread.c +0 -144
- data/vendor/libgit2/src/win32/pthread.h +0 -50
@@ -1,5 +1,5 @@
|
|
1
1
|
/* deflate.c -- compress data using the deflation algorithm
|
2
|
-
* Copyright (C) 1995-
|
2
|
+
* Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
|
3
3
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
4
|
*/
|
5
5
|
|
@@ -37,7 +37,7 @@
|
|
37
37
|
* REFERENCES
|
38
38
|
*
|
39
39
|
* Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
|
40
|
-
* Available in http://
|
40
|
+
* Available in http://tools.ietf.org/html/rfc1951
|
41
41
|
*
|
42
42
|
* A description of the Rabin and Karp algorithm is given in the book
|
43
43
|
* "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
|
@@ -52,7 +52,7 @@
|
|
52
52
|
#include "deflate.h"
|
53
53
|
|
54
54
|
const char deflate_copyright[] =
|
55
|
-
" deflate 1.2.
|
55
|
+
" deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler ";
|
56
56
|
/*
|
57
57
|
If you use the zlib library in a product, an acknowledgment is welcome
|
58
58
|
in the documentation of your product. If for some reason you cannot
|
@@ -73,6 +73,8 @@ typedef enum {
|
|
73
73
|
typedef block_state (*compress_func) OF((deflate_state *s, int flush));
|
74
74
|
/* Compression function. Returns the block state after the call. */
|
75
75
|
|
76
|
+
local int deflateStateCheck OF((z_streamp strm));
|
77
|
+
local void slide_hash OF((deflate_state *s));
|
76
78
|
local void fill_window OF((deflate_state *s));
|
77
79
|
local block_state deflate_stored OF((deflate_state *s, int flush));
|
78
80
|
local block_state deflate_fast OF((deflate_state *s, int flush));
|
@@ -84,15 +86,16 @@ local block_state deflate_huff OF((deflate_state *s, int flush));
|
|
84
86
|
local void lm_init OF((deflate_state *s));
|
85
87
|
local void putShortMSB OF((deflate_state *s, uInt b));
|
86
88
|
local void flush_pending OF((z_streamp strm));
|
87
|
-
local
|
89
|
+
local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
88
90
|
#ifdef ASMV
|
91
|
+
# pragma message("Assembler code may have bugs -- use at your own risk")
|
89
92
|
void match_init OF((void)); /* asm code initialization */
|
90
93
|
uInt longest_match OF((deflate_state *s, IPos cur_match));
|
91
94
|
#else
|
92
95
|
local uInt longest_match OF((deflate_state *s, IPos cur_match));
|
93
96
|
#endif
|
94
97
|
|
95
|
-
#ifdef
|
98
|
+
#ifdef ZLIB_DEBUG
|
96
99
|
local void check_match OF((deflate_state *s, IPos start, IPos match,
|
97
100
|
int length));
|
98
101
|
#endif
|
@@ -148,18 +151,14 @@ local const config configuration_table[10] = {
|
|
148
151
|
* meaning.
|
149
152
|
*/
|
150
153
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
#ifndef NO_DUMMY_DECL
|
155
|
-
struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
156
|
-
#endif
|
154
|
+
/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
|
155
|
+
#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0))
|
157
156
|
|
158
157
|
/* ===========================================================================
|
159
158
|
* Update a hash value with the given input byte
|
160
|
-
* IN assertion: all calls to
|
161
|
-
*
|
162
|
-
*
|
159
|
+
* IN assertion: all calls to UPDATE_HASH are made with consecutive input
|
160
|
+
* characters, so that a running hash key can be computed from the previous
|
161
|
+
* key instead of complete recalculation each time.
|
163
162
|
*/
|
164
163
|
#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
|
165
164
|
|
@@ -170,9 +169,9 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
|
170
169
|
* the previous length of the hash chain.
|
171
170
|
* If this file is compiled with -DFASTEST, the compression level is forced
|
172
171
|
* to 1, and no hash chains are maintained.
|
173
|
-
* IN assertion: all calls to
|
174
|
-
*
|
175
|
-
*
|
172
|
+
* IN assertion: all calls to INSERT_STRING are made with consecutive input
|
173
|
+
* characters and the first MIN_MATCH bytes of str are valid (except for
|
174
|
+
* the last MIN_MATCH-1 bytes of the input file).
|
176
175
|
*/
|
177
176
|
#ifdef FASTEST
|
178
177
|
#define INSERT_STRING(s, str, match_head) \
|
@@ -194,6 +193,37 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
|
194
193
|
s->head[s->hash_size-1] = NIL; \
|
195
194
|
zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
|
196
195
|
|
196
|
+
/* ===========================================================================
|
197
|
+
* Slide the hash table when sliding the window down (could be avoided with 32
|
198
|
+
* bit values at the expense of memory usage). We slide even when level == 0 to
|
199
|
+
* keep the hash table consistent if we switch back to level > 0 later.
|
200
|
+
*/
|
201
|
+
local void slide_hash(s)
|
202
|
+
deflate_state *s;
|
203
|
+
{
|
204
|
+
unsigned n, m;
|
205
|
+
Posf *p;
|
206
|
+
uInt wsize = s->w_size;
|
207
|
+
|
208
|
+
n = s->hash_size;
|
209
|
+
p = &s->head[n];
|
210
|
+
do {
|
211
|
+
m = *--p;
|
212
|
+
*p = (Pos)(m >= wsize ? m - wsize : NIL);
|
213
|
+
} while (--n);
|
214
|
+
n = wsize;
|
215
|
+
#ifndef FASTEST
|
216
|
+
p = &s->prev[n];
|
217
|
+
do {
|
218
|
+
m = *--p;
|
219
|
+
*p = (Pos)(m >= wsize ? m - wsize : NIL);
|
220
|
+
/* If n is not on any hash chain, prev[n] is garbage but
|
221
|
+
* its value will never be used.
|
222
|
+
*/
|
223
|
+
} while (--n);
|
224
|
+
#endif
|
225
|
+
}
|
226
|
+
|
197
227
|
/* ========================================================================= */
|
198
228
|
int ZEXPORT deflateInit_(strm, level, version, stream_size)
|
199
229
|
z_streamp strm;
|
@@ -235,10 +265,19 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|
235
265
|
|
236
266
|
strm->msg = Z_NULL;
|
237
267
|
if (strm->zalloc == (alloc_func)0) {
|
268
|
+
#ifdef Z_SOLO
|
269
|
+
return Z_STREAM_ERROR;
|
270
|
+
#else
|
238
271
|
strm->zalloc = zcalloc;
|
239
272
|
strm->opaque = (voidpf)0;
|
273
|
+
#endif
|
240
274
|
}
|
241
|
-
if (strm->zfree == (free_func)0)
|
275
|
+
if (strm->zfree == (free_func)0)
|
276
|
+
#ifdef Z_SOLO
|
277
|
+
return Z_STREAM_ERROR;
|
278
|
+
#else
|
279
|
+
strm->zfree = zcfree;
|
280
|
+
#endif
|
242
281
|
|
243
282
|
#ifdef FASTEST
|
244
283
|
if (level != 0) level = 1;
|
@@ -258,7 +297,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|
258
297
|
#endif
|
259
298
|
if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
|
260
299
|
windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
|
261
|
-
strategy < 0 || strategy > Z_FIXED) {
|
300
|
+
strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) {
|
262
301
|
return Z_STREAM_ERROR;
|
263
302
|
}
|
264
303
|
if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
|
@@ -266,14 +305,15 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|
266
305
|
if (s == Z_NULL) return Z_MEM_ERROR;
|
267
306
|
strm->state = (struct internal_state FAR *)s;
|
268
307
|
s->strm = strm;
|
308
|
+
s->status = INIT_STATE; /* to pass state test in deflateReset() */
|
269
309
|
|
270
310
|
s->wrap = wrap;
|
271
311
|
s->gzhead = Z_NULL;
|
272
|
-
s->w_bits = windowBits;
|
312
|
+
s->w_bits = (uInt)windowBits;
|
273
313
|
s->w_size = 1 << s->w_bits;
|
274
314
|
s->w_mask = s->w_size - 1;
|
275
315
|
|
276
|
-
s->hash_bits = memLevel + 7;
|
316
|
+
s->hash_bits = (uInt)memLevel + 7;
|
277
317
|
s->hash_size = 1 << s->hash_bits;
|
278
318
|
s->hash_mask = s->hash_size - 1;
|
279
319
|
s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
|
@@ -293,7 +333,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|
293
333
|
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
|
294
334
|
s->pending_buf == Z_NULL) {
|
295
335
|
s->status = FINISH_STATE;
|
296
|
-
strm->msg =
|
336
|
+
strm->msg = ERR_MSG(Z_MEM_ERROR);
|
297
337
|
deflateEnd (strm);
|
298
338
|
return Z_MEM_ERROR;
|
299
339
|
}
|
@@ -307,6 +347,31 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|
307
347
|
return deflateReset(strm);
|
308
348
|
}
|
309
349
|
|
350
|
+
/* =========================================================================
|
351
|
+
* Check for a valid deflate stream state. Return 0 if ok, 1 if not.
|
352
|
+
*/
|
353
|
+
local int deflateStateCheck (strm)
|
354
|
+
z_streamp strm;
|
355
|
+
{
|
356
|
+
deflate_state *s;
|
357
|
+
if (strm == Z_NULL ||
|
358
|
+
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
|
359
|
+
return 1;
|
360
|
+
s = strm->state;
|
361
|
+
if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE &&
|
362
|
+
#ifdef GZIP
|
363
|
+
s->status != GZIP_STATE &&
|
364
|
+
#endif
|
365
|
+
s->status != EXTRA_STATE &&
|
366
|
+
s->status != NAME_STATE &&
|
367
|
+
s->status != COMMENT_STATE &&
|
368
|
+
s->status != HCRC_STATE &&
|
369
|
+
s->status != BUSY_STATE &&
|
370
|
+
s->status != FINISH_STATE))
|
371
|
+
return 1;
|
372
|
+
return 0;
|
373
|
+
}
|
374
|
+
|
310
375
|
/* ========================================================================= */
|
311
376
|
int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
312
377
|
z_streamp strm;
|
@@ -314,49 +379,97 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
|
314
379
|
uInt dictLength;
|
315
380
|
{
|
316
381
|
deflate_state *s;
|
317
|
-
uInt
|
318
|
-
|
319
|
-
|
382
|
+
uInt str, n;
|
383
|
+
int wrap;
|
384
|
+
unsigned avail;
|
385
|
+
z_const unsigned char *next;
|
320
386
|
|
321
|
-
if (strm
|
322
|
-
strm->state->wrap == 2 ||
|
323
|
-
(strm->state->wrap == 1 && strm->state->status != INIT_STATE))
|
387
|
+
if (deflateStateCheck(strm) || dictionary == Z_NULL)
|
324
388
|
return Z_STREAM_ERROR;
|
325
|
-
|
326
389
|
s = strm->state;
|
327
|
-
|
328
|
-
|
390
|
+
wrap = s->wrap;
|
391
|
+
if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
|
392
|
+
return Z_STREAM_ERROR;
|
329
393
|
|
330
|
-
|
331
|
-
if (
|
332
|
-
|
333
|
-
|
394
|
+
/* when using zlib wrappers, compute Adler-32 for provided dictionary */
|
395
|
+
if (wrap == 1)
|
396
|
+
strm->adler = adler32(strm->adler, dictionary, dictLength);
|
397
|
+
s->wrap = 0; /* avoid computing Adler-32 in read_buf */
|
398
|
+
|
399
|
+
/* if dictionary would fill window, just replace the history */
|
400
|
+
if (dictLength >= s->w_size) {
|
401
|
+
if (wrap == 0) { /* already empty otherwise */
|
402
|
+
CLEAR_HASH(s);
|
403
|
+
s->strstart = 0;
|
404
|
+
s->block_start = 0L;
|
405
|
+
s->insert = 0;
|
406
|
+
}
|
407
|
+
dictionary += dictLength - s->w_size; /* use the tail */
|
408
|
+
dictLength = s->w_size;
|
334
409
|
}
|
335
|
-
zmemcpy(s->window, dictionary, length);
|
336
|
-
s->strstart = length;
|
337
|
-
s->block_start = (long)length;
|
338
410
|
|
339
|
-
/*
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
411
|
+
/* insert dictionary into window and hash */
|
412
|
+
avail = strm->avail_in;
|
413
|
+
next = strm->next_in;
|
414
|
+
strm->avail_in = dictLength;
|
415
|
+
strm->next_in = (z_const Bytef *)dictionary;
|
416
|
+
fill_window(s);
|
417
|
+
while (s->lookahead >= MIN_MATCH) {
|
418
|
+
str = s->strstart;
|
419
|
+
n = s->lookahead - (MIN_MATCH-1);
|
420
|
+
do {
|
421
|
+
UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
|
422
|
+
#ifndef FASTEST
|
423
|
+
s->prev[str & s->w_mask] = s->head[s->ins_h];
|
424
|
+
#endif
|
425
|
+
s->head[s->ins_h] = (Pos)str;
|
426
|
+
str++;
|
427
|
+
} while (--n);
|
428
|
+
s->strstart = str;
|
429
|
+
s->lookahead = MIN_MATCH-1;
|
430
|
+
fill_window(s);
|
347
431
|
}
|
348
|
-
|
432
|
+
s->strstart += s->lookahead;
|
433
|
+
s->block_start = (long)s->strstart;
|
434
|
+
s->insert = s->lookahead;
|
435
|
+
s->lookahead = 0;
|
436
|
+
s->match_length = s->prev_length = MIN_MATCH-1;
|
437
|
+
s->match_available = 0;
|
438
|
+
strm->next_in = next;
|
439
|
+
strm->avail_in = avail;
|
440
|
+
s->wrap = wrap;
|
349
441
|
return Z_OK;
|
350
442
|
}
|
351
443
|
|
352
444
|
/* ========================================================================= */
|
353
|
-
int ZEXPORT
|
445
|
+
int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength)
|
446
|
+
z_streamp strm;
|
447
|
+
Bytef *dictionary;
|
448
|
+
uInt *dictLength;
|
449
|
+
{
|
450
|
+
deflate_state *s;
|
451
|
+
uInt len;
|
452
|
+
|
453
|
+
if (deflateStateCheck(strm))
|
454
|
+
return Z_STREAM_ERROR;
|
455
|
+
s = strm->state;
|
456
|
+
len = s->strstart + s->lookahead;
|
457
|
+
if (len > s->w_size)
|
458
|
+
len = s->w_size;
|
459
|
+
if (dictionary != Z_NULL && len)
|
460
|
+
zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len);
|
461
|
+
if (dictLength != Z_NULL)
|
462
|
+
*dictLength = len;
|
463
|
+
return Z_OK;
|
464
|
+
}
|
465
|
+
|
466
|
+
/* ========================================================================= */
|
467
|
+
int ZEXPORT deflateResetKeep (strm)
|
354
468
|
z_streamp strm;
|
355
469
|
{
|
356
470
|
deflate_state *s;
|
357
471
|
|
358
|
-
if (strm
|
359
|
-
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
|
472
|
+
if (deflateStateCheck(strm)) {
|
360
473
|
return Z_STREAM_ERROR;
|
361
474
|
}
|
362
475
|
|
@@ -371,7 +484,11 @@ int ZEXPORT deflateReset (strm)
|
|
371
484
|
if (s->wrap < 0) {
|
372
485
|
s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
|
373
486
|
}
|
374
|
-
s->status =
|
487
|
+
s->status =
|
488
|
+
#ifdef GZIP
|
489
|
+
s->wrap == 2 ? GZIP_STATE :
|
490
|
+
#endif
|
491
|
+
s->wrap ? INIT_STATE : BUSY_STATE;
|
375
492
|
strm->adler =
|
376
493
|
#ifdef GZIP
|
377
494
|
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
|
@@ -380,31 +497,70 @@ int ZEXPORT deflateReset (strm)
|
|
380
497
|
s->last_flush = Z_NO_FLUSH;
|
381
498
|
|
382
499
|
_tr_init(s);
|
383
|
-
lm_init(s);
|
384
500
|
|
385
501
|
return Z_OK;
|
386
502
|
}
|
387
503
|
|
504
|
+
/* ========================================================================= */
|
505
|
+
int ZEXPORT deflateReset (strm)
|
506
|
+
z_streamp strm;
|
507
|
+
{
|
508
|
+
int ret;
|
509
|
+
|
510
|
+
ret = deflateResetKeep(strm);
|
511
|
+
if (ret == Z_OK)
|
512
|
+
lm_init(strm->state);
|
513
|
+
return ret;
|
514
|
+
}
|
515
|
+
|
388
516
|
/* ========================================================================= */
|
389
517
|
int ZEXPORT deflateSetHeader (strm, head)
|
390
518
|
z_streamp strm;
|
391
519
|
gz_headerp head;
|
392
520
|
{
|
393
|
-
if (strm
|
394
|
-
|
521
|
+
if (deflateStateCheck(strm) || strm->state->wrap != 2)
|
522
|
+
return Z_STREAM_ERROR;
|
395
523
|
strm->state->gzhead = head;
|
396
524
|
return Z_OK;
|
397
525
|
}
|
398
526
|
|
527
|
+
/* ========================================================================= */
|
528
|
+
int ZEXPORT deflatePending (strm, pending, bits)
|
529
|
+
unsigned *pending;
|
530
|
+
int *bits;
|
531
|
+
z_streamp strm;
|
532
|
+
{
|
533
|
+
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
534
|
+
if (pending != Z_NULL)
|
535
|
+
*pending = strm->state->pending;
|
536
|
+
if (bits != Z_NULL)
|
537
|
+
*bits = strm->state->bi_valid;
|
538
|
+
return Z_OK;
|
539
|
+
}
|
540
|
+
|
399
541
|
/* ========================================================================= */
|
400
542
|
int ZEXPORT deflatePrime (strm, bits, value)
|
401
543
|
z_streamp strm;
|
402
544
|
int bits;
|
403
545
|
int value;
|
404
546
|
{
|
405
|
-
|
406
|
-
|
407
|
-
|
547
|
+
deflate_state *s;
|
548
|
+
int put;
|
549
|
+
|
550
|
+
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
551
|
+
s = strm->state;
|
552
|
+
if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
|
553
|
+
return Z_BUF_ERROR;
|
554
|
+
do {
|
555
|
+
put = Buf_size - s->bi_valid;
|
556
|
+
if (put > bits)
|
557
|
+
put = bits;
|
558
|
+
s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
|
559
|
+
s->bi_valid += put;
|
560
|
+
_tr_flush_bits(s);
|
561
|
+
value >>= put;
|
562
|
+
bits -= put;
|
563
|
+
} while (bits);
|
408
564
|
return Z_OK;
|
409
565
|
}
|
410
566
|
|
@@ -416,9 +572,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
|
416
572
|
{
|
417
573
|
deflate_state *s;
|
418
574
|
compress_func func;
|
419
|
-
int err = Z_OK;
|
420
575
|
|
421
|
-
if (strm
|
576
|
+
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
422
577
|
s = strm->state;
|
423
578
|
|
424
579
|
#ifdef FASTEST
|
@@ -432,11 +587,22 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
|
432
587
|
func = configuration_table[s->level].func;
|
433
588
|
|
434
589
|
if ((strategy != s->strategy || func != configuration_table[level].func) &&
|
435
|
-
|
590
|
+
s->high_water) {
|
436
591
|
/* Flush the last buffer: */
|
437
|
-
err = deflate(strm, Z_BLOCK);
|
592
|
+
int err = deflate(strm, Z_BLOCK);
|
593
|
+
if (err == Z_STREAM_ERROR)
|
594
|
+
return err;
|
595
|
+
if (strm->avail_out == 0)
|
596
|
+
return Z_BUF_ERROR;
|
438
597
|
}
|
439
598
|
if (s->level != level) {
|
599
|
+
if (s->level == 0 && s->matches != 0) {
|
600
|
+
if (s->matches == 1)
|
601
|
+
slide_hash(s);
|
602
|
+
else
|
603
|
+
CLEAR_HASH(s);
|
604
|
+
s->matches = 0;
|
605
|
+
}
|
440
606
|
s->level = level;
|
441
607
|
s->max_lazy_match = configuration_table[level].max_lazy;
|
442
608
|
s->good_match = configuration_table[level].good_length;
|
@@ -444,7 +610,7 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
|
444
610
|
s->max_chain_length = configuration_table[level].max_chain;
|
445
611
|
}
|
446
612
|
s->strategy = strategy;
|
447
|
-
return
|
613
|
+
return Z_OK;
|
448
614
|
}
|
449
615
|
|
450
616
|
/* ========================================================================= */
|
@@ -457,12 +623,12 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
|
|
457
623
|
{
|
458
624
|
deflate_state *s;
|
459
625
|
|
460
|
-
if (strm
|
626
|
+
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
461
627
|
s = strm->state;
|
462
|
-
s->good_match = good_length;
|
463
|
-
s->max_lazy_match = max_lazy;
|
628
|
+
s->good_match = (uInt)good_length;
|
629
|
+
s->max_lazy_match = (uInt)max_lazy;
|
464
630
|
s->nice_match = nice_length;
|
465
|
-
s->max_chain_length = max_chain;
|
631
|
+
s->max_chain_length = (uInt)max_chain;
|
466
632
|
return Z_OK;
|
467
633
|
}
|
468
634
|
|
@@ -489,14 +655,13 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
|
|
489
655
|
{
|
490
656
|
deflate_state *s;
|
491
657
|
uLong complen, wraplen;
|
492
|
-
Bytef *str;
|
493
658
|
|
494
659
|
/* conservative upper bound for compressed data */
|
495
660
|
complen = sourceLen +
|
496
661
|
((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
|
497
662
|
|
498
663
|
/* if can't get parameters, return conservative bound plus zlib wrapper */
|
499
|
-
if (strm
|
664
|
+
if (deflateStateCheck(strm))
|
500
665
|
return complen + 6;
|
501
666
|
|
502
667
|
/* compute wrapper length */
|
@@ -508,9 +673,11 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
|
|
508
673
|
case 1: /* zlib wrapper */
|
509
674
|
wraplen = 6 + (s->strstart ? 4 : 0);
|
510
675
|
break;
|
676
|
+
#ifdef GZIP
|
511
677
|
case 2: /* gzip wrapper */
|
512
678
|
wraplen = 18;
|
513
679
|
if (s->gzhead != Z_NULL) { /* user-supplied gzip header */
|
680
|
+
Bytef *str;
|
514
681
|
if (s->gzhead->extra != Z_NULL)
|
515
682
|
wraplen += 2 + s->gzhead->extra_len;
|
516
683
|
str = s->gzhead->name;
|
@@ -527,6 +694,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
|
|
527
694
|
wraplen += 2;
|
528
695
|
}
|
529
696
|
break;
|
697
|
+
#endif
|
530
698
|
default: /* for compiler happiness */
|
531
699
|
wraplen = 6;
|
532
700
|
}
|
@@ -554,30 +722,43 @@ local void putShortMSB (s, b)
|
|
554
722
|
}
|
555
723
|
|
556
724
|
/* =========================================================================
|
557
|
-
* Flush as much pending output as possible. All deflate() output
|
558
|
-
* through this function so some
|
559
|
-
*
|
560
|
-
* (See also read_buf()).
|
725
|
+
* Flush as much pending output as possible. All deflate() output, except for
|
726
|
+
* some deflate_stored() output, goes through this function so some
|
727
|
+
* applications may wish to modify it to avoid allocating a large
|
728
|
+
* strm->next_out buffer and copying into it. (See also read_buf()).
|
561
729
|
*/
|
562
730
|
local void flush_pending(strm)
|
563
731
|
z_streamp strm;
|
564
732
|
{
|
565
|
-
unsigned len
|
733
|
+
unsigned len;
|
734
|
+
deflate_state *s = strm->state;
|
566
735
|
|
736
|
+
_tr_flush_bits(s);
|
737
|
+
len = s->pending;
|
567
738
|
if (len > strm->avail_out) len = strm->avail_out;
|
568
739
|
if (len == 0) return;
|
569
740
|
|
570
|
-
zmemcpy(strm->next_out,
|
741
|
+
zmemcpy(strm->next_out, s->pending_out, len);
|
571
742
|
strm->next_out += len;
|
572
|
-
|
743
|
+
s->pending_out += len;
|
573
744
|
strm->total_out += len;
|
574
|
-
strm->avail_out
|
575
|
-
|
576
|
-
if (
|
577
|
-
|
745
|
+
strm->avail_out -= len;
|
746
|
+
s->pending -= len;
|
747
|
+
if (s->pending == 0) {
|
748
|
+
s->pending_out = s->pending_buf;
|
578
749
|
}
|
579
750
|
}
|
580
751
|
|
752
|
+
/* ===========================================================================
|
753
|
+
* Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1].
|
754
|
+
*/
|
755
|
+
#define HCRC_UPDATE(beg) \
|
756
|
+
do { \
|
757
|
+
if (s->gzhead->hcrc && s->pending > (beg)) \
|
758
|
+
strm->adler = crc32(strm->adler, s->pending_buf + (beg), \
|
759
|
+
s->pending - (beg)); \
|
760
|
+
} while (0)
|
761
|
+
|
581
762
|
/* ========================================================================= */
|
582
763
|
int ZEXPORT deflate (strm, flush)
|
583
764
|
z_streamp strm;
|
@@ -586,230 +767,229 @@ int ZEXPORT deflate (strm, flush)
|
|
586
767
|
int old_flush; /* value of flush param for previous deflate call */
|
587
768
|
deflate_state *s;
|
588
769
|
|
589
|
-
if (strm
|
590
|
-
flush > Z_BLOCK || flush < 0) {
|
770
|
+
if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
|
591
771
|
return Z_STREAM_ERROR;
|
592
772
|
}
|
593
773
|
s = strm->state;
|
594
774
|
|
595
775
|
if (strm->next_out == Z_NULL ||
|
596
|
-
(strm->
|
776
|
+
(strm->avail_in != 0 && strm->next_in == Z_NULL) ||
|
597
777
|
(s->status == FINISH_STATE && flush != Z_FINISH)) {
|
598
778
|
ERR_RETURN(strm, Z_STREAM_ERROR);
|
599
779
|
}
|
600
780
|
if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
|
601
781
|
|
602
|
-
s->strm = strm; /* just in case */
|
603
782
|
old_flush = s->last_flush;
|
604
783
|
s->last_flush = flush;
|
605
784
|
|
785
|
+
/* Flush as much pending output as possible */
|
786
|
+
if (s->pending != 0) {
|
787
|
+
flush_pending(strm);
|
788
|
+
if (strm->avail_out == 0) {
|
789
|
+
/* Since avail_out is 0, deflate will be called again with
|
790
|
+
* more output space, but possibly with both pending and
|
791
|
+
* avail_in equal to zero. There won't be anything to do,
|
792
|
+
* but this is not an error situation so make sure we
|
793
|
+
* return OK instead of BUF_ERROR at next call of deflate:
|
794
|
+
*/
|
795
|
+
s->last_flush = -1;
|
796
|
+
return Z_OK;
|
797
|
+
}
|
798
|
+
|
799
|
+
/* Make sure there is something to do and avoid duplicate consecutive
|
800
|
+
* flushes. For repeated and useless calls with Z_FINISH, we keep
|
801
|
+
* returning Z_STREAM_END instead of Z_BUF_ERROR.
|
802
|
+
*/
|
803
|
+
} else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
|
804
|
+
flush != Z_FINISH) {
|
805
|
+
ERR_RETURN(strm, Z_BUF_ERROR);
|
806
|
+
}
|
807
|
+
|
808
|
+
/* User must not provide more input after the first FINISH: */
|
809
|
+
if (s->status == FINISH_STATE && strm->avail_in != 0) {
|
810
|
+
ERR_RETURN(strm, Z_BUF_ERROR);
|
811
|
+
}
|
812
|
+
|
606
813
|
/* Write the header */
|
607
814
|
if (s->status == INIT_STATE) {
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
put_byte(s, 0);
|
619
|
-
put_byte(s, 0);
|
620
|
-
put_byte(s, s->level == 9 ? 2 :
|
621
|
-
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
|
622
|
-
4 : 0));
|
623
|
-
put_byte(s, OS_CODE);
|
624
|
-
s->status = BUSY_STATE;
|
625
|
-
}
|
626
|
-
else {
|
627
|
-
put_byte(s, (s->gzhead->text ? 1 : 0) +
|
628
|
-
(s->gzhead->hcrc ? 2 : 0) +
|
629
|
-
(s->gzhead->extra == Z_NULL ? 0 : 4) +
|
630
|
-
(s->gzhead->name == Z_NULL ? 0 : 8) +
|
631
|
-
(s->gzhead->comment == Z_NULL ? 0 : 16)
|
632
|
-
);
|
633
|
-
put_byte(s, (Byte)(s->gzhead->time & 0xff));
|
634
|
-
put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
|
635
|
-
put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
|
636
|
-
put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
|
637
|
-
put_byte(s, s->level == 9 ? 2 :
|
638
|
-
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
|
639
|
-
4 : 0));
|
640
|
-
put_byte(s, s->gzhead->os & 0xff);
|
641
|
-
if (s->gzhead->extra != Z_NULL) {
|
642
|
-
put_byte(s, s->gzhead->extra_len & 0xff);
|
643
|
-
put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
|
644
|
-
}
|
645
|
-
if (s->gzhead->hcrc)
|
646
|
-
strm->adler = crc32(strm->adler, s->pending_buf,
|
647
|
-
s->pending);
|
648
|
-
s->gzindex = 0;
|
649
|
-
s->status = EXTRA_STATE;
|
650
|
-
}
|
651
|
-
}
|
815
|
+
/* zlib header */
|
816
|
+
uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
|
817
|
+
uInt level_flags;
|
818
|
+
|
819
|
+
if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
|
820
|
+
level_flags = 0;
|
821
|
+
else if (s->level < 6)
|
822
|
+
level_flags = 1;
|
823
|
+
else if (s->level == 6)
|
824
|
+
level_flags = 2;
|
652
825
|
else
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
|
659
|
-
level_flags = 0;
|
660
|
-
else if (s->level < 6)
|
661
|
-
level_flags = 1;
|
662
|
-
else if (s->level == 6)
|
663
|
-
level_flags = 2;
|
664
|
-
else
|
665
|
-
level_flags = 3;
|
666
|
-
header |= (level_flags << 6);
|
667
|
-
if (s->strstart != 0) header |= PRESET_DICT;
|
668
|
-
header += 31 - (header % 31);
|
826
|
+
level_flags = 3;
|
827
|
+
header |= (level_flags << 6);
|
828
|
+
if (s->strstart != 0) header |= PRESET_DICT;
|
829
|
+
header += 31 - (header % 31);
|
669
830
|
|
831
|
+
putShortMSB(s, header);
|
832
|
+
|
833
|
+
/* Save the adler32 of the preset dictionary: */
|
834
|
+
if (s->strstart != 0) {
|
835
|
+
putShortMSB(s, (uInt)(strm->adler >> 16));
|
836
|
+
putShortMSB(s, (uInt)(strm->adler & 0xffff));
|
837
|
+
}
|
838
|
+
strm->adler = adler32(0L, Z_NULL, 0);
|
839
|
+
s->status = BUSY_STATE;
|
840
|
+
|
841
|
+
/* Compression must start with an empty pending buffer */
|
842
|
+
flush_pending(strm);
|
843
|
+
if (s->pending != 0) {
|
844
|
+
s->last_flush = -1;
|
845
|
+
return Z_OK;
|
846
|
+
}
|
847
|
+
}
|
848
|
+
#ifdef GZIP
|
849
|
+
if (s->status == GZIP_STATE) {
|
850
|
+
/* gzip header */
|
851
|
+
strm->adler = crc32(0L, Z_NULL, 0);
|
852
|
+
put_byte(s, 31);
|
853
|
+
put_byte(s, 139);
|
854
|
+
put_byte(s, 8);
|
855
|
+
if (s->gzhead == Z_NULL) {
|
856
|
+
put_byte(s, 0);
|
857
|
+
put_byte(s, 0);
|
858
|
+
put_byte(s, 0);
|
859
|
+
put_byte(s, 0);
|
860
|
+
put_byte(s, 0);
|
861
|
+
put_byte(s, s->level == 9 ? 2 :
|
862
|
+
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
|
863
|
+
4 : 0));
|
864
|
+
put_byte(s, OS_CODE);
|
670
865
|
s->status = BUSY_STATE;
|
671
|
-
putShortMSB(s, header);
|
672
866
|
|
673
|
-
/*
|
674
|
-
|
675
|
-
|
676
|
-
|
867
|
+
/* Compression must start with an empty pending buffer */
|
868
|
+
flush_pending(strm);
|
869
|
+
if (s->pending != 0) {
|
870
|
+
s->last_flush = -1;
|
871
|
+
return Z_OK;
|
872
|
+
}
|
873
|
+
}
|
874
|
+
else {
|
875
|
+
put_byte(s, (s->gzhead->text ? 1 : 0) +
|
876
|
+
(s->gzhead->hcrc ? 2 : 0) +
|
877
|
+
(s->gzhead->extra == Z_NULL ? 0 : 4) +
|
878
|
+
(s->gzhead->name == Z_NULL ? 0 : 8) +
|
879
|
+
(s->gzhead->comment == Z_NULL ? 0 : 16)
|
880
|
+
);
|
881
|
+
put_byte(s, (Byte)(s->gzhead->time & 0xff));
|
882
|
+
put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
|
883
|
+
put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
|
884
|
+
put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
|
885
|
+
put_byte(s, s->level == 9 ? 2 :
|
886
|
+
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
|
887
|
+
4 : 0));
|
888
|
+
put_byte(s, s->gzhead->os & 0xff);
|
889
|
+
if (s->gzhead->extra != Z_NULL) {
|
890
|
+
put_byte(s, s->gzhead->extra_len & 0xff);
|
891
|
+
put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
|
677
892
|
}
|
678
|
-
|
893
|
+
if (s->gzhead->hcrc)
|
894
|
+
strm->adler = crc32(strm->adler, s->pending_buf,
|
895
|
+
s->pending);
|
896
|
+
s->gzindex = 0;
|
897
|
+
s->status = EXTRA_STATE;
|
679
898
|
}
|
680
899
|
}
|
681
|
-
#ifdef GZIP
|
682
900
|
if (s->status == EXTRA_STATE) {
|
683
901
|
if (s->gzhead->extra != Z_NULL) {
|
684
|
-
|
685
|
-
|
686
|
-
while (s->
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
902
|
+
ulg beg = s->pending; /* start of bytes to update crc */
|
903
|
+
uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
|
904
|
+
while (s->pending + left > s->pending_buf_size) {
|
905
|
+
uInt copy = s->pending_buf_size - s->pending;
|
906
|
+
zmemcpy(s->pending_buf + s->pending,
|
907
|
+
s->gzhead->extra + s->gzindex, copy);
|
908
|
+
s->pending = s->pending_buf_size;
|
909
|
+
HCRC_UPDATE(beg);
|
910
|
+
s->gzindex += copy;
|
911
|
+
flush_pending(strm);
|
912
|
+
if (s->pending != 0) {
|
913
|
+
s->last_flush = -1;
|
914
|
+
return Z_OK;
|
695
915
|
}
|
696
|
-
|
697
|
-
|
698
|
-
}
|
699
|
-
if (s->gzhead->hcrc && s->pending > beg)
|
700
|
-
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
701
|
-
s->pending - beg);
|
702
|
-
if (s->gzindex == s->gzhead->extra_len) {
|
703
|
-
s->gzindex = 0;
|
704
|
-
s->status = NAME_STATE;
|
916
|
+
beg = 0;
|
917
|
+
left -= copy;
|
705
918
|
}
|
919
|
+
zmemcpy(s->pending_buf + s->pending,
|
920
|
+
s->gzhead->extra + s->gzindex, left);
|
921
|
+
s->pending += left;
|
922
|
+
HCRC_UPDATE(beg);
|
923
|
+
s->gzindex = 0;
|
706
924
|
}
|
707
|
-
|
708
|
-
s->status = NAME_STATE;
|
925
|
+
s->status = NAME_STATE;
|
709
926
|
}
|
710
927
|
if (s->status == NAME_STATE) {
|
711
928
|
if (s->gzhead->name != Z_NULL) {
|
712
|
-
|
929
|
+
ulg beg = s->pending; /* start of bytes to update crc */
|
713
930
|
int val;
|
714
|
-
|
715
931
|
do {
|
716
932
|
if (s->pending == s->pending_buf_size) {
|
717
|
-
|
718
|
-
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
719
|
-
s->pending - beg);
|
933
|
+
HCRC_UPDATE(beg);
|
720
934
|
flush_pending(strm);
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
break;
|
935
|
+
if (s->pending != 0) {
|
936
|
+
s->last_flush = -1;
|
937
|
+
return Z_OK;
|
725
938
|
}
|
939
|
+
beg = 0;
|
726
940
|
}
|
727
941
|
val = s->gzhead->name[s->gzindex++];
|
728
942
|
put_byte(s, val);
|
729
943
|
} while (val != 0);
|
730
|
-
|
731
|
-
|
732
|
-
s->pending - beg);
|
733
|
-
if (val == 0) {
|
734
|
-
s->gzindex = 0;
|
735
|
-
s->status = COMMENT_STATE;
|
736
|
-
}
|
944
|
+
HCRC_UPDATE(beg);
|
945
|
+
s->gzindex = 0;
|
737
946
|
}
|
738
|
-
|
739
|
-
s->status = COMMENT_STATE;
|
947
|
+
s->status = COMMENT_STATE;
|
740
948
|
}
|
741
949
|
if (s->status == COMMENT_STATE) {
|
742
950
|
if (s->gzhead->comment != Z_NULL) {
|
743
|
-
|
951
|
+
ulg beg = s->pending; /* start of bytes to update crc */
|
744
952
|
int val;
|
745
|
-
|
746
953
|
do {
|
747
954
|
if (s->pending == s->pending_buf_size) {
|
748
|
-
|
749
|
-
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
750
|
-
s->pending - beg);
|
955
|
+
HCRC_UPDATE(beg);
|
751
956
|
flush_pending(strm);
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
break;
|
957
|
+
if (s->pending != 0) {
|
958
|
+
s->last_flush = -1;
|
959
|
+
return Z_OK;
|
756
960
|
}
|
961
|
+
beg = 0;
|
757
962
|
}
|
758
963
|
val = s->gzhead->comment[s->gzindex++];
|
759
964
|
put_byte(s, val);
|
760
965
|
} while (val != 0);
|
761
|
-
|
762
|
-
strm->adler = crc32(strm->adler, s->pending_buf + beg,
|
763
|
-
s->pending - beg);
|
764
|
-
if (val == 0)
|
765
|
-
s->status = HCRC_STATE;
|
966
|
+
HCRC_UPDATE(beg);
|
766
967
|
}
|
767
|
-
|
768
|
-
s->status = HCRC_STATE;
|
968
|
+
s->status = HCRC_STATE;
|
769
969
|
}
|
770
970
|
if (s->status == HCRC_STATE) {
|
771
971
|
if (s->gzhead->hcrc) {
|
772
|
-
if (s->pending + 2 > s->pending_buf_size)
|
972
|
+
if (s->pending + 2 > s->pending_buf_size) {
|
773
973
|
flush_pending(strm);
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
s->status = BUSY_STATE;
|
974
|
+
if (s->pending != 0) {
|
975
|
+
s->last_flush = -1;
|
976
|
+
return Z_OK;
|
977
|
+
}
|
779
978
|
}
|
979
|
+
put_byte(s, (Byte)(strm->adler & 0xff));
|
980
|
+
put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
|
981
|
+
strm->adler = crc32(0L, Z_NULL, 0);
|
780
982
|
}
|
781
|
-
|
782
|
-
s->status = BUSY_STATE;
|
783
|
-
}
|
784
|
-
#endif
|
983
|
+
s->status = BUSY_STATE;
|
785
984
|
|
786
|
-
|
787
|
-
if (s->pending != 0) {
|
985
|
+
/* Compression must start with an empty pending buffer */
|
788
986
|
flush_pending(strm);
|
789
|
-
if (
|
790
|
-
/* Since avail_out is 0, deflate will be called again with
|
791
|
-
* more output space, but possibly with both pending and
|
792
|
-
* avail_in equal to zero. There won't be anything to do,
|
793
|
-
* but this is not an error situation so make sure we
|
794
|
-
* return OK instead of BUF_ERROR at next call of deflate:
|
795
|
-
*/
|
987
|
+
if (s->pending != 0) {
|
796
988
|
s->last_flush = -1;
|
797
989
|
return Z_OK;
|
798
990
|
}
|
799
|
-
|
800
|
-
/* Make sure there is something to do and avoid duplicate consecutive
|
801
|
-
* flushes. For repeated and useless calls with Z_FINISH, we keep
|
802
|
-
* returning Z_STREAM_END instead of Z_BUF_ERROR.
|
803
|
-
*/
|
804
|
-
} else if (strm->avail_in == 0 && flush <= old_flush &&
|
805
|
-
flush != Z_FINISH) {
|
806
|
-
ERR_RETURN(strm, Z_BUF_ERROR);
|
807
|
-
}
|
808
|
-
|
809
|
-
/* User must not provide more input after the first FINISH: */
|
810
|
-
if (s->status == FINISH_STATE && strm->avail_in != 0) {
|
811
|
-
ERR_RETURN(strm, Z_BUF_ERROR);
|
812
991
|
}
|
992
|
+
#endif
|
813
993
|
|
814
994
|
/* Start a new block or continue the current one.
|
815
995
|
*/
|
@@ -817,9 +997,10 @@ int ZEXPORT deflate (strm, flush)
|
|
817
997
|
(flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
|
818
998
|
block_state bstate;
|
819
999
|
|
820
|
-
bstate = s->
|
821
|
-
|
822
|
-
|
1000
|
+
bstate = s->level == 0 ? deflate_stored(s, flush) :
|
1001
|
+
s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
|
1002
|
+
s->strategy == Z_RLE ? deflate_rle(s, flush) :
|
1003
|
+
(*(configuration_table[s->level].func))(s, flush);
|
823
1004
|
|
824
1005
|
if (bstate == finish_started || bstate == finish_done) {
|
825
1006
|
s->status = FINISH_STATE;
|
@@ -850,6 +1031,7 @@ int ZEXPORT deflate (strm, flush)
|
|
850
1031
|
if (s->lookahead == 0) {
|
851
1032
|
s->strstart = 0;
|
852
1033
|
s->block_start = 0L;
|
1034
|
+
s->insert = 0;
|
853
1035
|
}
|
854
1036
|
}
|
855
1037
|
}
|
@@ -860,7 +1042,6 @@ int ZEXPORT deflate (strm, flush)
|
|
860
1042
|
}
|
861
1043
|
}
|
862
1044
|
}
|
863
|
-
Assert(strm->avail_out > 0, "bug2");
|
864
1045
|
|
865
1046
|
if (flush != Z_FINISH) return Z_OK;
|
866
1047
|
if (s->wrap <= 0) return Z_STREAM_END;
|
@@ -897,18 +1078,9 @@ int ZEXPORT deflateEnd (strm)
|
|
897
1078
|
{
|
898
1079
|
int status;
|
899
1080
|
|
900
|
-
if (strm
|
1081
|
+
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
901
1082
|
|
902
1083
|
status = strm->state->status;
|
903
|
-
if (status != INIT_STATE &&
|
904
|
-
status != EXTRA_STATE &&
|
905
|
-
status != NAME_STATE &&
|
906
|
-
status != COMMENT_STATE &&
|
907
|
-
status != HCRC_STATE &&
|
908
|
-
status != BUSY_STATE &&
|
909
|
-
status != FINISH_STATE) {
|
910
|
-
return Z_STREAM_ERROR;
|
911
|
-
}
|
912
1084
|
|
913
1085
|
/* Deallocate in reverse order of allocations: */
|
914
1086
|
TRY_FREE(strm, strm->state->pending_buf);
|
@@ -939,18 +1111,18 @@ int ZEXPORT deflateCopy (dest, source)
|
|
939
1111
|
ushf *overlay;
|
940
1112
|
|
941
1113
|
|
942
|
-
if (source
|
1114
|
+
if (deflateStateCheck(source) || dest == Z_NULL) {
|
943
1115
|
return Z_STREAM_ERROR;
|
944
1116
|
}
|
945
1117
|
|
946
1118
|
ss = source->state;
|
947
1119
|
|
948
|
-
zmemcpy(dest, source, sizeof(z_stream));
|
1120
|
+
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
|
949
1121
|
|
950
1122
|
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
|
951
1123
|
if (ds == Z_NULL) return Z_MEM_ERROR;
|
952
1124
|
dest->state = (struct internal_state FAR *) ds;
|
953
|
-
zmemcpy(ds, ss, sizeof(deflate_state));
|
1125
|
+
zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
|
954
1126
|
ds->strm = dest;
|
955
1127
|
|
956
1128
|
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
|
@@ -966,8 +1138,8 @@ int ZEXPORT deflateCopy (dest, source)
|
|
966
1138
|
}
|
967
1139
|
/* following zmemcpy do not work for 16-bit MSDOS */
|
968
1140
|
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
|
969
|
-
zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
|
970
|
-
zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
|
1141
|
+
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
|
1142
|
+
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
|
971
1143
|
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
|
972
1144
|
|
973
1145
|
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
|
@@ -989,7 +1161,7 @@ int ZEXPORT deflateCopy (dest, source)
|
|
989
1161
|
* allocating a large strm->next_in buffer and copying from it.
|
990
1162
|
* (See also flush_pending()).
|
991
1163
|
*/
|
992
|
-
local
|
1164
|
+
local unsigned read_buf(strm, buf, size)
|
993
1165
|
z_streamp strm;
|
994
1166
|
Bytef *buf;
|
995
1167
|
unsigned size;
|
@@ -1001,19 +1173,19 @@ local int read_buf(strm, buf, size)
|
|
1001
1173
|
|
1002
1174
|
strm->avail_in -= len;
|
1003
1175
|
|
1176
|
+
zmemcpy(buf, strm->next_in, len);
|
1004
1177
|
if (strm->state->wrap == 1) {
|
1005
|
-
strm->adler = adler32(strm->adler,
|
1178
|
+
strm->adler = adler32(strm->adler, buf, len);
|
1006
1179
|
}
|
1007
1180
|
#ifdef GZIP
|
1008
1181
|
else if (strm->state->wrap == 2) {
|
1009
|
-
strm->adler = crc32(strm->adler,
|
1182
|
+
strm->adler = crc32(strm->adler, buf, len);
|
1010
1183
|
}
|
1011
1184
|
#endif
|
1012
|
-
zmemcpy(buf, strm->next_in, len);
|
1013
1185
|
strm->next_in += len;
|
1014
1186
|
strm->total_in += len;
|
1015
1187
|
|
1016
|
-
return
|
1188
|
+
return len;
|
1017
1189
|
}
|
1018
1190
|
|
1019
1191
|
/* ===========================================================================
|
@@ -1036,6 +1208,7 @@ local void lm_init (s)
|
|
1036
1208
|
s->strstart = 0;
|
1037
1209
|
s->block_start = 0L;
|
1038
1210
|
s->lookahead = 0;
|
1211
|
+
s->insert = 0;
|
1039
1212
|
s->match_length = s->prev_length = MIN_MATCH-1;
|
1040
1213
|
s->match_available = 0;
|
1041
1214
|
s->ins_h = 0;
|
@@ -1066,9 +1239,9 @@ local uInt longest_match(s, cur_match)
|
|
1066
1239
|
{
|
1067
1240
|
unsigned chain_length = s->max_chain_length;/* max hash chain length */
|
1068
1241
|
register Bytef *scan = s->window + s->strstart; /* current string */
|
1069
|
-
register Bytef *match;
|
1242
|
+
register Bytef *match; /* matched string */
|
1070
1243
|
register int len; /* length of current match */
|
1071
|
-
int best_len = s->prev_length;
|
1244
|
+
int best_len = (int)s->prev_length; /* best match length so far */
|
1072
1245
|
int nice_match = s->nice_match; /* stop if match long enough */
|
1073
1246
|
IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
|
1074
1247
|
s->strstart - (IPos)MAX_DIST(s) : NIL;
|
@@ -1103,7 +1276,7 @@ local uInt longest_match(s, cur_match)
|
|
1103
1276
|
/* Do not look for matches beyond the end of the input. This is necessary
|
1104
1277
|
* to make deflate deterministic.
|
1105
1278
|
*/
|
1106
|
-
if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
|
1279
|
+
if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
|
1107
1280
|
|
1108
1281
|
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
|
1109
1282
|
|
@@ -1264,7 +1437,11 @@ local uInt longest_match(s, cur_match)
|
|
1264
1437
|
|
1265
1438
|
#endif /* FASTEST */
|
1266
1439
|
|
1267
|
-
#ifdef
|
1440
|
+
#ifdef ZLIB_DEBUG
|
1441
|
+
|
1442
|
+
#define EQUAL 0
|
1443
|
+
/* result of memcmp for equal strings */
|
1444
|
+
|
1268
1445
|
/* ===========================================================================
|
1269
1446
|
* Check that the match at match_start is indeed a match.
|
1270
1447
|
*/
|
@@ -1290,7 +1467,7 @@ local void check_match(s, start, match, length)
|
|
1290
1467
|
}
|
1291
1468
|
#else
|
1292
1469
|
# define check_match(s, start, match, length)
|
1293
|
-
#endif /*
|
1470
|
+
#endif /* ZLIB_DEBUG */
|
1294
1471
|
|
1295
1472
|
/* ===========================================================================
|
1296
1473
|
* Fill the window when the lookahead becomes insufficient.
|
@@ -1305,11 +1482,12 @@ local void check_match(s, start, match, length)
|
|
1305
1482
|
local void fill_window(s)
|
1306
1483
|
deflate_state *s;
|
1307
1484
|
{
|
1308
|
-
|
1309
|
-
register Posf *p;
|
1485
|
+
unsigned n;
|
1310
1486
|
unsigned more; /* Amount of free space at the end of the window. */
|
1311
1487
|
uInt wsize = s->w_size;
|
1312
1488
|
|
1489
|
+
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
|
1490
|
+
|
1313
1491
|
do {
|
1314
1492
|
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
|
1315
1493
|
|
@@ -1331,38 +1509,14 @@ local void fill_window(s)
|
|
1331
1509
|
*/
|
1332
1510
|
if (s->strstart >= wsize+MAX_DIST(s)) {
|
1333
1511
|
|
1334
|
-
zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
|
1512
|
+
zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
|
1335
1513
|
s->match_start -= wsize;
|
1336
1514
|
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
|
1337
1515
|
s->block_start -= (long) wsize;
|
1338
|
-
|
1339
|
-
/* Slide the hash table (could be avoided with 32 bit values
|
1340
|
-
at the expense of memory usage). We slide even when level == 0
|
1341
|
-
to keep the hash table consistent if we switch back to level > 0
|
1342
|
-
later. (Using level 0 permanently is not an optimal usage of
|
1343
|
-
zlib, so we don't care about this pathological case.)
|
1344
|
-
*/
|
1345
|
-
n = s->hash_size;
|
1346
|
-
p = &s->head[n];
|
1347
|
-
do {
|
1348
|
-
m = *--p;
|
1349
|
-
*p = (Pos)(m >= wsize ? m-wsize : NIL);
|
1350
|
-
} while (--n);
|
1351
|
-
|
1352
|
-
n = wsize;
|
1353
|
-
#ifndef FASTEST
|
1354
|
-
p = &s->prev[n];
|
1355
|
-
do {
|
1356
|
-
m = *--p;
|
1357
|
-
*p = (Pos)(m >= wsize ? m-wsize : NIL);
|
1358
|
-
/* If n is not on any hash chain, prev[n] is garbage but
|
1359
|
-
* its value will never be used.
|
1360
|
-
*/
|
1361
|
-
} while (--n);
|
1362
|
-
#endif
|
1516
|
+
slide_hash(s);
|
1363
1517
|
more += wsize;
|
1364
1518
|
}
|
1365
|
-
if (s->strm->avail_in == 0)
|
1519
|
+
if (s->strm->avail_in == 0) break;
|
1366
1520
|
|
1367
1521
|
/* If there was no sliding:
|
1368
1522
|
* strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
|
@@ -1381,12 +1535,24 @@ local void fill_window(s)
|
|
1381
1535
|
s->lookahead += n;
|
1382
1536
|
|
1383
1537
|
/* Initialize the hash value now that we have some input: */
|
1384
|
-
if (s->lookahead >= MIN_MATCH) {
|
1385
|
-
|
1386
|
-
|
1538
|
+
if (s->lookahead + s->insert >= MIN_MATCH) {
|
1539
|
+
uInt str = s->strstart - s->insert;
|
1540
|
+
s->ins_h = s->window[str];
|
1541
|
+
UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
|
1387
1542
|
#if MIN_MATCH != 3
|
1388
1543
|
Call UPDATE_HASH() MIN_MATCH-3 more times
|
1389
1544
|
#endif
|
1545
|
+
while (s->insert) {
|
1546
|
+
UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
|
1547
|
+
#ifndef FASTEST
|
1548
|
+
s->prev[str & s->w_mask] = s->head[s->ins_h];
|
1549
|
+
#endif
|
1550
|
+
s->head[s->ins_h] = (Pos)str;
|
1551
|
+
str++;
|
1552
|
+
s->insert--;
|
1553
|
+
if (s->lookahead + s->insert < MIN_MATCH)
|
1554
|
+
break;
|
1555
|
+
}
|
1390
1556
|
}
|
1391
1557
|
/* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
|
1392
1558
|
* but this is not important since only literal bytes will be emitted.
|
@@ -1427,6 +1593,9 @@ local void fill_window(s)
|
|
1427
1593
|
s->high_water += init;
|
1428
1594
|
}
|
1429
1595
|
}
|
1596
|
+
|
1597
|
+
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
1598
|
+
"not enough room for search");
|
1430
1599
|
}
|
1431
1600
|
|
1432
1601
|
/* ===========================================================================
|
@@ -1450,64 +1619,199 @@ local void fill_window(s)
|
|
1450
1619
|
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
|
1451
1620
|
}
|
1452
1621
|
|
1622
|
+
/* Maximum stored block length in deflate format (not including header). */
|
1623
|
+
#define MAX_STORED 65535
|
1624
|
+
|
1625
|
+
/* Minimum of a and b. */
|
1626
|
+
#define MIN(a, b) ((a) > (b) ? (b) : (a))
|
1627
|
+
|
1453
1628
|
/* ===========================================================================
|
1454
1629
|
* Copy without compression as much as possible from the input stream, return
|
1455
1630
|
* the current block state.
|
1456
|
-
*
|
1457
|
-
*
|
1458
|
-
*
|
1459
|
-
*
|
1460
|
-
*
|
1631
|
+
*
|
1632
|
+
* In case deflateParams() is used to later switch to a non-zero compression
|
1633
|
+
* level, s->matches (otherwise unused when storing) keeps track of the number
|
1634
|
+
* of hash table slides to perform. If s->matches is 1, then one hash table
|
1635
|
+
* slide will be done when switching. If s->matches is 2, the maximum value
|
1636
|
+
* allowed here, then the hash table will be cleared, since two or more slides
|
1637
|
+
* is the same as a clear.
|
1638
|
+
*
|
1639
|
+
* deflate_stored() is written to minimize the number of times an input byte is
|
1640
|
+
* copied. It is most efficient with large input and output buffers, which
|
1641
|
+
* maximizes the opportunites to have a single copy from next_in to next_out.
|
1461
1642
|
*/
|
1462
1643
|
local block_state deflate_stored(s, flush)
|
1463
1644
|
deflate_state *s;
|
1464
1645
|
int flush;
|
1465
1646
|
{
|
1466
|
-
/*
|
1467
|
-
*
|
1647
|
+
/* Smallest worthy block size when not flushing or finishing. By default
|
1648
|
+
* this is 32K. This can be as small as 507 bytes for memLevel == 1. For
|
1649
|
+
* large input and output buffers, the stored block size will be larger.
|
1468
1650
|
*/
|
1469
|
-
|
1470
|
-
ulg max_start;
|
1651
|
+
unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size);
|
1471
1652
|
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1653
|
+
/* Copy as many min_block or larger stored blocks directly to next_out as
|
1654
|
+
* possible. If flushing, copy the remaining available input to next_out as
|
1655
|
+
* stored blocks, if there is enough space.
|
1656
|
+
*/
|
1657
|
+
unsigned len, left, have, last = 0;
|
1658
|
+
unsigned used = s->strm->avail_in;
|
1659
|
+
do {
|
1660
|
+
/* Set len to the maximum size block that we can copy directly with the
|
1661
|
+
* available input data and output space. Set left to how much of that
|
1662
|
+
* would be copied from what's left in the window.
|
1663
|
+
*/
|
1664
|
+
len = MAX_STORED; /* maximum deflate stored block length */
|
1665
|
+
have = (s->bi_valid + 42) >> 3; /* number of header bytes */
|
1666
|
+
if (s->strm->avail_out < have) /* need room for header */
|
1667
|
+
break;
|
1668
|
+
/* maximum stored block length that will fit in avail_out: */
|
1669
|
+
have = s->strm->avail_out - have;
|
1670
|
+
left = s->strstart - s->block_start; /* bytes left in window */
|
1671
|
+
if (len > (ulg)left + s->strm->avail_in)
|
1672
|
+
len = left + s->strm->avail_in; /* limit len to the input */
|
1673
|
+
if (len > have)
|
1674
|
+
len = have; /* limit len to the output */
|
1675
|
+
|
1676
|
+
/* If the stored block would be less than min_block in length, or if
|
1677
|
+
* unable to copy all of the available input when flushing, then try
|
1678
|
+
* copying to the window and the pending buffer instead. Also don't
|
1679
|
+
* write an empty block when flushing -- deflate() does that.
|
1680
|
+
*/
|
1681
|
+
if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
|
1682
|
+
flush == Z_NO_FLUSH ||
|
1683
|
+
len != left + s->strm->avail_in))
|
1684
|
+
break;
|
1483
1685
|
|
1484
|
-
|
1485
|
-
|
1686
|
+
/* Make a dummy stored block in pending to get the header bytes,
|
1687
|
+
* including any pending bits. This also updates the debugging counts.
|
1688
|
+
*/
|
1689
|
+
last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
|
1690
|
+
_tr_stored_block(s, (char *)0, 0L, last);
|
1691
|
+
|
1692
|
+
/* Replace the lengths in the dummy stored block with len. */
|
1693
|
+
s->pending_buf[s->pending - 4] = len;
|
1694
|
+
s->pending_buf[s->pending - 3] = len >> 8;
|
1695
|
+
s->pending_buf[s->pending - 2] = ~len;
|
1696
|
+
s->pending_buf[s->pending - 1] = ~len >> 8;
|
1697
|
+
|
1698
|
+
/* Write the stored block header bytes. */
|
1699
|
+
flush_pending(s->strm);
|
1700
|
+
|
1701
|
+
#ifdef ZLIB_DEBUG
|
1702
|
+
/* Update debugging counts for the data about to be copied. */
|
1703
|
+
s->compressed_len += len << 3;
|
1704
|
+
s->bits_sent += len << 3;
|
1705
|
+
#endif
|
1486
1706
|
|
1487
|
-
|
1707
|
+
/* Copy uncompressed bytes from the window to next_out. */
|
1708
|
+
if (left) {
|
1709
|
+
if (left > len)
|
1710
|
+
left = len;
|
1711
|
+
zmemcpy(s->strm->next_out, s->window + s->block_start, left);
|
1712
|
+
s->strm->next_out += left;
|
1713
|
+
s->strm->avail_out -= left;
|
1714
|
+
s->strm->total_out += left;
|
1715
|
+
s->block_start += left;
|
1716
|
+
len -= left;
|
1488
1717
|
}
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
s->lookahead = (uInt)(s->strstart - max_start);
|
1499
|
-
s->strstart = (uInt)max_start;
|
1500
|
-
FLUSH_BLOCK(s, 0);
|
1718
|
+
|
1719
|
+
/* Copy uncompressed bytes directly from next_in to next_out, updating
|
1720
|
+
* the check value.
|
1721
|
+
*/
|
1722
|
+
if (len) {
|
1723
|
+
read_buf(s->strm, s->strm->next_out, len);
|
1724
|
+
s->strm->next_out += len;
|
1725
|
+
s->strm->avail_out -= len;
|
1726
|
+
s->strm->total_out += len;
|
1501
1727
|
}
|
1502
|
-
|
1503
|
-
|
1728
|
+
} while (last == 0);
|
1729
|
+
|
1730
|
+
/* Update the sliding window with the last s->w_size bytes of the copied
|
1731
|
+
* data, or append all of the copied data to the existing window if less
|
1732
|
+
* than s->w_size bytes were copied. Also update the number of bytes to
|
1733
|
+
* insert in the hash tables, in the event that deflateParams() switches to
|
1734
|
+
* a non-zero compression level.
|
1735
|
+
*/
|
1736
|
+
used -= s->strm->avail_in; /* number of input bytes directly copied */
|
1737
|
+
if (used) {
|
1738
|
+
/* If any input was used, then no unused input remains in the window,
|
1739
|
+
* therefore s->block_start == s->strstart.
|
1504
1740
|
*/
|
1505
|
-
if (
|
1506
|
-
|
1741
|
+
if (used >= s->w_size) { /* supplant the previous history */
|
1742
|
+
s->matches = 2; /* clear hash */
|
1743
|
+
zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size);
|
1744
|
+
s->strstart = s->w_size;
|
1745
|
+
}
|
1746
|
+
else {
|
1747
|
+
if (s->window_size - s->strstart <= used) {
|
1748
|
+
/* Slide the window down. */
|
1749
|
+
s->strstart -= s->w_size;
|
1750
|
+
zmemcpy(s->window, s->window + s->w_size, s->strstart);
|
1751
|
+
if (s->matches < 2)
|
1752
|
+
s->matches++; /* add a pending slide_hash() */
|
1753
|
+
}
|
1754
|
+
zmemcpy(s->window + s->strstart, s->strm->next_in - used, used);
|
1755
|
+
s->strstart += used;
|
1507
1756
|
}
|
1757
|
+
s->block_start = s->strstart;
|
1758
|
+
s->insert += MIN(used, s->w_size - s->insert);
|
1759
|
+
}
|
1760
|
+
if (s->high_water < s->strstart)
|
1761
|
+
s->high_water = s->strstart;
|
1762
|
+
|
1763
|
+
/* If the last block was written to next_out, then done. */
|
1764
|
+
if (last)
|
1765
|
+
return finish_done;
|
1766
|
+
|
1767
|
+
/* If flushing and all input has been consumed, then done. */
|
1768
|
+
if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
|
1769
|
+
s->strm->avail_in == 0 && (long)s->strstart == s->block_start)
|
1770
|
+
return block_done;
|
1771
|
+
|
1772
|
+
/* Fill the window with any remaining input. */
|
1773
|
+
have = s->window_size - s->strstart - 1;
|
1774
|
+
if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
|
1775
|
+
/* Slide the window down. */
|
1776
|
+
s->block_start -= s->w_size;
|
1777
|
+
s->strstart -= s->w_size;
|
1778
|
+
zmemcpy(s->window, s->window + s->w_size, s->strstart);
|
1779
|
+
if (s->matches < 2)
|
1780
|
+
s->matches++; /* add a pending slide_hash() */
|
1781
|
+
have += s->w_size; /* more space now */
|
1782
|
+
}
|
1783
|
+
if (have > s->strm->avail_in)
|
1784
|
+
have = s->strm->avail_in;
|
1785
|
+
if (have) {
|
1786
|
+
read_buf(s->strm, s->window + s->strstart, have);
|
1787
|
+
s->strstart += have;
|
1788
|
+
}
|
1789
|
+
if (s->high_water < s->strstart)
|
1790
|
+
s->high_water = s->strstart;
|
1791
|
+
|
1792
|
+
/* There was not enough avail_out to write a complete worthy or flushed
|
1793
|
+
* stored block to next_out. Write a stored block to pending instead, if we
|
1794
|
+
* have enough input for a worthy block, or if flushing and there is enough
|
1795
|
+
* room for the remaining input as a stored block in the pending buffer.
|
1796
|
+
*/
|
1797
|
+
have = (s->bi_valid + 42) >> 3; /* number of header bytes */
|
1798
|
+
/* maximum stored block length that will fit in pending: */
|
1799
|
+
have = MIN(s->pending_buf_size - have, MAX_STORED);
|
1800
|
+
min_block = MIN(have, s->w_size);
|
1801
|
+
left = s->strstart - s->block_start;
|
1802
|
+
if (left >= min_block ||
|
1803
|
+
((left || flush == Z_FINISH) && flush != Z_NO_FLUSH &&
|
1804
|
+
s->strm->avail_in == 0 && left <= have)) {
|
1805
|
+
len = MIN(left, have);
|
1806
|
+
last = flush == Z_FINISH && s->strm->avail_in == 0 &&
|
1807
|
+
len == left ? 1 : 0;
|
1808
|
+
_tr_stored_block(s, (charf *)s->window + s->block_start, len, last);
|
1809
|
+
s->block_start += len;
|
1810
|
+
flush_pending(s->strm);
|
1508
1811
|
}
|
1509
|
-
|
1510
|
-
|
1812
|
+
|
1813
|
+
/* We've done all we can with the available input and output. */
|
1814
|
+
return last ? finish_started : need_more;
|
1511
1815
|
}
|
1512
1816
|
|
1513
1817
|
/* ===========================================================================
|
@@ -1603,8 +1907,14 @@ local block_state deflate_fast(s, flush)
|
|
1603
1907
|
}
|
1604
1908
|
if (bflush) FLUSH_BLOCK(s, 0);
|
1605
1909
|
}
|
1606
|
-
|
1607
|
-
|
1910
|
+
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
|
1911
|
+
if (flush == Z_FINISH) {
|
1912
|
+
FLUSH_BLOCK(s, 1);
|
1913
|
+
return finish_done;
|
1914
|
+
}
|
1915
|
+
if (s->last_lit)
|
1916
|
+
FLUSH_BLOCK(s, 0);
|
1917
|
+
return block_done;
|
1608
1918
|
}
|
1609
1919
|
|
1610
1920
|
#ifndef FASTEST
|
@@ -1728,8 +2038,14 @@ local block_state deflate_slow(s, flush)
|
|
1728
2038
|
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
1729
2039
|
s->match_available = 0;
|
1730
2040
|
}
|
1731
|
-
|
1732
|
-
|
2041
|
+
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
|
2042
|
+
if (flush == Z_FINISH) {
|
2043
|
+
FLUSH_BLOCK(s, 1);
|
2044
|
+
return finish_done;
|
2045
|
+
}
|
2046
|
+
if (s->last_lit)
|
2047
|
+
FLUSH_BLOCK(s, 0);
|
2048
|
+
return block_done;
|
1733
2049
|
}
|
1734
2050
|
#endif /* FASTEST */
|
1735
2051
|
|
@@ -1749,11 +2065,11 @@ local block_state deflate_rle(s, flush)
|
|
1749
2065
|
for (;;) {
|
1750
2066
|
/* Make sure that we always have enough lookahead, except
|
1751
2067
|
* at the end of the input file. We need MAX_MATCH bytes
|
1752
|
-
* for the longest
|
2068
|
+
* for the longest run, plus one for the unrolled loop.
|
1753
2069
|
*/
|
1754
|
-
if (s->lookahead
|
2070
|
+
if (s->lookahead <= MAX_MATCH) {
|
1755
2071
|
fill_window(s);
|
1756
|
-
if (s->lookahead
|
2072
|
+
if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
|
1757
2073
|
return need_more;
|
1758
2074
|
}
|
1759
2075
|
if (s->lookahead == 0) break; /* flush the current block */
|
@@ -1772,10 +2088,11 @@ local block_state deflate_rle(s, flush)
|
|
1772
2088
|
prev == *++scan && prev == *++scan &&
|
1773
2089
|
prev == *++scan && prev == *++scan &&
|
1774
2090
|
scan < strend);
|
1775
|
-
s->match_length = MAX_MATCH - (
|
2091
|
+
s->match_length = MAX_MATCH - (uInt)(strend - scan);
|
1776
2092
|
if (s->match_length > s->lookahead)
|
1777
2093
|
s->match_length = s->lookahead;
|
1778
2094
|
}
|
2095
|
+
Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
|
1779
2096
|
}
|
1780
2097
|
|
1781
2098
|
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
|
@@ -1796,8 +2113,14 @@ local block_state deflate_rle(s, flush)
|
|
1796
2113
|
}
|
1797
2114
|
if (bflush) FLUSH_BLOCK(s, 0);
|
1798
2115
|
}
|
1799
|
-
|
1800
|
-
|
2116
|
+
s->insert = 0;
|
2117
|
+
if (flush == Z_FINISH) {
|
2118
|
+
FLUSH_BLOCK(s, 1);
|
2119
|
+
return finish_done;
|
2120
|
+
}
|
2121
|
+
if (s->last_lit)
|
2122
|
+
FLUSH_BLOCK(s, 0);
|
2123
|
+
return block_done;
|
1801
2124
|
}
|
1802
2125
|
|
1803
2126
|
/* ===========================================================================
|
@@ -1829,6 +2152,12 @@ local block_state deflate_huff(s, flush)
|
|
1829
2152
|
s->strstart++;
|
1830
2153
|
if (bflush) FLUSH_BLOCK(s, 0);
|
1831
2154
|
}
|
1832
|
-
|
1833
|
-
|
2155
|
+
s->insert = 0;
|
2156
|
+
if (flush == Z_FINISH) {
|
2157
|
+
FLUSH_BLOCK(s, 1);
|
2158
|
+
return finish_done;
|
2159
|
+
}
|
2160
|
+
if (s->last_lit)
|
2161
|
+
FLUSH_BLOCK(s, 0);
|
2162
|
+
return block_done;
|
1834
2163
|
}
|