rugged 1.3.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -2
- data/ext/rugged/extconf.rb +6 -3
- data/ext/rugged/rugged.c +16 -0
- data/ext/rugged/rugged.h +4 -0
- data/ext/rugged/rugged_allocator.c +0 -54
- data/ext/rugged/rugged_blame.c +2 -0
- data/ext/rugged/rugged_blob.c +3 -0
- data/ext/rugged/rugged_commit.c +1 -0
- data/ext/rugged/rugged_config.c +9 -2
- data/ext/rugged/rugged_diff.c +1 -0
- data/ext/rugged/rugged_index.c +2 -0
- data/ext/rugged/rugged_patch.c +1 -0
- data/ext/rugged/rugged_rebase.c +1 -0
- data/ext/rugged/rugged_reference.c +1 -0
- data/ext/rugged/rugged_remote.c +28 -10
- data/ext/rugged/rugged_repo.c +7 -9
- data/ext/rugged/rugged_revwalk.c +5 -1
- data/ext/rugged/rugged_settings.c +5 -0
- data/ext/rugged/rugged_submodule.c +1 -0
- data/ext/rugged/rugged_tag.c +1 -0
- data/ext/rugged/rugged_tree.c +4 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/tree.rb +5 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/AUTHORS +1 -0
- data/vendor/libgit2/CMakeLists.txt +141 -289
- data/vendor/libgit2/COPYING +301 -20
- data/vendor/libgit2/cmake/AddCFlagIfSupported.cmake +21 -21
- data/vendor/libgit2/cmake/AddClarTest.cmake +7 -0
- data/vendor/libgit2/cmake/CheckPrototypeDefinitionSafe.cmake +16 -0
- data/vendor/libgit2/cmake/DefaultCFlags.cmake +154 -0
- data/vendor/libgit2/cmake/EnableWarnings.cmake +13 -13
- data/vendor/libgit2/cmake/ExperimentalFeatures.cmake +23 -0
- data/vendor/libgit2/cmake/FindCoreFoundation.cmake +13 -13
- data/vendor/libgit2/cmake/FindGSSAPI.cmake +171 -287
- data/vendor/libgit2/cmake/FindGSSFramework.cmake +13 -13
- data/vendor/libgit2/cmake/FindHTTP_Parser.cmake +17 -17
- data/vendor/libgit2/cmake/FindIntlIconv.cmake +51 -0
- data/vendor/libgit2/cmake/FindLLHTTP.cmake +39 -0
- data/vendor/libgit2/cmake/FindLibSSH2.cmake +5 -5
- data/vendor/libgit2/cmake/FindPCRE.cmake +12 -13
- data/vendor/libgit2/cmake/FindPCRE2.cmake +12 -12
- data/vendor/libgit2/cmake/FindPkgLibraries.cmake +19 -19
- data/vendor/libgit2/cmake/FindSecurity.cmake +14 -14
- data/vendor/libgit2/cmake/FindStatNsec.cmake +12 -18
- data/vendor/libgit2/cmake/Findfutimens.cmake +8 -8
- data/vendor/libgit2/cmake/FindmbedTLS.cmake +63 -70
- data/vendor/libgit2/cmake/IdeSplitSources.cmake +18 -18
- data/vendor/libgit2/cmake/PkgBuildConfig.cmake +60 -60
- data/vendor/libgit2/cmake/SanitizeBool.cmake +20 -20
- data/vendor/libgit2/cmake/SelectGSSAPI.cmake +37 -37
- data/vendor/libgit2/cmake/SelectHTTPParser.cmake +34 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +129 -101
- data/vendor/libgit2/cmake/SelectHashes.cmake +113 -54
- data/vendor/libgit2/cmake/SelectRegex.cmake +56 -0
- data/vendor/libgit2/cmake/SelectSSH.cmake +46 -0
- data/vendor/libgit2/cmake/SelectXdiff.cmake +9 -0
- data/vendor/libgit2/cmake/SelectZlib.cmake +38 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +6 -6
- data/vendor/libgit2/deps/llhttp/CMakeLists.txt +8 -0
- data/vendor/libgit2/deps/llhttp/LICENSE-MIT +22 -0
- data/vendor/libgit2/deps/llhttp/api.c +510 -0
- data/vendor/libgit2/deps/llhttp/http.c +170 -0
- data/vendor/libgit2/deps/llhttp/llhttp.c +10168 -0
- data/vendor/libgit2/deps/llhttp/llhttp.h +897 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +33 -31
- data/vendor/libgit2/deps/ntlmclient/crypt_builtin_md4.c +311 -0
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +2 -1
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +0 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +7 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +25 -25
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +4 -4
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +2 -2
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +5 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +2 -1
- data/vendor/libgit2/deps/ntlmclient/utf8.h +1176 -721
- data/vendor/libgit2/deps/ntlmclient/util.h +11 -0
- data/vendor/libgit2/deps/pcre/CMakeLists.txt +89 -88
- data/vendor/libgit2/deps/pcre/LICENCE +5 -5
- data/vendor/libgit2/deps/pcre/pcre.h +2 -2
- data/vendor/libgit2/deps/pcre/pcre_compile.c +6 -3
- data/vendor/libgit2/deps/pcre/pcre_exec.c +2 -2
- data/vendor/libgit2/deps/winhttp/CMakeLists.txt +14 -16
- data/vendor/libgit2/deps/xdiff/CMakeLists.txt +28 -0
- data/vendor/libgit2/deps/xdiff/git-xdiff.h +56 -0
- data/vendor/libgit2/{src → deps}/xdiff/xdiff.h +15 -15
- data/vendor/libgit2/{src → deps}/xdiff/xdiffi.c +152 -125
- data/vendor/libgit2/{src → deps}/xdiff/xdiffi.h +2 -4
- data/vendor/libgit2/{src → deps}/xdiff/xemit.c +26 -10
- data/vendor/libgit2/{src → deps}/xdiff/xhistogram.c +92 -94
- data/vendor/libgit2/{src → deps}/xdiff/xinclude.h +1 -12
- data/vendor/libgit2/{src → deps}/xdiff/xmacros.h +18 -1
- data/vendor/libgit2/{src → deps}/xdiff/xmerge.c +126 -137
- data/vendor/libgit2/{src → deps}/xdiff/xpatience.c +26 -46
- data/vendor/libgit2/{src → deps}/xdiff/xprepare.c +24 -46
- data/vendor/libgit2/{src → deps}/xdiff/xutils.c +36 -8
- data/vendor/libgit2/{src → deps}/xdiff/xutils.h +2 -1
- data/vendor/libgit2/deps/zlib/CMakeLists.txt +6 -1
- data/vendor/libgit2/deps/zlib/LICENSE +22 -0
- data/vendor/libgit2/deps/zlib/adler32.c +7 -22
- data/vendor/libgit2/deps/zlib/crc32.c +931 -317
- data/vendor/libgit2/deps/zlib/crc32.h +9441 -436
- data/vendor/libgit2/deps/zlib/deflate.c +428 -453
- data/vendor/libgit2/deps/zlib/deflate.h +51 -23
- data/vendor/libgit2/deps/zlib/gzguts.h +15 -19
- data/vendor/libgit2/deps/zlib/infback.c +19 -31
- data/vendor/libgit2/deps/zlib/inffast.c +15 -18
- data/vendor/libgit2/deps/zlib/inffast.h +1 -1
- data/vendor/libgit2/deps/zlib/inflate.c +75 -110
- data/vendor/libgit2/deps/zlib/inflate.h +3 -2
- data/vendor/libgit2/deps/zlib/inftrees.c +6 -11
- data/vendor/libgit2/deps/zlib/inftrees.h +6 -6
- data/vendor/libgit2/deps/zlib/trees.c +294 -380
- data/vendor/libgit2/deps/zlib/zconf.h +23 -14
- data/vendor/libgit2/deps/zlib/zlib.h +310 -284
- data/vendor/libgit2/deps/zlib/zutil.c +20 -46
- data/vendor/libgit2/deps/zlib/zutil.h +24 -41
- data/vendor/libgit2/include/git2/annotated_commit.h +12 -5
- data/vendor/libgit2/include/git2/apply.h +43 -8
- data/vendor/libgit2/include/git2/attr.h +28 -6
- data/vendor/libgit2/include/git2/blame.h +137 -29
- data/vendor/libgit2/include/git2/blob.h +85 -29
- data/vendor/libgit2/include/git2/branch.h +25 -16
- data/vendor/libgit2/include/git2/buffer.h +24 -82
- data/vendor/libgit2/include/git2/cert.h +4 -3
- data/vendor/libgit2/include/git2/checkout.h +88 -34
- data/vendor/libgit2/include/git2/cherrypick.h +10 -3
- data/vendor/libgit2/include/git2/clone.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +134 -3
- data/vendor/libgit2/include/git2/common.h +172 -59
- data/vendor/libgit2/include/git2/config.h +118 -32
- data/vendor/libgit2/include/git2/credential.h +32 -3
- data/vendor/libgit2/include/git2/credential_helpers.h +2 -0
- data/vendor/libgit2/include/git2/deprecated.h +141 -3
- data/vendor/libgit2/include/git2/describe.h +20 -3
- data/vendor/libgit2/include/git2/diff.h +95 -19
- data/vendor/libgit2/include/git2/email.h +10 -30
- data/vendor/libgit2/include/git2/errors.h +51 -61
- data/vendor/libgit2/include/git2/experimental.h +20 -0
- data/vendor/libgit2/include/git2/filter.h +21 -9
- data/vendor/libgit2/include/git2/global.h +8 -1
- data/vendor/libgit2/include/git2/graph.h +4 -2
- data/vendor/libgit2/include/git2/ignore.h +11 -1
- data/vendor/libgit2/include/git2/index.h +111 -11
- data/vendor/libgit2/include/git2/indexer.h +67 -2
- data/vendor/libgit2/include/git2/mailmap.h +7 -1
- data/vendor/libgit2/include/git2/merge.h +70 -5
- data/vendor/libgit2/include/git2/message.h +4 -2
- data/vendor/libgit2/include/git2/net.h +3 -1
- data/vendor/libgit2/include/git2/notes.h +9 -6
- data/vendor/libgit2/include/git2/object.h +57 -7
- data/vendor/libgit2/include/git2/odb.h +156 -33
- data/vendor/libgit2/include/git2/odb_backend.h +132 -16
- data/vendor/libgit2/include/git2/oid.h +116 -17
- data/vendor/libgit2/include/git2/oidarray.h +7 -1
- data/vendor/libgit2/include/git2/pack.h +37 -9
- data/vendor/libgit2/include/git2/patch.h +10 -3
- data/vendor/libgit2/include/git2/pathspec.h +10 -1
- data/vendor/libgit2/include/git2/proxy.h +11 -1
- data/vendor/libgit2/include/git2/rebase.h +18 -7
- data/vendor/libgit2/include/git2/refdb.h +5 -2
- data/vendor/libgit2/include/git2/reflog.h +4 -3
- data/vendor/libgit2/include/git2/refs.h +11 -8
- data/vendor/libgit2/include/git2/refspec.h +14 -4
- data/vendor/libgit2/include/git2/remote.h +295 -54
- data/vendor/libgit2/include/git2/repository.h +95 -25
- data/vendor/libgit2/include/git2/reset.h +18 -5
- data/vendor/libgit2/include/git2/revert.h +9 -4
- data/vendor/libgit2/include/git2/revparse.h +4 -4
- data/vendor/libgit2/include/git2/revwalk.h +7 -3
- data/vendor/libgit2/include/git2/signature.h +47 -2
- data/vendor/libgit2/include/git2/stash.h +78 -10
- data/vendor/libgit2/include/git2/status.h +24 -11
- data/vendor/libgit2/include/git2/stdint.h +87 -85
- data/vendor/libgit2/include/git2/strarray.h +2 -16
- data/vendor/libgit2/include/git2/submodule.h +27 -11
- data/vendor/libgit2/include/git2/sys/alloc.h +12 -34
- data/vendor/libgit2/include/git2/sys/commit.h +77 -3
- data/vendor/libgit2/include/git2/sys/commit_graph.h +110 -59
- data/vendor/libgit2/include/git2/sys/config.h +80 -4
- data/vendor/libgit2/include/git2/sys/credential.h +4 -3
- data/vendor/libgit2/include/git2/sys/diff.h +21 -1
- data/vendor/libgit2/include/git2/sys/email.h +7 -0
- data/vendor/libgit2/include/git2/sys/errors.h +76 -0
- data/vendor/libgit2/include/git2/sys/filter.h +66 -3
- data/vendor/libgit2/include/git2/sys/hashsig.h +11 -0
- data/vendor/libgit2/include/git2/sys/index.h +3 -2
- data/vendor/libgit2/include/git2/sys/mempack.h +32 -2
- data/vendor/libgit2/include/git2/sys/merge.h +55 -7
- data/vendor/libgit2/include/git2/sys/midx.h +47 -4
- data/vendor/libgit2/include/git2/sys/odb_backend.h +10 -9
- data/vendor/libgit2/include/git2/sys/openssl.h +8 -1
- data/vendor/libgit2/include/git2/sys/path.h +12 -1
- data/vendor/libgit2/include/git2/sys/refdb_backend.h +40 -36
- data/vendor/libgit2/include/git2/sys/refs.h +3 -2
- data/vendor/libgit2/include/git2/sys/remote.h +53 -0
- data/vendor/libgit2/include/git2/sys/repository.h +63 -3
- data/vendor/libgit2/include/git2/sys/stream.h +26 -3
- data/vendor/libgit2/include/git2/sys/transport.h +87 -41
- data/vendor/libgit2/include/git2/tag.h +4 -1
- data/vendor/libgit2/include/git2/trace.h +9 -3
- data/vendor/libgit2/include/git2/transaction.h +3 -2
- data/vendor/libgit2/include/git2/transport.h +11 -3
- data/vendor/libgit2/include/git2/tree.h +20 -8
- data/vendor/libgit2/include/git2/types.h +26 -10
- data/vendor/libgit2/include/git2/version.h +63 -6
- data/vendor/libgit2/include/git2/worktree.h +30 -8
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +203 -420
- data/vendor/libgit2/src/README.md +12 -0
- data/vendor/libgit2/src/cli/CMakeLists.txt +56 -0
- data/vendor/libgit2/src/cli/README.md +26 -0
- data/vendor/libgit2/src/{branch.h → cli/cmd.c} +10 -8
- data/vendor/libgit2/src/cli/cmd.h +37 -0
- data/vendor/libgit2/src/cli/cmd_blame.c +287 -0
- data/vendor/libgit2/src/cli/cmd_cat_file.c +202 -0
- data/vendor/libgit2/src/cli/cmd_clone.c +190 -0
- data/vendor/libgit2/src/cli/cmd_config.c +241 -0
- data/vendor/libgit2/src/cli/cmd_hash_object.c +152 -0
- data/vendor/libgit2/src/cli/cmd_help.c +85 -0
- data/vendor/libgit2/src/cli/cmd_index_pack.c +114 -0
- data/vendor/libgit2/src/cli/cmd_init.c +102 -0
- data/vendor/libgit2/src/cli/common.c +168 -0
- data/vendor/libgit2/src/cli/common.h +63 -0
- data/vendor/libgit2/src/cli/error.h +51 -0
- data/vendor/libgit2/src/cli/main.c +134 -0
- data/vendor/libgit2/src/cli/opt.c +695 -0
- data/vendor/libgit2/src/cli/opt.h +367 -0
- data/vendor/libgit2/src/cli/opt_usage.c +263 -0
- data/vendor/libgit2/src/cli/opt_usage.h +40 -0
- data/vendor/libgit2/src/cli/progress.c +395 -0
- data/vendor/libgit2/src/cli/progress.h +129 -0
- data/vendor/libgit2/src/cli/sighandler.h +20 -0
- data/vendor/libgit2/src/cli/unix/sighandler.c +37 -0
- data/vendor/libgit2/src/cli/win32/precompiled.h +3 -0
- data/vendor/libgit2/src/cli/win32/sighandler.c +37 -0
- data/vendor/libgit2/src/libgit2/CMakeLists.txt +140 -0
- data/vendor/libgit2/src/{annotated_commit.c → libgit2/annotated_commit.c} +2 -2
- data/vendor/libgit2/src/{annotated_commit.h → libgit2/annotated_commit.h} +2 -2
- data/vendor/libgit2/src/{apply.c → libgit2/apply.c} +32 -34
- data/vendor/libgit2/src/{apply.h → libgit2/apply.h} +2 -2
- data/vendor/libgit2/src/{attr.c → libgit2/attr.c} +48 -31
- data/vendor/libgit2/src/{attr_file.c → libgit2/attr_file.c} +25 -20
- data/vendor/libgit2/src/{attr_file.h → libgit2/attr_file.h} +6 -4
- data/vendor/libgit2/src/{attrcache.c → libgit2/attrcache.c} +87 -46
- data/vendor/libgit2/src/{attrcache.h → libgit2/attrcache.h} +5 -9
- data/vendor/libgit2/src/{blame.c → libgit2/blame.c} +152 -57
- data/vendor/libgit2/src/{blame.h → libgit2/blame.h} +1 -0
- data/vendor/libgit2/src/{blame_git.c → libgit2/blame_git.c} +1 -2
- data/vendor/libgit2/src/{blob.c → libgit2/blob.c} +38 -29
- data/vendor/libgit2/src/{blob.h → libgit2/blob.h} +3 -3
- data/vendor/libgit2/src/{branch.c → libgit2/branch.c} +164 -118
- data/vendor/libgit2/src/libgit2/branch.h +31 -0
- data/vendor/libgit2/src/libgit2/buf.c +126 -0
- data/vendor/libgit2/src/libgit2/buf.h +50 -0
- data/vendor/libgit2/src/{cache.c → libgit2/cache.c} +22 -17
- data/vendor/libgit2/src/{cache.h → libgit2/cache.h} +7 -9
- data/vendor/libgit2/src/{checkout.c → libgit2/checkout.c} +107 -91
- data/vendor/libgit2/src/{checkout.h → libgit2/checkout.h} +0 -2
- data/vendor/libgit2/src/{cherrypick.c → libgit2/cherrypick.c} +14 -15
- data/vendor/libgit2/src/{clone.c → libgit2/clone.c} +254 -203
- data/vendor/libgit2/src/{clone.h → libgit2/clone.h} +4 -1
- data/vendor/libgit2/src/{commit.c → libgit2/commit.c} +296 -77
- data/vendor/libgit2/src/libgit2/commit.h +87 -0
- data/vendor/libgit2/src/{commit_graph.c → libgit2/commit_graph.c} +246 -135
- data/vendor/libgit2/src/{commit_graph.h → libgit2/commit_graph.h} +33 -8
- data/vendor/libgit2/src/{commit_list.c → libgit2/commit_list.c} +17 -7
- data/vendor/libgit2/src/{commit_list.h → libgit2/commit_list.h} +1 -0
- data/vendor/libgit2/src/libgit2/common.h +55 -0
- data/vendor/libgit2/src/{config.c → libgit2/config.c} +490 -360
- data/vendor/libgit2/src/libgit2/config.cmake.in +3 -0
- data/vendor/libgit2/src/{config.h → libgit2/config.h} +24 -6
- data/vendor/libgit2/src/{config_backend.h → libgit2/config_backend.h} +8 -10
- data/vendor/libgit2/src/{config_cache.c → libgit2/config_cache.c} +4 -5
- data/vendor/libgit2/src/{config_file.c → libgit2/config_file.c} +212 -183
- data/vendor/libgit2/src/libgit2/config_list.c +285 -0
- data/vendor/libgit2/src/libgit2/config_list.h +32 -0
- data/vendor/libgit2/src/libgit2/config_mem.c +374 -0
- data/vendor/libgit2/src/{config_parse.c → libgit2/config_parse.c} +37 -32
- data/vendor/libgit2/src/{config_snapshot.c → libgit2/config_snapshot.c} +24 -31
- data/vendor/libgit2/src/{crlf.c → libgit2/crlf.c} +24 -21
- data/vendor/libgit2/src/{describe.c → libgit2/describe.c} +62 -51
- data/vendor/libgit2/src/{diff.c → libgit2/diff.c} +44 -14
- data/vendor/libgit2/src/{diff.h → libgit2/diff.h} +8 -10
- data/vendor/libgit2/src/{diff_driver.c → libgit2/diff_driver.c} +46 -55
- data/vendor/libgit2/src/{diff_driver.h → libgit2/diff_driver.h} +5 -5
- data/vendor/libgit2/src/{diff_file.c → libgit2/diff_file.c} +45 -27
- data/vendor/libgit2/src/{diff_generate.c → libgit2/diff_generate.c} +70 -20
- data/vendor/libgit2/src/{diff_generate.h → libgit2/diff_generate.h} +5 -3
- data/vendor/libgit2/src/{diff_parse.c → libgit2/diff_parse.c} +22 -6
- data/vendor/libgit2/src/{diff_print.c → libgit2/diff_print.c} +192 -105
- data/vendor/libgit2/src/{diff_stats.c → libgit2/diff_stats.c} +40 -29
- data/vendor/libgit2/src/libgit2/diff_stats.h +18 -0
- data/vendor/libgit2/src/{diff_tform.c → libgit2/diff_tform.c} +49 -16
- data/vendor/libgit2/src/{diff_xdiff.c → libgit2/diff_xdiff.c} +4 -8
- data/vendor/libgit2/src/{diff_xdiff.h → libgit2/diff_xdiff.h} +1 -1
- data/vendor/libgit2/src/{email.c → libgit2/email.c} +58 -40
- data/vendor/libgit2/src/{email.h → libgit2/email.h} +1 -1
- data/vendor/libgit2/src/{transports/ssh.h → libgit2/experimental.h.in} +3 -4
- data/vendor/libgit2/src/{fetch.c → libgit2/fetch.c} +105 -30
- data/vendor/libgit2/src/{fetch.h → libgit2/fetch.h} +1 -3
- data/vendor/libgit2/src/{fetchhead.c → libgit2/fetchhead.c} +30 -28
- data/vendor/libgit2/src/{filter.c → libgit2/filter.c} +132 -58
- data/vendor/libgit2/src/{filter.h → libgit2/filter.h} +26 -5
- data/vendor/libgit2/src/{win32 → libgit2}/git2.rc +3 -3
- data/vendor/libgit2/src/libgit2/grafts.c +270 -0
- data/vendor/libgit2/src/libgit2/grafts.h +35 -0
- data/vendor/libgit2/src/{graph.c → libgit2/graph.c} +1 -1
- data/vendor/libgit2/src/libgit2/hashmap_oid.h +30 -0
- data/vendor/libgit2/src/{ident.c → libgit2/ident.c} +20 -20
- data/vendor/libgit2/src/{ignore.c → libgit2/ignore.c} +44 -39
- data/vendor/libgit2/src/{ignore.h → libgit2/ignore.h} +2 -2
- data/vendor/libgit2/src/{index.c → libgit2/index.c} +460 -276
- data/vendor/libgit2/src/{index.h → libgit2/index.h} +21 -5
- data/vendor/libgit2/src/libgit2/index_map.c +95 -0
- data/vendor/libgit2/src/libgit2/index_map.h +28 -0
- data/vendor/libgit2/src/{indexer.c → libgit2/indexer.c} +208 -124
- data/vendor/libgit2/src/{iterator.c → libgit2/iterator.c} +102 -71
- data/vendor/libgit2/src/{iterator.h → libgit2/iterator.h} +8 -5
- data/vendor/libgit2/src/libgit2/libgit2.c +268 -0
- data/vendor/libgit2/src/{mailmap.c → libgit2/mailmap.c} +39 -37
- data/vendor/libgit2/src/{merge.c → libgit2/merge.c} +83 -73
- data/vendor/libgit2/src/{merge.h → libgit2/merge.h} +1 -14
- data/vendor/libgit2/src/{merge_driver.c → libgit2/merge_driver.c} +4 -4
- data/vendor/libgit2/src/{merge_file.c → libgit2/merge_file.c} +13 -5
- data/vendor/libgit2/src/{message.c → libgit2/message.c} +21 -10
- data/vendor/libgit2/src/{midx.c → libgit2/midx.c} +174 -112
- data/vendor/libgit2/src/{midx.h → libgit2/midx.h} +17 -6
- data/vendor/libgit2/src/{mwindow.c → libgit2/mwindow.c} +53 -57
- data/vendor/libgit2/src/{mwindow.h → libgit2/mwindow.h} +9 -2
- data/vendor/libgit2/src/{notes.c → libgit2/notes.c} +29 -37
- data/vendor/libgit2/src/{object.c → libgit2/object.c} +166 -35
- data/vendor/libgit2/src/{object.h → libgit2/object.h} +17 -2
- data/vendor/libgit2/src/{odb.c → libgit2/odb.c} +261 -88
- data/vendor/libgit2/src/{odb.h → libgit2/odb.h} +44 -5
- data/vendor/libgit2/src/{odb_loose.c → libgit2/odb_loose.c} +192 -134
- data/vendor/libgit2/src/{odb_mempack.c → libgit2/odb_mempack.c} +67 -22
- data/vendor/libgit2/src/{odb_pack.c → libgit2/odb_pack.c} +162 -89
- data/vendor/libgit2/src/{oid.c → libgit2/oid.c} +171 -92
- data/vendor/libgit2/src/libgit2/oid.h +284 -0
- data/vendor/libgit2/src/libgit2/oidarray.c +89 -0
- data/vendor/libgit2/src/{oidarray.h → libgit2/oidarray.h} +5 -1
- data/vendor/libgit2/src/{pack-objects.c → libgit2/pack-objects.c} +126 -66
- data/vendor/libgit2/src/{pack-objects.h → libgit2/pack-objects.h} +28 -12
- data/vendor/libgit2/src/{pack.c → libgit2/pack.c} +146 -111
- data/vendor/libgit2/src/{pack.h → libgit2/pack.h} +45 -25
- data/vendor/libgit2/src/{parse.c → libgit2/parse.c} +8 -4
- data/vendor/libgit2/src/{parse.h → libgit2/parse.h} +1 -1
- data/vendor/libgit2/src/{patch.c → libgit2/patch.c} +3 -3
- data/vendor/libgit2/src/{patch.h → libgit2/patch.h} +8 -1
- data/vendor/libgit2/src/{patch_generate.c → libgit2/patch_generate.c} +51 -16
- data/vendor/libgit2/src/{patch_generate.h → libgit2/patch_generate.h} +5 -5
- data/vendor/libgit2/src/{patch_parse.c → libgit2/patch_parse.c} +42 -34
- data/vendor/libgit2/src/libgit2/path.c +375 -0
- data/vendor/libgit2/src/libgit2/path.h +68 -0
- data/vendor/libgit2/src/{pathspec.c → libgit2/pathspec.c} +7 -7
- data/vendor/libgit2/src/{pathspec.h → libgit2/pathspec.h} +2 -2
- data/vendor/libgit2/src/{proxy.c → libgit2/proxy.c} +4 -1
- data/vendor/libgit2/src/{proxy.h → libgit2/proxy.h} +1 -1
- data/vendor/libgit2/src/{push.c → libgit2/push.c} +116 -60
- data/vendor/libgit2/src/{push.h → libgit2/push.h} +5 -16
- data/vendor/libgit2/src/{reader.c → libgit2/reader.c} +9 -9
- data/vendor/libgit2/src/{reader.h → libgit2/reader.h} +2 -2
- data/vendor/libgit2/src/{rebase.c → libgit2/rebase.c} +147 -147
- data/vendor/libgit2/src/{refdb_fs.c → libgit2/refdb_fs.c} +639 -254
- data/vendor/libgit2/src/{reflog.c → libgit2/reflog.c} +8 -7
- data/vendor/libgit2/src/{reflog.h → libgit2/reflog.h} +3 -2
- data/vendor/libgit2/src/{refs.c → libgit2/refs.c} +67 -39
- data/vendor/libgit2/src/{refs.h → libgit2/refs.h} +8 -3
- data/vendor/libgit2/src/{refspec.c → libgit2/refspec.c} +60 -38
- data/vendor/libgit2/src/{refspec.h → libgit2/refspec.h} +13 -2
- data/vendor/libgit2/src/{remote.c → libgit2/remote.c} +821 -454
- data/vendor/libgit2/src/libgit2/remote.h +101 -0
- data/vendor/libgit2/src/{repository.c → libgit2/repository.c} +1377 -594
- data/vendor/libgit2/src/{repository.h → libgit2/repository.h} +43 -12
- data/vendor/libgit2/src/{reset.c → libgit2/reset.c} +8 -5
- data/vendor/libgit2/src/{revert.c → libgit2/revert.c} +18 -22
- data/vendor/libgit2/src/{revparse.c → libgit2/revparse.c} +76 -44
- data/vendor/libgit2/src/{revwalk.c → libgit2/revwalk.c} +48 -19
- data/vendor/libgit2/src/{revwalk.h → libgit2/revwalk.h} +3 -3
- data/vendor/libgit2/src/{libgit2.c → libgit2/settings.c} +162 -95
- data/vendor/libgit2/src/{settings.h → libgit2/settings.h} +6 -2
- data/vendor/libgit2/src/{signature.c → libgit2/signature.c} +144 -21
- data/vendor/libgit2/src/{signature.h → libgit2/signature.h} +1 -2
- data/vendor/libgit2/src/{stash.c → libgit2/stash.c} +243 -68
- data/vendor/libgit2/src/{status.c → libgit2/status.c} +5 -2
- data/vendor/libgit2/src/{strarray.c → libgit2/strarray.c} +1 -0
- data/vendor/libgit2/src/libgit2/strarray.h +25 -0
- data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.c +62 -67
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.c +41 -24
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl.h +2 -0
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.c +11 -3
- data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_dynamic.h +6 -3
- data/vendor/libgit2/src/libgit2/streams/schannel.c +715 -0
- data/vendor/libgit2/src/libgit2/streams/schannel.h +28 -0
- data/vendor/libgit2/src/libgit2/streams/socket.c +428 -0
- data/vendor/libgit2/src/{streams → libgit2/streams}/socket.h +3 -1
- data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.c +79 -19
- data/vendor/libgit2/src/{streams → libgit2/streams}/tls.c +5 -0
- data/vendor/libgit2/src/{submodule.c → libgit2/submodule.c} +279 -220
- data/vendor/libgit2/src/{submodule.h → libgit2/submodule.h} +10 -11
- data/vendor/libgit2/src/libgit2/sysdir.c +650 -0
- data/vendor/libgit2/src/{sysdir.h → libgit2/sysdir.h} +55 -18
- data/vendor/libgit2/src/{tag.c → libgit2/tag.c} +74 -43
- data/vendor/libgit2/src/{tag.h → libgit2/tag.h} +2 -2
- data/vendor/libgit2/src/{trace.c → libgit2/trace.c} +1 -14
- data/vendor/libgit2/src/{trace.h → libgit2/trace.h} +5 -22
- data/vendor/libgit2/src/{trailer.c → libgit2/trailer.c} +7 -7
- data/vendor/libgit2/src/{transaction.c → libgit2/transaction.c} +27 -21
- data/vendor/libgit2/src/{transaction.h → libgit2/transaction.h} +4 -1
- data/vendor/libgit2/src/{transport.c → libgit2/transport.c} +14 -11
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth.c +7 -9
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth.h +3 -5
- data/vendor/libgit2/src/{transports/auth_negotiate.c → libgit2/transports/auth_gssapi.c} +44 -45
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_negotiate.h +1 -1
- data/vendor/libgit2/src/{transports → libgit2/transports}/auth_ntlm.h +1 -2
- data/vendor/libgit2/src/{transports/auth_ntlm.c → libgit2/transports/auth_ntlmclient.c} +22 -22
- data/vendor/libgit2/src/libgit2/transports/auth_sspi.c +341 -0
- data/vendor/libgit2/src/{transports → libgit2/transports}/credential.c +1 -1
- data/vendor/libgit2/src/{transports → libgit2/transports}/git.c +16 -19
- data/vendor/libgit2/src/{transports → libgit2/transports}/http.c +49 -24
- data/vendor/libgit2/src/{transports → libgit2/transports}/http.h +0 -11
- data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.c +188 -134
- data/vendor/libgit2/src/{transports → libgit2/transports}/httpclient.h +10 -0
- data/vendor/libgit2/src/libgit2/transports/httpparser.c +128 -0
- data/vendor/libgit2/src/libgit2/transports/httpparser.h +99 -0
- data/vendor/libgit2/src/{transports → libgit2/transports}/local.c +159 -127
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart.c +142 -165
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart.h +56 -36
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart_pkt.c +307 -74
- data/vendor/libgit2/src/{transports → libgit2/transports}/smart_protocol.c +297 -97
- data/vendor/libgit2/src/libgit2/transports/ssh.c +85 -0
- data/vendor/libgit2/src/libgit2/transports/ssh_exec.c +347 -0
- data/vendor/libgit2/src/libgit2/transports/ssh_exec.h +26 -0
- data/vendor/libgit2/src/{transports/ssh.c → libgit2/transports/ssh_libssh2.c} +414 -268
- data/vendor/libgit2/src/libgit2/transports/ssh_libssh2.h +28 -0
- data/vendor/libgit2/src/{transports → libgit2/transports}/winhttp.c +101 -75
- data/vendor/libgit2/src/{tree-cache.c → libgit2/tree-cache.c} +30 -20
- data/vendor/libgit2/src/{tree-cache.h → libgit2/tree-cache.h} +7 -5
- data/vendor/libgit2/src/{tree.c → libgit2/tree.c} +128 -110
- data/vendor/libgit2/src/{tree.h → libgit2/tree.h} +7 -6
- data/vendor/libgit2/src/{worktree.c → libgit2/worktree.c} +160 -121
- data/vendor/libgit2/src/{worktree.h → libgit2/worktree.h} +1 -1
- data/vendor/libgit2/src/util/CMakeLists.txt +77 -0
- data/vendor/libgit2/src/{alloc.c → util/alloc.c} +69 -7
- data/vendor/libgit2/src/util/alloc.h +65 -0
- data/vendor/libgit2/src/util/allocators/debugalloc.c +73 -0
- data/vendor/libgit2/src/util/allocators/debugalloc.h +17 -0
- data/vendor/libgit2/src/util/allocators/failalloc.c +32 -0
- data/vendor/libgit2/src/util/allocators/failalloc.h +17 -0
- data/vendor/libgit2/src/util/allocators/stdalloc.c +37 -0
- data/vendor/libgit2/src/{allocators → util/allocators}/stdalloc.h +1 -1
- data/vendor/libgit2/src/util/allocators/win32_leakcheck.c +50 -0
- data/vendor/libgit2/src/{allocators → util/allocators}/win32_leakcheck.h +1 -1
- data/vendor/libgit2/src/{array.h → util/array.h} +25 -19
- data/vendor/libgit2/src/{assert_safe.h → util/assert_safe.h} +16 -0
- data/vendor/libgit2/src/{cc-compat.h → util/cc-compat.h} +5 -1
- data/vendor/libgit2/src/util/ctype_compat.h +70 -0
- data/vendor/libgit2/src/{date.c → util/date.c} +35 -33
- data/vendor/libgit2/src/util/date.h +45 -0
- data/vendor/libgit2/src/util/errors.c +401 -0
- data/vendor/libgit2/src/{errors.h → util/errors.h} +22 -19
- data/vendor/libgit2/src/{filebuf.c → util/filebuf.c} +35 -30
- data/vendor/libgit2/src/{filebuf.h → util/filebuf.h} +21 -8
- data/vendor/libgit2/src/{path.c → util/fs_path.c} +591 -615
- data/vendor/libgit2/src/{path.h → util/fs_path.h} +257 -181
- data/vendor/libgit2/src/{futils.c → util/futils.c} +144 -95
- data/vendor/libgit2/src/{futils.h → util/futils.h} +40 -18
- data/vendor/libgit2/src/{features.h.in → util/git2_features.h.in} +33 -2
- data/vendor/libgit2/src/{common.h → util/git2_util.h} +26 -59
- data/vendor/libgit2/src/util/hash/builtin.c +53 -0
- data/vendor/libgit2/src/{hash/sha1/openssl.h → util/hash/builtin.h} +6 -6
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.c +3 -3
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/collisiondetect.h +3 -3
- data/vendor/libgit2/src/util/hash/common_crypto.c +112 -0
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/common_crypto.h +11 -3
- data/vendor/libgit2/src/util/hash/mbedtls.c +92 -0
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/mbedtls.h +14 -4
- data/vendor/libgit2/src/util/hash/openssl.c +347 -0
- data/vendor/libgit2/src/util/hash/openssl.h +61 -0
- data/vendor/libgit2/src/util/hash/rfc6234/sha.h +243 -0
- data/vendor/libgit2/src/util/hash/rfc6234/sha224-256.c +601 -0
- data/vendor/libgit2/src/util/hash/sha.h +73 -0
- data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.c +1 -1
- data/vendor/libgit2/src/util/hash/win32.c +549 -0
- data/vendor/libgit2/src/util/hash/win32.h +60 -0
- data/vendor/libgit2/src/util/hash.c +158 -0
- data/vendor/libgit2/src/util/hash.h +61 -0
- data/vendor/libgit2/src/util/hashmap.h +424 -0
- data/vendor/libgit2/src/util/hashmap_str.h +43 -0
- data/vendor/libgit2/src/{integer.h → util/integer.h} +3 -1
- data/vendor/libgit2/src/{map.h → util/map.h} +1 -1
- data/vendor/libgit2/src/util/net.c +1160 -0
- data/vendor/libgit2/src/{net.h → util/net.h} +45 -4
- data/vendor/libgit2/src/{pool.c → util/pool.c} +1 -1
- data/vendor/libgit2/src/{pool.h → util/pool.h} +6 -1
- data/vendor/libgit2/src/{posix.c → util/posix.c} +57 -3
- data/vendor/libgit2/src/{posix.h → util/posix.h} +26 -1
- data/vendor/libgit2/src/{pqueue.h → util/pqueue.h} +3 -3
- data/vendor/libgit2/src/util/process.h +222 -0
- data/vendor/libgit2/src/util/rand.c +230 -0
- data/vendor/libgit2/src/util/rand.h +37 -0
- data/vendor/libgit2/src/{regexp.c → util/regexp.c} +5 -5
- data/vendor/libgit2/src/{regexp.h → util/regexp.h} +1 -1
- data/vendor/libgit2/src/{runtime.c → util/runtime.c} +1 -1
- data/vendor/libgit2/src/{runtime.h → util/runtime.h} +1 -1
- data/vendor/libgit2/src/{sortedcache.c → util/sortedcache.c} +15 -14
- data/vendor/libgit2/src/{sortedcache.h → util/sortedcache.h} +5 -5
- data/vendor/libgit2/src/util/staticstr.h +66 -0
- data/vendor/libgit2/src/{buffer.c → util/str.c} +159 -153
- data/vendor/libgit2/src/util/str.h +357 -0
- data/vendor/libgit2/src/util/strlist.c +108 -0
- data/vendor/libgit2/src/util/strlist.h +36 -0
- data/vendor/libgit2/src/{thread.c → util/thread.c} +1 -1
- data/vendor/libgit2/src/{thread.h → util/thread.h} +23 -22
- data/vendor/libgit2/src/{tsort.c → util/tsort.c} +1 -1
- data/vendor/libgit2/src/{unix → util/unix}/map.c +1 -3
- data/vendor/libgit2/src/{unix → util/unix}/posix.h +1 -6
- data/vendor/libgit2/src/util/unix/process.c +629 -0
- data/vendor/libgit2/src/{unix → util/unix}/realpath.c +24 -8
- data/vendor/libgit2/src/{utf8.c → util/utf8.c} +1 -1
- data/vendor/libgit2/src/{utf8.h → util/utf8.h} +1 -1
- data/vendor/libgit2/src/{util.c → util/util.c} +24 -19
- data/vendor/libgit2/src/{util.h → util/util.h} +30 -81
- data/vendor/libgit2/src/{varint.h → util/varint.h} +1 -1
- data/vendor/libgit2/src/{vector.c → util/vector.c} +3 -3
- data/vendor/libgit2/src/{vector.h → util/vector.h} +4 -4
- data/vendor/libgit2/src/{wildmatch.h → util/wildmatch.h} +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/dir.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/error.c +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/error.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/map.c +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/path_w32.c +148 -17
- data/vendor/libgit2/src/{win32 → util/win32}/path_w32.h +3 -1
- data/vendor/libgit2/src/{win32 → util/win32}/posix.h +1 -2
- data/vendor/libgit2/src/{win32 → util/win32}/posix_w32.c +42 -35
- data/vendor/libgit2/src/util/win32/precompiled.c +1 -0
- data/vendor/libgit2/src/{win32 → util/win32}/precompiled.h +1 -1
- data/vendor/libgit2/src/util/win32/process.c +506 -0
- data/vendor/libgit2/src/{win32 → util/win32}/thread.h +1 -1
- data/vendor/libgit2/src/util/win32/utf-conv.c +144 -0
- data/vendor/libgit2/src/util/win32/utf-conv.h +127 -0
- data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.c +2 -3
- data/vendor/libgit2/src/{win32 → util/win32}/w32_buffer.h +3 -4
- data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.c +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/w32_leakcheck.h +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/w32_util.c +1 -1
- data/vendor/libgit2/src/{win32 → util/win32}/w32_util.h +1 -1
- data/vendor/libgit2/src/{zstream.c → util/zstream.c} +5 -5
- data/vendor/libgit2/src/{zstream.h → util/zstream.h} +5 -5
- metadata +431 -362
- data/vendor/libgit2/cmake/FindIconv.cmake +0 -45
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -6
- data/vendor/libgit2/deps/http-parser/COPYING +0 -23
- data/vendor/libgit2/deps/http-parser/http_parser.c +0 -2182
- data/vendor/libgit2/deps/http-parser/http_parser.h +0 -305
- data/vendor/libgit2/deps/zlib/COPYING +0 -27
- data/vendor/libgit2/include/git2/sys/reflog.h +0 -21
- data/vendor/libgit2/src/alloc.h +0 -40
- data/vendor/libgit2/src/allocators/failalloc.c +0 -92
- data/vendor/libgit2/src/allocators/failalloc.h +0 -23
- data/vendor/libgit2/src/allocators/stdalloc.c +0 -150
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +0 -118
- data/vendor/libgit2/src/buffer.h +0 -374
- data/vendor/libgit2/src/commit.h +0 -46
- data/vendor/libgit2/src/config_entries.c +0 -237
- data/vendor/libgit2/src/config_entries.h +0 -24
- data/vendor/libgit2/src/config_mem.c +0 -220
- data/vendor/libgit2/src/errors.c +0 -238
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +0 -57
- data/vendor/libgit2/src/hash/sha1/generic.c +0 -300
- data/vendor/libgit2/src/hash/sha1/generic.h +0 -19
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +0 -46
- data/vendor/libgit2/src/hash/sha1/openssl.c +0 -59
- data/vendor/libgit2/src/hash/sha1/win32.c +0 -333
- data/vendor/libgit2/src/hash/sha1/win32.h +0 -128
- data/vendor/libgit2/src/hash/sha1.h +0 -38
- data/vendor/libgit2/src/hash.c +0 -110
- data/vendor/libgit2/src/hash.h +0 -46
- data/vendor/libgit2/src/idxmap.c +0 -157
- data/vendor/libgit2/src/idxmap.h +0 -177
- data/vendor/libgit2/src/khash.h +0 -615
- data/vendor/libgit2/src/libgit2.h +0 -15
- data/vendor/libgit2/src/message.h +0 -17
- data/vendor/libgit2/src/net.c +0 -540
- data/vendor/libgit2/src/netops.c +0 -125
- data/vendor/libgit2/src/netops.h +0 -68
- data/vendor/libgit2/src/offmap.c +0 -101
- data/vendor/libgit2/src/offmap.h +0 -133
- data/vendor/libgit2/src/oid.h +0 -51
- data/vendor/libgit2/src/oidarray.c +0 -43
- data/vendor/libgit2/src/oidmap.c +0 -107
- data/vendor/libgit2/src/oidmap.h +0 -128
- data/vendor/libgit2/src/remote.h +0 -55
- data/vendor/libgit2/src/streams/socket.c +0 -239
- data/vendor/libgit2/src/strmap.c +0 -100
- data/vendor/libgit2/src/strmap.h +0 -131
- data/vendor/libgit2/src/sysdir.c +0 -347
- data/vendor/libgit2/src/threadstate.c +0 -84
- data/vendor/libgit2/src/threadstate.h +0 -24
- data/vendor/libgit2/src/win32/findfile.c +0 -230
- data/vendor/libgit2/src/win32/findfile.h +0 -19
- data/vendor/libgit2/src/win32/utf-conv.c +0 -146
- data/vendor/libgit2/src/win32/utf-conv.h +0 -60
- /data/vendor/libgit2/{src → deps}/xdiff/xemit.h +0 -0
- /data/vendor/libgit2/{src → deps}/xdiff/xprepare.h +0 -0
- /data/vendor/libgit2/{src → deps}/xdiff/xtypes.h +0 -0
- /data/vendor/libgit2/src/{win32 → cli/win32}/precompiled.c +0 -0
- /data/vendor/libgit2/src/{attr.h → libgit2/attr.h} +0 -0
- /data/vendor/libgit2/src/{blame_git.h → libgit2/blame_git.h} +0 -0
- /data/vendor/libgit2/src/{config_parse.h → libgit2/config_parse.h} +0 -0
- /data/vendor/libgit2/src/{delta.c → libgit2/delta.c} +0 -0
- /data/vendor/libgit2/src/{delta.h → libgit2/delta.h} +0 -0
- /data/vendor/libgit2/src/{diff_file.h → libgit2/diff_file.h} +0 -0
- /data/vendor/libgit2/src/{diff_parse.h → libgit2/diff_parse.h} +0 -0
- /data/vendor/libgit2/src/{diff_tform.h → libgit2/diff_tform.h} +0 -0
- /data/vendor/libgit2/src/{fetchhead.h → libgit2/fetchhead.h} +0 -0
- /data/vendor/libgit2/src/{hashsig.c → libgit2/hashsig.c} +0 -0
- /data/vendor/libgit2/src/{indexer.h → libgit2/indexer.h} +0 -0
- /data/vendor/libgit2/src/{mailmap.h → libgit2/mailmap.h} +0 -0
- /data/vendor/libgit2/src/{merge_driver.h → libgit2/merge_driver.h} +0 -0
- /data/vendor/libgit2/src/{notes.h → libgit2/notes.h} +0 -0
- /data/vendor/libgit2/src/{object_api.c → libgit2/object_api.c} +0 -0
- /data/vendor/libgit2/src/{patch_parse.h → libgit2/patch_parse.h} +0 -0
- /data/vendor/libgit2/src/{refdb.c → libgit2/refdb.c} +0 -0
- /data/vendor/libgit2/src/{refdb.h → libgit2/refdb.h} +0 -0
- /data/vendor/libgit2/src/{repo_template.h → libgit2/repo_template.h} +0 -0
- /data/vendor/libgit2/src/{status.h → libgit2/status.h} +0 -0
- /data/vendor/libgit2/src/{stream.h → libgit2/stream.h} +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/mbedtls.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/openssl_legacy.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.c +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/registry.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/stransport.h +0 -0
- /data/vendor/libgit2/src/{streams → libgit2/streams}/tls.h +0 -0
- /data/vendor/libgit2/src/{transports → libgit2/transports}/credential_helpers.c +0 -0
- /data/vendor/libgit2/src/{userdiff.h → libgit2/userdiff.h} +0 -0
- /data/vendor/libgit2/src/{bitvec.h → util/bitvec.h} +0 -0
- /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/sha1.h +0 -0
- /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.c +0 -0
- /data/vendor/libgit2/src/{hash/sha1 → util/hash}/sha1dc/ubc_check.h +0 -0
- /data/vendor/libgit2/src/{pqueue.c → util/pqueue.c} +0 -0
- /data/vendor/libgit2/src/{strnlen.h → util/strnlen.h} +0 -0
- /data/vendor/libgit2/src/{unix → util/unix}/pthread.h +0 -0
- /data/vendor/libgit2/src/{varint.c → util/varint.c} +0 -0
- /data/vendor/libgit2/src/{wildmatch.c → util/wildmatch.c} +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/dir.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/mingw-compat.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/msvc-compat.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/reparse.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/thread.c +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/version.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/w32_common.h +0 -0
- /data/vendor/libgit2/src/{win32 → util/win32}/win32-compat.h +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
/* deflate.c -- compress data using the deflation algorithm
|
2
|
-
* Copyright (C) 1995-
|
2
|
+
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
3
3
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
4
|
*/
|
5
5
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
#include "deflate.h"
|
53
53
|
|
54
54
|
const char deflate_copyright[] =
|
55
|
-
" deflate 1.
|
55
|
+
" deflate 1.3.1 Copyright 1995-2024 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
|
@@ -60,9 +60,6 @@ const char deflate_copyright[] =
|
|
60
60
|
copyright string in the executable of your product.
|
61
61
|
*/
|
62
62
|
|
63
|
-
/* ===========================================================================
|
64
|
-
* Function prototypes.
|
65
|
-
*/
|
66
63
|
typedef enum {
|
67
64
|
need_more, /* block not completed, need more input or more output */
|
68
65
|
block_done, /* block flush performed */
|
@@ -70,35 +67,16 @@ typedef enum {
|
|
70
67
|
finish_done /* finish done, accept no more input or output */
|
71
68
|
} block_state;
|
72
69
|
|
73
|
-
typedef block_state (*compress_func)
|
70
|
+
typedef block_state (*compress_func)(deflate_state *s, int flush);
|
74
71
|
/* Compression function. Returns the block state after the call. */
|
75
72
|
|
76
|
-
local
|
77
|
-
local
|
78
|
-
local void fill_window OF((deflate_state *s));
|
79
|
-
local block_state deflate_stored OF((deflate_state *s, int flush));
|
80
|
-
local block_state deflate_fast OF((deflate_state *s, int flush));
|
73
|
+
local block_state deflate_stored(deflate_state *s, int flush);
|
74
|
+
local block_state deflate_fast(deflate_state *s, int flush);
|
81
75
|
#ifndef FASTEST
|
82
|
-
local block_state deflate_slow
|
83
|
-
#endif
|
84
|
-
local block_state deflate_rle OF((deflate_state *s, int flush));
|
85
|
-
local block_state deflate_huff OF((deflate_state *s, int flush));
|
86
|
-
local void lm_init OF((deflate_state *s));
|
87
|
-
local void putShortMSB OF((deflate_state *s, uInt b));
|
88
|
-
local void flush_pending OF((z_streamp strm));
|
89
|
-
local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
90
|
-
#ifdef ASMV
|
91
|
-
# pragma message("Assembler code may have bugs -- use at your own risk")
|
92
|
-
void match_init OF((void)); /* asm code initialization */
|
93
|
-
uInt longest_match OF((deflate_state *s, IPos cur_match));
|
94
|
-
#else
|
95
|
-
local uInt longest_match OF((deflate_state *s, IPos cur_match));
|
96
|
-
#endif
|
97
|
-
|
98
|
-
#ifdef ZLIB_DEBUG
|
99
|
-
local void check_match OF((deflate_state *s, IPos start, IPos match,
|
100
|
-
int length));
|
76
|
+
local block_state deflate_slow(deflate_state *s, int flush);
|
101
77
|
#endif
|
78
|
+
local block_state deflate_rle(deflate_state *s, int flush);
|
79
|
+
local block_state deflate_huff(deflate_state *s, int flush);
|
102
80
|
|
103
81
|
/* ===========================================================================
|
104
82
|
* Local data
|
@@ -160,7 +138,7 @@ local const config configuration_table[10] = {
|
|
160
138
|
* characters, so that a running hash key can be computed from the previous
|
161
139
|
* key instead of complete recalculation each time.
|
162
140
|
*/
|
163
|
-
#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
|
141
|
+
#define UPDATE_HASH(s,h,c) (h = (((h) << s->hash_shift) ^ (c)) & s->hash_mask)
|
164
142
|
|
165
143
|
|
166
144
|
/* ===========================================================================
|
@@ -190,17 +168,23 @@ local const config configuration_table[10] = {
|
|
190
168
|
* prev[] will be initialized on the fly.
|
191
169
|
*/
|
192
170
|
#define CLEAR_HASH(s) \
|
193
|
-
|
194
|
-
|
171
|
+
do { \
|
172
|
+
s->head[s->hash_size - 1] = NIL; \
|
173
|
+
zmemzero((Bytef *)s->head, \
|
174
|
+
(unsigned)(s->hash_size - 1)*sizeof(*s->head)); \
|
175
|
+
} while (0)
|
195
176
|
|
196
177
|
/* ===========================================================================
|
197
178
|
* Slide the hash table when sliding the window down (could be avoided with 32
|
198
179
|
* bit values at the expense of memory usage). We slide even when level == 0 to
|
199
180
|
* keep the hash table consistent if we switch back to level > 0 later.
|
200
181
|
*/
|
201
|
-
|
202
|
-
|
203
|
-
|
182
|
+
#if defined(__has_feature)
|
183
|
+
# if __has_feature(memory_sanitizer)
|
184
|
+
__attribute__((no_sanitize("memory")))
|
185
|
+
# endif
|
186
|
+
#endif
|
187
|
+
local void slide_hash(deflate_state *s) {
|
204
188
|
unsigned n, m;
|
205
189
|
Posf *p;
|
206
190
|
uInt wsize = s->w_size;
|
@@ -224,39 +208,181 @@ local void slide_hash(s)
|
|
224
208
|
#endif
|
225
209
|
}
|
226
210
|
|
211
|
+
/* ===========================================================================
|
212
|
+
* Read a new buffer from the current input stream, update the adler32
|
213
|
+
* and total number of bytes read. All deflate() input goes through
|
214
|
+
* this function so some applications may wish to modify it to avoid
|
215
|
+
* allocating a large strm->next_in buffer and copying from it.
|
216
|
+
* (See also flush_pending()).
|
217
|
+
*/
|
218
|
+
local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) {
|
219
|
+
unsigned len = strm->avail_in;
|
220
|
+
|
221
|
+
if (len > size) len = size;
|
222
|
+
if (len == 0) return 0;
|
223
|
+
|
224
|
+
strm->avail_in -= len;
|
225
|
+
|
226
|
+
zmemcpy(buf, strm->next_in, len);
|
227
|
+
if (strm->state->wrap == 1) {
|
228
|
+
strm->adler = adler32(strm->adler, buf, len);
|
229
|
+
}
|
230
|
+
#ifdef GZIP
|
231
|
+
else if (strm->state->wrap == 2) {
|
232
|
+
strm->adler = crc32(strm->adler, buf, len);
|
233
|
+
}
|
234
|
+
#endif
|
235
|
+
strm->next_in += len;
|
236
|
+
strm->total_in += len;
|
237
|
+
|
238
|
+
return len;
|
239
|
+
}
|
240
|
+
|
241
|
+
/* ===========================================================================
|
242
|
+
* Fill the window when the lookahead becomes insufficient.
|
243
|
+
* Updates strstart and lookahead.
|
244
|
+
*
|
245
|
+
* IN assertion: lookahead < MIN_LOOKAHEAD
|
246
|
+
* OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
|
247
|
+
* At least one byte has been read, or avail_in == 0; reads are
|
248
|
+
* performed for at least two bytes (required for the zip translate_eol
|
249
|
+
* option -- not supported here).
|
250
|
+
*/
|
251
|
+
local void fill_window(deflate_state *s) {
|
252
|
+
unsigned n;
|
253
|
+
unsigned more; /* Amount of free space at the end of the window. */
|
254
|
+
uInt wsize = s->w_size;
|
255
|
+
|
256
|
+
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
|
257
|
+
|
258
|
+
do {
|
259
|
+
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
|
260
|
+
|
261
|
+
/* Deal with !@#$% 64K limit: */
|
262
|
+
if (sizeof(int) <= 2) {
|
263
|
+
if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
|
264
|
+
more = wsize;
|
265
|
+
|
266
|
+
} else if (more == (unsigned)(-1)) {
|
267
|
+
/* Very unlikely, but possible on 16 bit machine if
|
268
|
+
* strstart == 0 && lookahead == 1 (input done a byte at time)
|
269
|
+
*/
|
270
|
+
more--;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
|
274
|
+
/* If the window is almost full and there is insufficient lookahead,
|
275
|
+
* move the upper half to the lower one to make room in the upper half.
|
276
|
+
*/
|
277
|
+
if (s->strstart >= wsize + MAX_DIST(s)) {
|
278
|
+
|
279
|
+
zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more);
|
280
|
+
s->match_start -= wsize;
|
281
|
+
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
|
282
|
+
s->block_start -= (long) wsize;
|
283
|
+
if (s->insert > s->strstart)
|
284
|
+
s->insert = s->strstart;
|
285
|
+
slide_hash(s);
|
286
|
+
more += wsize;
|
287
|
+
}
|
288
|
+
if (s->strm->avail_in == 0) break;
|
289
|
+
|
290
|
+
/* If there was no sliding:
|
291
|
+
* strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
|
292
|
+
* more == window_size - lookahead - strstart
|
293
|
+
* => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
|
294
|
+
* => more >= window_size - 2*WSIZE + 2
|
295
|
+
* In the BIG_MEM or MMAP case (not yet supported),
|
296
|
+
* window_size == input_size + MIN_LOOKAHEAD &&
|
297
|
+
* strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
|
298
|
+
* Otherwise, window_size == 2*WSIZE so more >= 2.
|
299
|
+
* If there was sliding, more >= WSIZE. So in all cases, more >= 2.
|
300
|
+
*/
|
301
|
+
Assert(more >= 2, "more < 2");
|
302
|
+
|
303
|
+
n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
|
304
|
+
s->lookahead += n;
|
305
|
+
|
306
|
+
/* Initialize the hash value now that we have some input: */
|
307
|
+
if (s->lookahead + s->insert >= MIN_MATCH) {
|
308
|
+
uInt str = s->strstart - s->insert;
|
309
|
+
s->ins_h = s->window[str];
|
310
|
+
UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
|
311
|
+
#if MIN_MATCH != 3
|
312
|
+
Call UPDATE_HASH() MIN_MATCH-3 more times
|
313
|
+
#endif
|
314
|
+
while (s->insert) {
|
315
|
+
UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
|
316
|
+
#ifndef FASTEST
|
317
|
+
s->prev[str & s->w_mask] = s->head[s->ins_h];
|
318
|
+
#endif
|
319
|
+
s->head[s->ins_h] = (Pos)str;
|
320
|
+
str++;
|
321
|
+
s->insert--;
|
322
|
+
if (s->lookahead + s->insert < MIN_MATCH)
|
323
|
+
break;
|
324
|
+
}
|
325
|
+
}
|
326
|
+
/* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
|
327
|
+
* but this is not important since only literal bytes will be emitted.
|
328
|
+
*/
|
329
|
+
|
330
|
+
} while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
|
331
|
+
|
332
|
+
/* If the WIN_INIT bytes after the end of the current data have never been
|
333
|
+
* written, then zero those bytes in order to avoid memory check reports of
|
334
|
+
* the use of uninitialized (or uninitialised as Julian writes) bytes by
|
335
|
+
* the longest match routines. Update the high water mark for the next
|
336
|
+
* time through here. WIN_INIT is set to MAX_MATCH since the longest match
|
337
|
+
* routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
|
338
|
+
*/
|
339
|
+
if (s->high_water < s->window_size) {
|
340
|
+
ulg curr = s->strstart + (ulg)(s->lookahead);
|
341
|
+
ulg init;
|
342
|
+
|
343
|
+
if (s->high_water < curr) {
|
344
|
+
/* Previous high water mark below current data -- zero WIN_INIT
|
345
|
+
* bytes or up to end of window, whichever is less.
|
346
|
+
*/
|
347
|
+
init = s->window_size - curr;
|
348
|
+
if (init > WIN_INIT)
|
349
|
+
init = WIN_INIT;
|
350
|
+
zmemzero(s->window + curr, (unsigned)init);
|
351
|
+
s->high_water = curr + init;
|
352
|
+
}
|
353
|
+
else if (s->high_water < (ulg)curr + WIN_INIT) {
|
354
|
+
/* High water mark at or above current data, but below current data
|
355
|
+
* plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
|
356
|
+
* to end of window, whichever is less.
|
357
|
+
*/
|
358
|
+
init = (ulg)curr + WIN_INIT - s->high_water;
|
359
|
+
if (init > s->window_size - s->high_water)
|
360
|
+
init = s->window_size - s->high_water;
|
361
|
+
zmemzero(s->window + s->high_water, (unsigned)init);
|
362
|
+
s->high_water += init;
|
363
|
+
}
|
364
|
+
}
|
365
|
+
|
366
|
+
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
367
|
+
"not enough room for search");
|
368
|
+
}
|
369
|
+
|
227
370
|
/* ========================================================================= */
|
228
|
-
int ZEXPORT deflateInit_(strm, level, version,
|
229
|
-
|
230
|
-
int level;
|
231
|
-
const char *version;
|
232
|
-
int stream_size;
|
233
|
-
{
|
371
|
+
int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version,
|
372
|
+
int stream_size) {
|
234
373
|
return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
|
235
374
|
Z_DEFAULT_STRATEGY, version, stream_size);
|
236
375
|
/* To do: ignore strm->next_in if we use it as window */
|
237
376
|
}
|
238
377
|
|
239
378
|
/* ========================================================================= */
|
240
|
-
int ZEXPORT deflateInit2_(strm, level, method,
|
241
|
-
|
242
|
-
|
243
|
-
int level;
|
244
|
-
int method;
|
245
|
-
int windowBits;
|
246
|
-
int memLevel;
|
247
|
-
int strategy;
|
248
|
-
const char *version;
|
249
|
-
int stream_size;
|
250
|
-
{
|
379
|
+
int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
|
380
|
+
int windowBits, int memLevel, int strategy,
|
381
|
+
const char *version, int stream_size) {
|
251
382
|
deflate_state *s;
|
252
383
|
int wrap = 1;
|
253
384
|
static const char my_version[] = ZLIB_VERSION;
|
254
385
|
|
255
|
-
ushf *overlay;
|
256
|
-
/* We overlay pending_buf and d_buf+l_buf. This works since the average
|
257
|
-
* output size for (length,distance) codes is <= 24 bits.
|
258
|
-
*/
|
259
|
-
|
260
386
|
if (version == Z_NULL || version[0] != my_version[0] ||
|
261
387
|
stream_size != sizeof(z_stream)) {
|
262
388
|
return Z_VERSION_ERROR;
|
@@ -287,6 +413,8 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|
287
413
|
|
288
414
|
if (windowBits < 0) { /* suppress zlib wrapper */
|
289
415
|
wrap = 0;
|
416
|
+
if (windowBits < -15)
|
417
|
+
return Z_STREAM_ERROR;
|
290
418
|
windowBits = -windowBits;
|
291
419
|
}
|
292
420
|
#ifdef GZIP
|
@@ -316,20 +444,57 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|
316
444
|
s->hash_bits = (uInt)memLevel + 7;
|
317
445
|
s->hash_size = 1 << s->hash_bits;
|
318
446
|
s->hash_mask = s->hash_size - 1;
|
319
|
-
s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
|
447
|
+
s->hash_shift = ((s->hash_bits + MIN_MATCH-1) / MIN_MATCH);
|
320
448
|
|
321
449
|
s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
|
322
450
|
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
|
323
|
-
memset(s->prev, 0, s->w_size * sizeof(Pos));
|
324
451
|
s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
|
325
452
|
|
326
453
|
s->high_water = 0; /* nothing written to s->window yet */
|
327
454
|
|
328
455
|
s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
|
329
456
|
|
330
|
-
overlay
|
331
|
-
|
332
|
-
|
457
|
+
/* We overlay pending_buf and sym_buf. This works since the average size
|
458
|
+
* for length/distance pairs over any compressed block is assured to be 31
|
459
|
+
* bits or less.
|
460
|
+
*
|
461
|
+
* Analysis: The longest fixed codes are a length code of 8 bits plus 5
|
462
|
+
* extra bits, for lengths 131 to 257. The longest fixed distance codes are
|
463
|
+
* 5 bits plus 13 extra bits, for distances 16385 to 32768. The longest
|
464
|
+
* possible fixed-codes length/distance pair is then 31 bits total.
|
465
|
+
*
|
466
|
+
* sym_buf starts one-fourth of the way into pending_buf. So there are
|
467
|
+
* three bytes in sym_buf for every four bytes in pending_buf. Each symbol
|
468
|
+
* in sym_buf is three bytes -- two for the distance and one for the
|
469
|
+
* literal/length. As each symbol is consumed, the pointer to the next
|
470
|
+
* sym_buf value to read moves forward three bytes. From that symbol, up to
|
471
|
+
* 31 bits are written to pending_buf. The closest the written pending_buf
|
472
|
+
* bits gets to the next sym_buf symbol to read is just before the last
|
473
|
+
* code is written. At that time, 31*(n - 2) bits have been written, just
|
474
|
+
* after 24*(n - 2) bits have been consumed from sym_buf. sym_buf starts at
|
475
|
+
* 8*n bits into pending_buf. (Note that the symbol buffer fills when n - 1
|
476
|
+
* symbols are written.) The closest the writing gets to what is unread is
|
477
|
+
* then n + 14 bits. Here n is lit_bufsize, which is 16384 by default, and
|
478
|
+
* can range from 128 to 32768.
|
479
|
+
*
|
480
|
+
* Therefore, at a minimum, there are 142 bits of space between what is
|
481
|
+
* written and what is read in the overlain buffers, so the symbols cannot
|
482
|
+
* be overwritten by the compressed data. That space is actually 139 bits,
|
483
|
+
* due to the three-bit fixed-code block header.
|
484
|
+
*
|
485
|
+
* That covers the case where either Z_FIXED is specified, forcing fixed
|
486
|
+
* codes, or when the use of fixed codes is chosen, because that choice
|
487
|
+
* results in a smaller compressed block than dynamic codes. That latter
|
488
|
+
* condition then assures that the above analysis also covers all dynamic
|
489
|
+
* blocks. A dynamic-code block will only be chosen to be emitted if it has
|
490
|
+
* fewer bits than a fixed-code block would for the same set of symbols.
|
491
|
+
* Therefore its average symbol length is assured to be less than 31. So
|
492
|
+
* the compressed data for a dynamic block also cannot overwrite the
|
493
|
+
* symbols from which it is being constructed.
|
494
|
+
*/
|
495
|
+
|
496
|
+
s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS);
|
497
|
+
s->pending_buf_size = (ulg)s->lit_bufsize * 4;
|
333
498
|
|
334
499
|
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
|
335
500
|
s->pending_buf == Z_NULL) {
|
@@ -338,8 +503,18 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|
338
503
|
deflateEnd (strm);
|
339
504
|
return Z_MEM_ERROR;
|
340
505
|
}
|
341
|
-
|
342
|
-
s->
|
506
|
+
#ifdef LIT_MEM
|
507
|
+
s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1));
|
508
|
+
s->l_buf = s->pending_buf + (s->lit_bufsize << 2);
|
509
|
+
s->sym_end = s->lit_bufsize - 1;
|
510
|
+
#else
|
511
|
+
s->sym_buf = s->pending_buf + s->lit_bufsize;
|
512
|
+
s->sym_end = (s->lit_bufsize - 1) * 3;
|
513
|
+
#endif
|
514
|
+
/* We avoid equality with lit_bufsize*3 because of wraparound at 64K
|
515
|
+
* on 16 bit machines and because stored blocks are restricted to
|
516
|
+
* 64K-1 bytes.
|
517
|
+
*/
|
343
518
|
|
344
519
|
s->level = level;
|
345
520
|
s->strategy = strategy;
|
@@ -351,9 +526,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
|
351
526
|
/* =========================================================================
|
352
527
|
* Check for a valid deflate stream state. Return 0 if ok, 1 if not.
|
353
528
|
*/
|
354
|
-
local int deflateStateCheck
|
355
|
-
z_streamp strm;
|
356
|
-
{
|
529
|
+
local int deflateStateCheck(z_streamp strm) {
|
357
530
|
deflate_state *s;
|
358
531
|
if (strm == Z_NULL ||
|
359
532
|
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
|
@@ -374,11 +547,8 @@ local int deflateStateCheck (strm)
|
|
374
547
|
}
|
375
548
|
|
376
549
|
/* ========================================================================= */
|
377
|
-
int ZEXPORT deflateSetDictionary
|
378
|
-
|
379
|
-
const Bytef *dictionary;
|
380
|
-
uInt dictLength;
|
381
|
-
{
|
550
|
+
int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary,
|
551
|
+
uInt dictLength) {
|
382
552
|
deflate_state *s;
|
383
553
|
uInt str, n;
|
384
554
|
int wrap;
|
@@ -443,11 +613,8 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
|
443
613
|
}
|
444
614
|
|
445
615
|
/* ========================================================================= */
|
446
|
-
int ZEXPORT deflateGetDictionary
|
447
|
-
|
448
|
-
Bytef *dictionary;
|
449
|
-
uInt *dictLength;
|
450
|
-
{
|
616
|
+
int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary,
|
617
|
+
uInt *dictLength) {
|
451
618
|
deflate_state *s;
|
452
619
|
uInt len;
|
453
620
|
|
@@ -465,9 +632,7 @@ int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength)
|
|
465
632
|
}
|
466
633
|
|
467
634
|
/* ========================================================================= */
|
468
|
-
int ZEXPORT deflateResetKeep
|
469
|
-
z_streamp strm;
|
470
|
-
{
|
635
|
+
int ZEXPORT deflateResetKeep(z_streamp strm) {
|
471
636
|
deflate_state *s;
|
472
637
|
|
473
638
|
if (deflateStateCheck(strm)) {
|
@@ -489,23 +654,45 @@ int ZEXPORT deflateResetKeep (strm)
|
|
489
654
|
#ifdef GZIP
|
490
655
|
s->wrap == 2 ? GZIP_STATE :
|
491
656
|
#endif
|
492
|
-
|
657
|
+
INIT_STATE;
|
493
658
|
strm->adler =
|
494
659
|
#ifdef GZIP
|
495
660
|
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
|
496
661
|
#endif
|
497
662
|
adler32(0L, Z_NULL, 0);
|
498
|
-
s->last_flush =
|
663
|
+
s->last_flush = -2;
|
499
664
|
|
500
665
|
_tr_init(s);
|
501
666
|
|
502
667
|
return Z_OK;
|
503
668
|
}
|
504
669
|
|
670
|
+
/* ===========================================================================
|
671
|
+
* Initialize the "longest match" routines for a new zlib stream
|
672
|
+
*/
|
673
|
+
local void lm_init(deflate_state *s) {
|
674
|
+
s->window_size = (ulg)2L*s->w_size;
|
675
|
+
|
676
|
+
CLEAR_HASH(s);
|
677
|
+
|
678
|
+
/* Set the default configuration parameters:
|
679
|
+
*/
|
680
|
+
s->max_lazy_match = configuration_table[s->level].max_lazy;
|
681
|
+
s->good_match = configuration_table[s->level].good_length;
|
682
|
+
s->nice_match = configuration_table[s->level].nice_length;
|
683
|
+
s->max_chain_length = configuration_table[s->level].max_chain;
|
684
|
+
|
685
|
+
s->strstart = 0;
|
686
|
+
s->block_start = 0L;
|
687
|
+
s->lookahead = 0;
|
688
|
+
s->insert = 0;
|
689
|
+
s->match_length = s->prev_length = MIN_MATCH-1;
|
690
|
+
s->match_available = 0;
|
691
|
+
s->ins_h = 0;
|
692
|
+
}
|
693
|
+
|
505
694
|
/* ========================================================================= */
|
506
|
-
int ZEXPORT deflateReset
|
507
|
-
z_streamp strm;
|
508
|
-
{
|
695
|
+
int ZEXPORT deflateReset(z_streamp strm) {
|
509
696
|
int ret;
|
510
697
|
|
511
698
|
ret = deflateResetKeep(strm);
|
@@ -515,10 +702,7 @@ int ZEXPORT deflateReset (strm)
|
|
515
702
|
}
|
516
703
|
|
517
704
|
/* ========================================================================= */
|
518
|
-
int ZEXPORT deflateSetHeader
|
519
|
-
z_streamp strm;
|
520
|
-
gz_headerp head;
|
521
|
-
{
|
705
|
+
int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) {
|
522
706
|
if (deflateStateCheck(strm) || strm->state->wrap != 2)
|
523
707
|
return Z_STREAM_ERROR;
|
524
708
|
strm->state->gzhead = head;
|
@@ -526,11 +710,7 @@ int ZEXPORT deflateSetHeader (strm, head)
|
|
526
710
|
}
|
527
711
|
|
528
712
|
/* ========================================================================= */
|
529
|
-
int ZEXPORT deflatePending
|
530
|
-
unsigned *pending;
|
531
|
-
int *bits;
|
532
|
-
z_streamp strm;
|
533
|
-
{
|
713
|
+
int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
|
534
714
|
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
535
715
|
if (pending != Z_NULL)
|
536
716
|
*pending = strm->state->pending;
|
@@ -540,18 +720,21 @@ int ZEXPORT deflatePending (strm, pending, bits)
|
|
540
720
|
}
|
541
721
|
|
542
722
|
/* ========================================================================= */
|
543
|
-
int ZEXPORT deflatePrime
|
544
|
-
z_streamp strm;
|
545
|
-
int bits;
|
546
|
-
int value;
|
547
|
-
{
|
723
|
+
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
|
548
724
|
deflate_state *s;
|
549
725
|
int put;
|
550
726
|
|
551
727
|
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
552
728
|
s = strm->state;
|
553
|
-
|
729
|
+
#ifdef LIT_MEM
|
730
|
+
if (bits < 0 || bits > 16 ||
|
731
|
+
(uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3))
|
732
|
+
return Z_BUF_ERROR;
|
733
|
+
#else
|
734
|
+
if (bits < 0 || bits > 16 ||
|
735
|
+
s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3))
|
554
736
|
return Z_BUF_ERROR;
|
737
|
+
#endif
|
555
738
|
do {
|
556
739
|
put = Buf_size - s->bi_valid;
|
557
740
|
if (put > bits)
|
@@ -566,11 +749,7 @@ int ZEXPORT deflatePrime (strm, bits, value)
|
|
566
749
|
}
|
567
750
|
|
568
751
|
/* ========================================================================= */
|
569
|
-
int ZEXPORT deflateParams(strm, level, strategy)
|
570
|
-
z_streamp strm;
|
571
|
-
int level;
|
572
|
-
int strategy;
|
573
|
-
{
|
752
|
+
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) {
|
574
753
|
deflate_state *s;
|
575
754
|
compress_func func;
|
576
755
|
|
@@ -588,12 +767,12 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
|
588
767
|
func = configuration_table[s->level].func;
|
589
768
|
|
590
769
|
if ((strategy != s->strategy || func != configuration_table[level].func) &&
|
591
|
-
s->
|
770
|
+
s->last_flush != -2) {
|
592
771
|
/* Flush the last buffer: */
|
593
772
|
int err = deflate(strm, Z_BLOCK);
|
594
773
|
if (err == Z_STREAM_ERROR)
|
595
774
|
return err;
|
596
|
-
if (strm->
|
775
|
+
if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead)
|
597
776
|
return Z_BUF_ERROR;
|
598
777
|
}
|
599
778
|
if (s->level != level) {
|
@@ -615,13 +794,8 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
|
615
794
|
}
|
616
795
|
|
617
796
|
/* ========================================================================= */
|
618
|
-
int ZEXPORT deflateTune(strm, good_length, max_lazy,
|
619
|
-
|
620
|
-
int good_length;
|
621
|
-
int max_lazy;
|
622
|
-
int nice_length;
|
623
|
-
int max_chain;
|
624
|
-
{
|
797
|
+
int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy,
|
798
|
+
int nice_length, int max_chain) {
|
625
799
|
deflate_state *s;
|
626
800
|
|
627
801
|
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
@@ -634,36 +808,47 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
|
|
634
808
|
}
|
635
809
|
|
636
810
|
/* =========================================================================
|
637
|
-
* For the default windowBits of 15 and memLevel of 8, this function returns
|
638
|
-
*
|
639
|
-
*
|
640
|
-
*
|
641
|
-
*
|
811
|
+
* For the default windowBits of 15 and memLevel of 8, this function returns a
|
812
|
+
* close to exact, as well as small, upper bound on the compressed size. This
|
813
|
+
* is an expansion of ~0.03%, plus a small constant.
|
814
|
+
*
|
815
|
+
* For any setting other than those defaults for windowBits and memLevel, one
|
816
|
+
* of two worst case bounds is returned. This is at most an expansion of ~4% or
|
817
|
+
* ~13%, plus a small constant.
|
818
|
+
*
|
819
|
+
* Both the 0.03% and 4% derive from the overhead of stored blocks. The first
|
820
|
+
* one is for stored blocks of 16383 bytes (memLevel == 8), whereas the second
|
821
|
+
* is for stored blocks of 127 bytes (the worst case memLevel == 1). The
|
822
|
+
* expansion results from five bytes of header for each stored block.
|
642
823
|
*
|
643
|
-
*
|
644
|
-
* the
|
645
|
-
*
|
646
|
-
*
|
824
|
+
* The larger expansion of 13% results from a window size less than or equal to
|
825
|
+
* the symbols buffer size (windowBits <= memLevel + 7). In that case some of
|
826
|
+
* the data being compressed may have slid out of the sliding window, impeding
|
827
|
+
* a stored block from being emitted. Then the only choice is a fixed or
|
828
|
+
* dynamic block, where a fixed block limits the maximum expansion to 9 bits
|
829
|
+
* per 8-bit byte, plus 10 bits for every block. The smallest block size for
|
830
|
+
* which this can occur is 255 (memLevel == 2).
|
647
831
|
*
|
648
|
-
*
|
649
|
-
* every combination of windowBits and memLevel. But even the conservative
|
650
|
-
* upper bound of about 14% expansion does not seem onerous for output buffer
|
651
|
-
* allocation.
|
832
|
+
* Shifts are used to approximate divisions, for speed.
|
652
833
|
*/
|
653
|
-
uLong ZEXPORT deflateBound(strm, sourceLen)
|
654
|
-
z_streamp strm;
|
655
|
-
uLong sourceLen;
|
656
|
-
{
|
834
|
+
uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
|
657
835
|
deflate_state *s;
|
658
|
-
uLong
|
836
|
+
uLong fixedlen, storelen, wraplen;
|
659
837
|
|
660
|
-
/*
|
661
|
-
|
662
|
-
|
838
|
+
/* upper bound for fixed blocks with 9-bit literals and length 255
|
839
|
+
(memLevel == 2, which is the lowest that may not use stored blocks) --
|
840
|
+
~13% overhead plus a small constant */
|
841
|
+
fixedlen = sourceLen + (sourceLen >> 3) + (sourceLen >> 8) +
|
842
|
+
(sourceLen >> 9) + 4;
|
663
843
|
|
664
|
-
/*
|
844
|
+
/* upper bound for stored blocks with length 127 (memLevel == 1) --
|
845
|
+
~4% overhead plus a small constant */
|
846
|
+
storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) +
|
847
|
+
(sourceLen >> 11) + 7;
|
848
|
+
|
849
|
+
/* if can't get parameters, return larger bound plus a zlib wrapper */
|
665
850
|
if (deflateStateCheck(strm))
|
666
|
-
return
|
851
|
+
return (fixedlen > storelen ? fixedlen : storelen) + 6;
|
667
852
|
|
668
853
|
/* compute wrapper length */
|
669
854
|
s = strm->state;
|
@@ -700,11 +885,13 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
|
|
700
885
|
wraplen = 6;
|
701
886
|
}
|
702
887
|
|
703
|
-
/* if not default parameters, return conservative
|
888
|
+
/* if not default parameters, return one of the conservative bounds */
|
704
889
|
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
|
705
|
-
return
|
890
|
+
return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
|
891
|
+
wraplen;
|
706
892
|
|
707
|
-
/* default settings: return tight bound for that case
|
893
|
+
/* default settings: return tight bound for that case -- ~0.03% overhead
|
894
|
+
plus a small constant */
|
708
895
|
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
709
896
|
(sourceLen >> 25) + 13 - 6 + wraplen;
|
710
897
|
}
|
@@ -714,10 +901,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
|
|
714
901
|
* IN assertion: the stream state is correct and there is enough room in
|
715
902
|
* pending_buf.
|
716
903
|
*/
|
717
|
-
local void putShortMSB
|
718
|
-
deflate_state *s;
|
719
|
-
uInt b;
|
720
|
-
{
|
904
|
+
local void putShortMSB(deflate_state *s, uInt b) {
|
721
905
|
put_byte(s, (Byte)(b >> 8));
|
722
906
|
put_byte(s, (Byte)(b & 0xff));
|
723
907
|
}
|
@@ -728,9 +912,7 @@ local void putShortMSB (s, b)
|
|
728
912
|
* applications may wish to modify it to avoid allocating a large
|
729
913
|
* strm->next_out buffer and copying into it. (See also read_buf()).
|
730
914
|
*/
|
731
|
-
local void flush_pending(strm)
|
732
|
-
z_streamp strm;
|
733
|
-
{
|
915
|
+
local void flush_pending(z_streamp strm) {
|
734
916
|
unsigned len;
|
735
917
|
deflate_state *s = strm->state;
|
736
918
|
|
@@ -761,10 +943,7 @@ local void flush_pending(strm)
|
|
761
943
|
} while (0)
|
762
944
|
|
763
945
|
/* ========================================================================= */
|
764
|
-
int ZEXPORT deflate
|
765
|
-
z_streamp strm;
|
766
|
-
int flush;
|
767
|
-
{
|
946
|
+
int ZEXPORT deflate(z_streamp strm, int flush) {
|
768
947
|
int old_flush; /* value of flush param for previous deflate call */
|
769
948
|
deflate_state *s;
|
770
949
|
|
@@ -812,9 +991,11 @@ int ZEXPORT deflate (strm, flush)
|
|
812
991
|
}
|
813
992
|
|
814
993
|
/* Write the header */
|
994
|
+
if (s->status == INIT_STATE && s->wrap == 0)
|
995
|
+
s->status = BUSY_STATE;
|
815
996
|
if (s->status == INIT_STATE) {
|
816
997
|
/* zlib header */
|
817
|
-
uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
|
998
|
+
uInt header = (Z_DEFLATED + ((s->w_bits - 8) << 4)) << 8;
|
818
999
|
uInt level_flags;
|
819
1000
|
|
820
1001
|
if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
|
@@ -1074,9 +1255,7 @@ int ZEXPORT deflate (strm, flush)
|
|
1074
1255
|
}
|
1075
1256
|
|
1076
1257
|
/* ========================================================================= */
|
1077
|
-
int ZEXPORT deflateEnd
|
1078
|
-
z_streamp strm;
|
1079
|
-
{
|
1258
|
+
int ZEXPORT deflateEnd(z_streamp strm) {
|
1080
1259
|
int status;
|
1081
1260
|
|
1082
1261
|
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
@@ -1100,16 +1279,14 @@ int ZEXPORT deflateEnd (strm)
|
|
1100
1279
|
* To simplify the source, this is not supported for 16-bit MSDOS (which
|
1101
1280
|
* doesn't have enough memory anyway to duplicate compression states).
|
1102
1281
|
*/
|
1103
|
-
int ZEXPORT deflateCopy
|
1104
|
-
z_streamp dest;
|
1105
|
-
z_streamp source;
|
1106
|
-
{
|
1282
|
+
int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
|
1107
1283
|
#ifdef MAXSEG_64K
|
1284
|
+
(void)dest;
|
1285
|
+
(void)source;
|
1108
1286
|
return Z_STREAM_ERROR;
|
1109
1287
|
#else
|
1110
1288
|
deflate_state *ds;
|
1111
1289
|
deflate_state *ss;
|
1112
|
-
ushf *overlay;
|
1113
1290
|
|
1114
1291
|
|
1115
1292
|
if (deflateStateCheck(source) || dest == Z_NULL) {
|
@@ -1129,8 +1306,7 @@ int ZEXPORT deflateCopy (dest, source)
|
|
1129
1306
|
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
|
1130
1307
|
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
|
1131
1308
|
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
|
1132
|
-
|
1133
|
-
ds->pending_buf = (uchf *) overlay;
|
1309
|
+
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);
|
1134
1310
|
|
1135
1311
|
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
|
1136
1312
|
ds->pending_buf == Z_NULL) {
|
@@ -1141,11 +1317,15 @@ int ZEXPORT deflateCopy (dest, source)
|
|
1141
1317
|
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
|
1142
1318
|
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
|
1143
1319
|
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
|
1144
|
-
zmemcpy(ds->pending_buf, ss->pending_buf,
|
1320
|
+
zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS);
|
1145
1321
|
|
1146
1322
|
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
|
1147
|
-
|
1148
|
-
ds->
|
1323
|
+
#ifdef LIT_MEM
|
1324
|
+
ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1));
|
1325
|
+
ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2);
|
1326
|
+
#else
|
1327
|
+
ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
|
1328
|
+
#endif
|
1149
1329
|
|
1150
1330
|
ds->l_desc.dyn_tree = ds->dyn_ltree;
|
1151
1331
|
ds->d_desc.dyn_tree = ds->dyn_dtree;
|
@@ -1155,71 +1335,6 @@ int ZEXPORT deflateCopy (dest, source)
|
|
1155
1335
|
#endif /* MAXSEG_64K */
|
1156
1336
|
}
|
1157
1337
|
|
1158
|
-
/* ===========================================================================
|
1159
|
-
* Read a new buffer from the current input stream, update the adler32
|
1160
|
-
* and total number of bytes read. All deflate() input goes through
|
1161
|
-
* this function so some applications may wish to modify it to avoid
|
1162
|
-
* allocating a large strm->next_in buffer and copying from it.
|
1163
|
-
* (See also flush_pending()).
|
1164
|
-
*/
|
1165
|
-
local unsigned read_buf(strm, buf, size)
|
1166
|
-
z_streamp strm;
|
1167
|
-
Bytef *buf;
|
1168
|
-
unsigned size;
|
1169
|
-
{
|
1170
|
-
unsigned len = strm->avail_in;
|
1171
|
-
|
1172
|
-
if (len > size) len = size;
|
1173
|
-
if (len == 0) return 0;
|
1174
|
-
|
1175
|
-
strm->avail_in -= len;
|
1176
|
-
|
1177
|
-
zmemcpy(buf, strm->next_in, len);
|
1178
|
-
if (strm->state->wrap == 1) {
|
1179
|
-
strm->adler = adler32(strm->adler, buf, len);
|
1180
|
-
}
|
1181
|
-
#ifdef GZIP
|
1182
|
-
else if (strm->state->wrap == 2) {
|
1183
|
-
strm->adler = crc32(strm->adler, buf, len);
|
1184
|
-
}
|
1185
|
-
#endif
|
1186
|
-
strm->next_in += len;
|
1187
|
-
strm->total_in += len;
|
1188
|
-
|
1189
|
-
return len;
|
1190
|
-
}
|
1191
|
-
|
1192
|
-
/* ===========================================================================
|
1193
|
-
* Initialize the "longest match" routines for a new zlib stream
|
1194
|
-
*/
|
1195
|
-
local void lm_init (s)
|
1196
|
-
deflate_state *s;
|
1197
|
-
{
|
1198
|
-
s->window_size = (ulg)2L*s->w_size;
|
1199
|
-
|
1200
|
-
CLEAR_HASH(s);
|
1201
|
-
|
1202
|
-
/* Set the default configuration parameters:
|
1203
|
-
*/
|
1204
|
-
s->max_lazy_match = configuration_table[s->level].max_lazy;
|
1205
|
-
s->good_match = configuration_table[s->level].good_length;
|
1206
|
-
s->nice_match = configuration_table[s->level].nice_length;
|
1207
|
-
s->max_chain_length = configuration_table[s->level].max_chain;
|
1208
|
-
|
1209
|
-
s->strstart = 0;
|
1210
|
-
s->block_start = 0L;
|
1211
|
-
s->lookahead = 0;
|
1212
|
-
s->insert = 0;
|
1213
|
-
s->match_length = s->prev_length = MIN_MATCH-1;
|
1214
|
-
s->match_available = 0;
|
1215
|
-
s->ins_h = 0;
|
1216
|
-
#ifndef FASTEST
|
1217
|
-
#ifdef ASMV
|
1218
|
-
match_init(); /* initialize the asm code */
|
1219
|
-
#endif
|
1220
|
-
#endif
|
1221
|
-
}
|
1222
|
-
|
1223
1338
|
#ifndef FASTEST
|
1224
1339
|
/* ===========================================================================
|
1225
1340
|
* Set match_start to the longest match starting at the given string and
|
@@ -1230,14 +1345,7 @@ local void lm_init (s)
|
|
1230
1345
|
* string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
|
1231
1346
|
* OUT assertion: the match length is not greater than s->lookahead.
|
1232
1347
|
*/
|
1233
|
-
|
1234
|
-
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
|
1235
|
-
* match.S. The code will be functionally equivalent.
|
1236
|
-
*/
|
1237
|
-
local uInt longest_match(s, cur_match)
|
1238
|
-
deflate_state *s;
|
1239
|
-
IPos cur_match; /* current match */
|
1240
|
-
{
|
1348
|
+
local uInt longest_match(deflate_state *s, IPos cur_match) {
|
1241
1349
|
unsigned chain_length = s->max_chain_length;/* max hash chain length */
|
1242
1350
|
register Bytef *scan = s->window + s->strstart; /* current string */
|
1243
1351
|
register Bytef *match; /* matched string */
|
@@ -1258,10 +1366,10 @@ local uInt longest_match(s, cur_match)
|
|
1258
1366
|
*/
|
1259
1367
|
register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
|
1260
1368
|
register ush scan_start = *(ushf*)scan;
|
1261
|
-
register ush scan_end = *(ushf*)(scan+best_len-1);
|
1369
|
+
register ush scan_end = *(ushf*)(scan + best_len - 1);
|
1262
1370
|
#else
|
1263
1371
|
register Bytef *strend = s->window + s->strstart + MAX_MATCH;
|
1264
|
-
register Byte scan_end1 = scan[best_len-1];
|
1372
|
+
register Byte scan_end1 = scan[best_len - 1];
|
1265
1373
|
register Byte scan_end = scan[best_len];
|
1266
1374
|
#endif
|
1267
1375
|
|
@@ -1279,7 +1387,8 @@ local uInt longest_match(s, cur_match)
|
|
1279
1387
|
*/
|
1280
1388
|
if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead;
|
1281
1389
|
|
1282
|
-
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD,
|
1390
|
+
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
1391
|
+
"need lookahead");
|
1283
1392
|
|
1284
1393
|
do {
|
1285
1394
|
Assert(cur_match < s->strstart, "no future");
|
@@ -1297,43 +1406,44 @@ local uInt longest_match(s, cur_match)
|
|
1297
1406
|
/* This code assumes sizeof(unsigned short) == 2. Do not use
|
1298
1407
|
* UNALIGNED_OK if your compiler uses a different size.
|
1299
1408
|
*/
|
1300
|
-
if (*(ushf*)(match+best_len-1) != scan_end ||
|
1409
|
+
if (*(ushf*)(match + best_len - 1) != scan_end ||
|
1301
1410
|
*(ushf*)match != scan_start) continue;
|
1302
1411
|
|
1303
1412
|
/* It is not necessary to compare scan[2] and match[2] since they are
|
1304
1413
|
* always equal when the other bytes match, given that the hash keys
|
1305
1414
|
* are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
|
1306
|
-
* strstart+3, +5,
|
1415
|
+
* strstart + 3, + 5, up to strstart + 257. We check for insufficient
|
1307
1416
|
* lookahead only every 4th comparison; the 128th check will be made
|
1308
|
-
* at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
|
1417
|
+
* at strstart + 257. If MAX_MATCH-2 is not a multiple of 8, it is
|
1309
1418
|
* necessary to put more guard bytes at the end of the window, or
|
1310
1419
|
* to check more often for insufficient lookahead.
|
1311
1420
|
*/
|
1312
1421
|
Assert(scan[2] == match[2], "scan[2]?");
|
1313
1422
|
scan++, match++;
|
1314
1423
|
do {
|
1315
|
-
} while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
|
1316
|
-
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
|
1317
|
-
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
|
1318
|
-
*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
|
1424
|
+
} while (*(ushf*)(scan += 2) == *(ushf*)(match += 2) &&
|
1425
|
+
*(ushf*)(scan += 2) == *(ushf*)(match += 2) &&
|
1426
|
+
*(ushf*)(scan += 2) == *(ushf*)(match += 2) &&
|
1427
|
+
*(ushf*)(scan += 2) == *(ushf*)(match += 2) &&
|
1319
1428
|
scan < strend);
|
1320
1429
|
/* The funny "do {}" generates better code on most compilers */
|
1321
1430
|
|
1322
|
-
/* Here, scan <= window+strstart+257 */
|
1323
|
-
Assert(scan <= s->window+(unsigned)(s->window_size-1),
|
1431
|
+
/* Here, scan <= window + strstart + 257 */
|
1432
|
+
Assert(scan <= s->window + (unsigned)(s->window_size - 1),
|
1433
|
+
"wild scan");
|
1324
1434
|
if (*scan == *match) scan++;
|
1325
1435
|
|
1326
|
-
len = (MAX_MATCH - 1) - (int)(strend-scan);
|
1436
|
+
len = (MAX_MATCH - 1) - (int)(strend - scan);
|
1327
1437
|
scan = strend - (MAX_MATCH-1);
|
1328
1438
|
|
1329
1439
|
#else /* UNALIGNED_OK */
|
1330
1440
|
|
1331
|
-
if (match[best_len]
|
1332
|
-
match[best_len-1] != scan_end1 ||
|
1333
|
-
*match
|
1334
|
-
*++match
|
1441
|
+
if (match[best_len] != scan_end ||
|
1442
|
+
match[best_len - 1] != scan_end1 ||
|
1443
|
+
*match != *scan ||
|
1444
|
+
*++match != scan[1]) continue;
|
1335
1445
|
|
1336
|
-
/* The check at best_len-1 can be removed because it will be made
|
1446
|
+
/* The check at best_len - 1 can be removed because it will be made
|
1337
1447
|
* again later. (This heuristic is not always a win.)
|
1338
1448
|
* It is not necessary to compare scan[2] and match[2] since they
|
1339
1449
|
* are always equal when the other bytes match, given that
|
@@ -1343,7 +1453,7 @@ local uInt longest_match(s, cur_match)
|
|
1343
1453
|
Assert(*scan == *match, "match[2]?");
|
1344
1454
|
|
1345
1455
|
/* We check for insufficient lookahead only every 8th comparison;
|
1346
|
-
* the 256th check will be made at strstart+258.
|
1456
|
+
* the 256th check will be made at strstart + 258.
|
1347
1457
|
*/
|
1348
1458
|
do {
|
1349
1459
|
} while (*++scan == *++match && *++scan == *++match &&
|
@@ -1352,7 +1462,8 @@ local uInt longest_match(s, cur_match)
|
|
1352
1462
|
*++scan == *++match && *++scan == *++match &&
|
1353
1463
|
scan < strend);
|
1354
1464
|
|
1355
|
-
Assert(scan <= s->window+(unsigned)(s->window_size-1),
|
1465
|
+
Assert(scan <= s->window + (unsigned)(s->window_size - 1),
|
1466
|
+
"wild scan");
|
1356
1467
|
|
1357
1468
|
len = MAX_MATCH - (int)(strend - scan);
|
1358
1469
|
scan = strend - MAX_MATCH;
|
@@ -1364,9 +1475,9 @@ local uInt longest_match(s, cur_match)
|
|
1364
1475
|
best_len = len;
|
1365
1476
|
if (len >= nice_match) break;
|
1366
1477
|
#ifdef UNALIGNED_OK
|
1367
|
-
scan_end = *(ushf*)(scan+best_len-1);
|
1478
|
+
scan_end = *(ushf*)(scan + best_len - 1);
|
1368
1479
|
#else
|
1369
|
-
scan_end1 = scan[best_len-1];
|
1480
|
+
scan_end1 = scan[best_len - 1];
|
1370
1481
|
scan_end = scan[best_len];
|
1371
1482
|
#endif
|
1372
1483
|
}
|
@@ -1376,17 +1487,13 @@ local uInt longest_match(s, cur_match)
|
|
1376
1487
|
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
|
1377
1488
|
return s->lookahead;
|
1378
1489
|
}
|
1379
|
-
#endif /* ASMV */
|
1380
1490
|
|
1381
1491
|
#else /* FASTEST */
|
1382
1492
|
|
1383
1493
|
/* ---------------------------------------------------------------------------
|
1384
1494
|
* Optimized version for FASTEST only
|
1385
1495
|
*/
|
1386
|
-
local uInt longest_match(s, cur_match)
|
1387
|
-
deflate_state *s;
|
1388
|
-
IPos cur_match; /* current match */
|
1389
|
-
{
|
1496
|
+
local uInt longest_match(deflate_state *s, IPos cur_match) {
|
1390
1497
|
register Bytef *scan = s->window + s->strstart; /* current string */
|
1391
1498
|
register Bytef *match; /* matched string */
|
1392
1499
|
register int len; /* length of current match */
|
@@ -1397,7 +1504,8 @@ local uInt longest_match(s, cur_match)
|
|
1397
1504
|
*/
|
1398
1505
|
Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
|
1399
1506
|
|
1400
|
-
Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD,
|
1507
|
+
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
1508
|
+
"need lookahead");
|
1401
1509
|
|
1402
1510
|
Assert(cur_match < s->strstart, "no future");
|
1403
1511
|
|
@@ -1407,7 +1515,7 @@ local uInt longest_match(s, cur_match)
|
|
1407
1515
|
*/
|
1408
1516
|
if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
|
1409
1517
|
|
1410
|
-
/* The check at best_len-1 can be removed because it will be made
|
1518
|
+
/* The check at best_len - 1 can be removed because it will be made
|
1411
1519
|
* again later. (This heuristic is not always a win.)
|
1412
1520
|
* It is not necessary to compare scan[2] and match[2] since they
|
1413
1521
|
* are always equal when the other bytes match, given that
|
@@ -1417,7 +1525,7 @@ local uInt longest_match(s, cur_match)
|
|
1417
1525
|
Assert(*scan == *match, "match[2]?");
|
1418
1526
|
|
1419
1527
|
/* We check for insufficient lookahead only every 8th comparison;
|
1420
|
-
* the 256th check will be made at strstart+258.
|
1528
|
+
* the 256th check will be made at strstart + 258.
|
1421
1529
|
*/
|
1422
1530
|
do {
|
1423
1531
|
} while (*++scan == *++match && *++scan == *++match &&
|
@@ -1426,7 +1534,7 @@ local uInt longest_match(s, cur_match)
|
|
1426
1534
|
*++scan == *++match && *++scan == *++match &&
|
1427
1535
|
scan < strend);
|
1428
1536
|
|
1429
|
-
Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
|
1537
|
+
Assert(scan <= s->window + (unsigned)(s->window_size - 1), "wild scan");
|
1430
1538
|
|
1431
1539
|
len = MAX_MATCH - (int)(strend - scan);
|
1432
1540
|
|
@@ -1446,23 +1554,27 @@ local uInt longest_match(s, cur_match)
|
|
1446
1554
|
/* ===========================================================================
|
1447
1555
|
* Check that the match at match_start is indeed a match.
|
1448
1556
|
*/
|
1449
|
-
local void check_match(s, start, match, length)
|
1450
|
-
deflate_state *s;
|
1451
|
-
IPos start, match;
|
1452
|
-
int length;
|
1453
|
-
{
|
1557
|
+
local void check_match(deflate_state *s, IPos start, IPos match, int length) {
|
1454
1558
|
/* check that the match is indeed a match */
|
1455
|
-
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1559
|
+
Bytef *back = s->window + (int)match, *here = s->window + start;
|
1560
|
+
IPos len = length;
|
1561
|
+
if (match == (IPos)-1) {
|
1562
|
+
/* match starts one byte before the current window -- just compare the
|
1563
|
+
subsequent length-1 bytes */
|
1564
|
+
back++;
|
1565
|
+
here++;
|
1566
|
+
len--;
|
1567
|
+
}
|
1568
|
+
if (zmemcmp(back, here, len) != EQUAL) {
|
1569
|
+
fprintf(stderr, " start %u, match %d, length %d\n",
|
1570
|
+
start, (int)match, length);
|
1459
1571
|
do {
|
1460
|
-
fprintf(stderr, "%
|
1461
|
-
} while (--
|
1572
|
+
fprintf(stderr, "(%02x %02x)", *back++, *here++);
|
1573
|
+
} while (--len != 0);
|
1462
1574
|
z_error("invalid match");
|
1463
1575
|
}
|
1464
1576
|
if (z_verbose > 1) {
|
1465
|
-
fprintf(stderr,"\\[%d,%d]", start-match, length);
|
1577
|
+
fprintf(stderr,"\\[%d,%d]", start - match, length);
|
1466
1578
|
do { putc(s->window[start++], stderr); } while (--length != 0);
|
1467
1579
|
}
|
1468
1580
|
}
|
@@ -1470,135 +1582,6 @@ local void check_match(s, start, match, length)
|
|
1470
1582
|
# define check_match(s, start, match, length)
|
1471
1583
|
#endif /* ZLIB_DEBUG */
|
1472
1584
|
|
1473
|
-
/* ===========================================================================
|
1474
|
-
* Fill the window when the lookahead becomes insufficient.
|
1475
|
-
* Updates strstart and lookahead.
|
1476
|
-
*
|
1477
|
-
* IN assertion: lookahead < MIN_LOOKAHEAD
|
1478
|
-
* OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
|
1479
|
-
* At least one byte has been read, or avail_in == 0; reads are
|
1480
|
-
* performed for at least two bytes (required for the zip translate_eol
|
1481
|
-
* option -- not supported here).
|
1482
|
-
*/
|
1483
|
-
local void fill_window(s)
|
1484
|
-
deflate_state *s;
|
1485
|
-
{
|
1486
|
-
unsigned n;
|
1487
|
-
unsigned more; /* Amount of free space at the end of the window. */
|
1488
|
-
uInt wsize = s->w_size;
|
1489
|
-
|
1490
|
-
Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
|
1491
|
-
|
1492
|
-
do {
|
1493
|
-
more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
|
1494
|
-
|
1495
|
-
/* Deal with !@#$% 64K limit: */
|
1496
|
-
if (sizeof(int) <= 2) {
|
1497
|
-
if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
|
1498
|
-
more = wsize;
|
1499
|
-
|
1500
|
-
} else if (more == (unsigned)(-1)) {
|
1501
|
-
/* Very unlikely, but possible on 16 bit machine if
|
1502
|
-
* strstart == 0 && lookahead == 1 (input done a byte at time)
|
1503
|
-
*/
|
1504
|
-
more--;
|
1505
|
-
}
|
1506
|
-
}
|
1507
|
-
|
1508
|
-
/* If the window is almost full and there is insufficient lookahead,
|
1509
|
-
* move the upper half to the lower one to make room in the upper half.
|
1510
|
-
*/
|
1511
|
-
if (s->strstart >= wsize+MAX_DIST(s)) {
|
1512
|
-
|
1513
|
-
zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more);
|
1514
|
-
s->match_start -= wsize;
|
1515
|
-
s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
|
1516
|
-
s->block_start -= (long) wsize;
|
1517
|
-
slide_hash(s);
|
1518
|
-
more += wsize;
|
1519
|
-
}
|
1520
|
-
if (s->strm->avail_in == 0) break;
|
1521
|
-
|
1522
|
-
/* If there was no sliding:
|
1523
|
-
* strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
|
1524
|
-
* more == window_size - lookahead - strstart
|
1525
|
-
* => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
|
1526
|
-
* => more >= window_size - 2*WSIZE + 2
|
1527
|
-
* In the BIG_MEM or MMAP case (not yet supported),
|
1528
|
-
* window_size == input_size + MIN_LOOKAHEAD &&
|
1529
|
-
* strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
|
1530
|
-
* Otherwise, window_size == 2*WSIZE so more >= 2.
|
1531
|
-
* If there was sliding, more >= WSIZE. So in all cases, more >= 2.
|
1532
|
-
*/
|
1533
|
-
Assert(more >= 2, "more < 2");
|
1534
|
-
|
1535
|
-
n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
|
1536
|
-
s->lookahead += n;
|
1537
|
-
|
1538
|
-
/* Initialize the hash value now that we have some input: */
|
1539
|
-
if (s->lookahead + s->insert >= MIN_MATCH) {
|
1540
|
-
uInt str = s->strstart - s->insert;
|
1541
|
-
s->ins_h = s->window[str];
|
1542
|
-
UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
|
1543
|
-
#if MIN_MATCH != 3
|
1544
|
-
Call UPDATE_HASH() MIN_MATCH-3 more times
|
1545
|
-
#endif
|
1546
|
-
while (s->insert) {
|
1547
|
-
UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
|
1548
|
-
#ifndef FASTEST
|
1549
|
-
s->prev[str & s->w_mask] = s->head[s->ins_h];
|
1550
|
-
#endif
|
1551
|
-
s->head[s->ins_h] = (Pos)str;
|
1552
|
-
str++;
|
1553
|
-
s->insert--;
|
1554
|
-
if (s->lookahead + s->insert < MIN_MATCH)
|
1555
|
-
break;
|
1556
|
-
}
|
1557
|
-
}
|
1558
|
-
/* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
|
1559
|
-
* but this is not important since only literal bytes will be emitted.
|
1560
|
-
*/
|
1561
|
-
|
1562
|
-
} while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
|
1563
|
-
|
1564
|
-
/* If the WIN_INIT bytes after the end of the current data have never been
|
1565
|
-
* written, then zero those bytes in order to avoid memory check reports of
|
1566
|
-
* the use of uninitialized (or uninitialised as Julian writes) bytes by
|
1567
|
-
* the longest match routines. Update the high water mark for the next
|
1568
|
-
* time through here. WIN_INIT is set to MAX_MATCH since the longest match
|
1569
|
-
* routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
|
1570
|
-
*/
|
1571
|
-
if (s->high_water < s->window_size) {
|
1572
|
-
ulg curr = s->strstart + (ulg)(s->lookahead);
|
1573
|
-
ulg init;
|
1574
|
-
|
1575
|
-
if (s->high_water < curr) {
|
1576
|
-
/* Previous high water mark below current data -- zero WIN_INIT
|
1577
|
-
* bytes or up to end of window, whichever is less.
|
1578
|
-
*/
|
1579
|
-
init = s->window_size - curr;
|
1580
|
-
if (init > WIN_INIT)
|
1581
|
-
init = WIN_INIT;
|
1582
|
-
zmemzero(s->window + curr, (unsigned)init);
|
1583
|
-
s->high_water = curr + init;
|
1584
|
-
}
|
1585
|
-
else if (s->high_water < (ulg)curr + WIN_INIT) {
|
1586
|
-
/* High water mark at or above current data, but below current data
|
1587
|
-
* plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
|
1588
|
-
* to end of window, whichever is less.
|
1589
|
-
*/
|
1590
|
-
init = (ulg)curr + WIN_INIT - s->high_water;
|
1591
|
-
if (init > s->window_size - s->high_water)
|
1592
|
-
init = s->window_size - s->high_water;
|
1593
|
-
zmemzero(s->window + s->high_water, (unsigned)init);
|
1594
|
-
s->high_water += init;
|
1595
|
-
}
|
1596
|
-
}
|
1597
|
-
|
1598
|
-
Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
|
1599
|
-
"not enough room for search");
|
1600
|
-
}
|
1601
|
-
|
1602
1585
|
/* ===========================================================================
|
1603
1586
|
* Flush the current block, with given end-of-file flag.
|
1604
1587
|
* IN assertion: strstart is set to the end of the current match.
|
@@ -1639,12 +1622,9 @@ local void fill_window(s)
|
|
1639
1622
|
*
|
1640
1623
|
* deflate_stored() is written to minimize the number of times an input byte is
|
1641
1624
|
* copied. It is most efficient with large input and output buffers, which
|
1642
|
-
* maximizes the
|
1625
|
+
* maximizes the opportunities to have a single copy from next_in to next_out.
|
1643
1626
|
*/
|
1644
|
-
local block_state deflate_stored(s, flush)
|
1645
|
-
deflate_state *s;
|
1646
|
-
int flush;
|
1647
|
-
{
|
1627
|
+
local block_state deflate_stored(deflate_state *s, int flush) {
|
1648
1628
|
/* Smallest worthy block size when not flushing or finishing. By default
|
1649
1629
|
* this is 32K. This can be as small as 507 bytes for memLevel == 1. For
|
1650
1630
|
* large input and output buffers, the stored block size will be larger.
|
@@ -1743,6 +1723,7 @@ local block_state deflate_stored(s, flush)
|
|
1743
1723
|
s->matches = 2; /* clear hash */
|
1744
1724
|
zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size);
|
1745
1725
|
s->strstart = s->w_size;
|
1726
|
+
s->insert = s->strstart;
|
1746
1727
|
}
|
1747
1728
|
else {
|
1748
1729
|
if (s->window_size - s->strstart <= used) {
|
@@ -1751,12 +1732,14 @@ local block_state deflate_stored(s, flush)
|
|
1751
1732
|
zmemcpy(s->window, s->window + s->w_size, s->strstart);
|
1752
1733
|
if (s->matches < 2)
|
1753
1734
|
s->matches++; /* add a pending slide_hash() */
|
1735
|
+
if (s->insert > s->strstart)
|
1736
|
+
s->insert = s->strstart;
|
1754
1737
|
}
|
1755
1738
|
zmemcpy(s->window + s->strstart, s->strm->next_in - used, used);
|
1756
1739
|
s->strstart += used;
|
1740
|
+
s->insert += MIN(used, s->w_size - s->insert);
|
1757
1741
|
}
|
1758
1742
|
s->block_start = s->strstart;
|
1759
|
-
s->insert += MIN(used, s->w_size - s->insert);
|
1760
1743
|
}
|
1761
1744
|
if (s->high_water < s->strstart)
|
1762
1745
|
s->high_water = s->strstart;
|
@@ -1771,7 +1754,7 @@ local block_state deflate_stored(s, flush)
|
|
1771
1754
|
return block_done;
|
1772
1755
|
|
1773
1756
|
/* Fill the window with any remaining input. */
|
1774
|
-
have = s->window_size - s->strstart
|
1757
|
+
have = s->window_size - s->strstart;
|
1775
1758
|
if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) {
|
1776
1759
|
/* Slide the window down. */
|
1777
1760
|
s->block_start -= s->w_size;
|
@@ -1780,12 +1763,15 @@ local block_state deflate_stored(s, flush)
|
|
1780
1763
|
if (s->matches < 2)
|
1781
1764
|
s->matches++; /* add a pending slide_hash() */
|
1782
1765
|
have += s->w_size; /* more space now */
|
1766
|
+
if (s->insert > s->strstart)
|
1767
|
+
s->insert = s->strstart;
|
1783
1768
|
}
|
1784
1769
|
if (have > s->strm->avail_in)
|
1785
1770
|
have = s->strm->avail_in;
|
1786
1771
|
if (have) {
|
1787
1772
|
read_buf(s->strm, s->window + s->strstart, have);
|
1788
1773
|
s->strstart += have;
|
1774
|
+
s->insert += MIN(have, s->w_size - s->insert);
|
1789
1775
|
}
|
1790
1776
|
if (s->high_water < s->strstart)
|
1791
1777
|
s->high_water = s->strstart;
|
@@ -1822,10 +1808,7 @@ local block_state deflate_stored(s, flush)
|
|
1822
1808
|
* new strings in the dictionary only for unmatched strings or for short
|
1823
1809
|
* matches. It is used only for the fast compression options.
|
1824
1810
|
*/
|
1825
|
-
local block_state deflate_fast(s, flush)
|
1826
|
-
deflate_state *s;
|
1827
|
-
int flush;
|
1828
|
-
{
|
1811
|
+
local block_state deflate_fast(deflate_state *s, int flush) {
|
1829
1812
|
IPos hash_head; /* head of the hash chain */
|
1830
1813
|
int bflush; /* set if current block must be flushed */
|
1831
1814
|
|
@@ -1843,7 +1826,7 @@ local block_state deflate_fast(s, flush)
|
|
1843
1826
|
if (s->lookahead == 0) break; /* flush the current block */
|
1844
1827
|
}
|
1845
1828
|
|
1846
|
-
/* Insert the string window[strstart .. strstart+2] in the
|
1829
|
+
/* Insert the string window[strstart .. strstart + 2] in the
|
1847
1830
|
* dictionary, and set hash_head to the head of the hash chain:
|
1848
1831
|
*/
|
1849
1832
|
hash_head = NIL;
|
@@ -1891,7 +1874,7 @@ local block_state deflate_fast(s, flush)
|
|
1891
1874
|
s->strstart += s->match_length;
|
1892
1875
|
s->match_length = 0;
|
1893
1876
|
s->ins_h = s->window[s->strstart];
|
1894
|
-
UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
|
1877
|
+
UPDATE_HASH(s, s->ins_h, s->window[s->strstart + 1]);
|
1895
1878
|
#if MIN_MATCH != 3
|
1896
1879
|
Call UPDATE_HASH() MIN_MATCH-3 more times
|
1897
1880
|
#endif
|
@@ -1902,7 +1885,7 @@ local block_state deflate_fast(s, flush)
|
|
1902
1885
|
} else {
|
1903
1886
|
/* No match, output a literal byte */
|
1904
1887
|
Tracevv((stderr,"%c", s->window[s->strstart]));
|
1905
|
-
_tr_tally_lit
|
1888
|
+
_tr_tally_lit(s, s->window[s->strstart], bflush);
|
1906
1889
|
s->lookahead--;
|
1907
1890
|
s->strstart++;
|
1908
1891
|
}
|
@@ -1913,7 +1896,7 @@ local block_state deflate_fast(s, flush)
|
|
1913
1896
|
FLUSH_BLOCK(s, 1);
|
1914
1897
|
return finish_done;
|
1915
1898
|
}
|
1916
|
-
if (s->
|
1899
|
+
if (s->sym_next)
|
1917
1900
|
FLUSH_BLOCK(s, 0);
|
1918
1901
|
return block_done;
|
1919
1902
|
}
|
@@ -1924,10 +1907,7 @@ local block_state deflate_fast(s, flush)
|
|
1924
1907
|
* evaluation for matches: a match is finally adopted only if there is
|
1925
1908
|
* no better match at the next window position.
|
1926
1909
|
*/
|
1927
|
-
local block_state deflate_slow(s, flush)
|
1928
|
-
deflate_state *s;
|
1929
|
-
int flush;
|
1930
|
-
{
|
1910
|
+
local block_state deflate_slow(deflate_state *s, int flush) {
|
1931
1911
|
IPos hash_head; /* head of hash chain */
|
1932
1912
|
int bflush; /* set if current block must be flushed */
|
1933
1913
|
|
@@ -1946,7 +1926,7 @@ local block_state deflate_slow(s, flush)
|
|
1946
1926
|
if (s->lookahead == 0) break; /* flush the current block */
|
1947
1927
|
}
|
1948
1928
|
|
1949
|
-
/* Insert the string window[strstart .. strstart+2] in the
|
1929
|
+
/* Insert the string window[strstart .. strstart + 2] in the
|
1950
1930
|
* dictionary, and set hash_head to the head of the hash chain:
|
1951
1931
|
*/
|
1952
1932
|
hash_head = NIL;
|
@@ -1988,17 +1968,17 @@ local block_state deflate_slow(s, flush)
|
|
1988
1968
|
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
|
1989
1969
|
/* Do not insert strings in hash table beyond this. */
|
1990
1970
|
|
1991
|
-
check_match(s, s->strstart-1, s->prev_match, s->prev_length);
|
1971
|
+
check_match(s, s->strstart - 1, s->prev_match, s->prev_length);
|
1992
1972
|
|
1993
|
-
_tr_tally_dist(s, s->strstart -1 - s->prev_match,
|
1973
|
+
_tr_tally_dist(s, s->strstart - 1 - s->prev_match,
|
1994
1974
|
s->prev_length - MIN_MATCH, bflush);
|
1995
1975
|
|
1996
1976
|
/* Insert in hash table all strings up to the end of the match.
|
1997
|
-
* strstart-1 and strstart are already inserted. If there is not
|
1977
|
+
* strstart - 1 and strstart are already inserted. If there is not
|
1998
1978
|
* enough lookahead, the last two strings are not inserted in
|
1999
1979
|
* the hash table.
|
2000
1980
|
*/
|
2001
|
-
s->lookahead -= s->prev_length-1;
|
1981
|
+
s->lookahead -= s->prev_length - 1;
|
2002
1982
|
s->prev_length -= 2;
|
2003
1983
|
do {
|
2004
1984
|
if (++s->strstart <= max_insert) {
|
@@ -2016,8 +1996,8 @@ local block_state deflate_slow(s, flush)
|
|
2016
1996
|
* single literal. If there was a match but the current match
|
2017
1997
|
* is longer, truncate the previous match to a single literal.
|
2018
1998
|
*/
|
2019
|
-
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
2020
|
-
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
1999
|
+
Tracevv((stderr,"%c", s->window[s->strstart - 1]));
|
2000
|
+
_tr_tally_lit(s, s->window[s->strstart - 1], bflush);
|
2021
2001
|
if (bflush) {
|
2022
2002
|
FLUSH_BLOCK_ONLY(s, 0);
|
2023
2003
|
}
|
@@ -2035,8 +2015,8 @@ local block_state deflate_slow(s, flush)
|
|
2035
2015
|
}
|
2036
2016
|
Assert (flush != Z_NO_FLUSH, "no flush?");
|
2037
2017
|
if (s->match_available) {
|
2038
|
-
Tracevv((stderr,"%c", s->window[s->strstart-1]));
|
2039
|
-
_tr_tally_lit(s, s->window[s->strstart-1], bflush);
|
2018
|
+
Tracevv((stderr,"%c", s->window[s->strstart - 1]));
|
2019
|
+
_tr_tally_lit(s, s->window[s->strstart - 1], bflush);
|
2040
2020
|
s->match_available = 0;
|
2041
2021
|
}
|
2042
2022
|
s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
|
@@ -2044,7 +2024,7 @@ local block_state deflate_slow(s, flush)
|
|
2044
2024
|
FLUSH_BLOCK(s, 1);
|
2045
2025
|
return finish_done;
|
2046
2026
|
}
|
2047
|
-
if (s->
|
2027
|
+
if (s->sym_next)
|
2048
2028
|
FLUSH_BLOCK(s, 0);
|
2049
2029
|
return block_done;
|
2050
2030
|
}
|
@@ -2055,10 +2035,7 @@ local block_state deflate_slow(s, flush)
|
|
2055
2035
|
* one. Do not maintain a hash table. (It will be regenerated if this run of
|
2056
2036
|
* deflate switches away from Z_RLE.)
|
2057
2037
|
*/
|
2058
|
-
local block_state deflate_rle(s, flush)
|
2059
|
-
deflate_state *s;
|
2060
|
-
int flush;
|
2061
|
-
{
|
2038
|
+
local block_state deflate_rle(deflate_state *s, int flush) {
|
2062
2039
|
int bflush; /* set if current block must be flushed */
|
2063
2040
|
uInt prev; /* byte at distance one to match */
|
2064
2041
|
Bytef *scan, *strend; /* scan goes up to strend for length of run */
|
@@ -2093,7 +2070,8 @@ local block_state deflate_rle(s, flush)
|
|
2093
2070
|
if (s->match_length > s->lookahead)
|
2094
2071
|
s->match_length = s->lookahead;
|
2095
2072
|
}
|
2096
|
-
Assert(scan <= s->window+(uInt)(s->window_size-1),
|
2073
|
+
Assert(scan <= s->window + (uInt)(s->window_size - 1),
|
2074
|
+
"wild scan");
|
2097
2075
|
}
|
2098
2076
|
|
2099
2077
|
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
|
@@ -2108,7 +2086,7 @@ local block_state deflate_rle(s, flush)
|
|
2108
2086
|
} else {
|
2109
2087
|
/* No match, output a literal byte */
|
2110
2088
|
Tracevv((stderr,"%c", s->window[s->strstart]));
|
2111
|
-
_tr_tally_lit
|
2089
|
+
_tr_tally_lit(s, s->window[s->strstart], bflush);
|
2112
2090
|
s->lookahead--;
|
2113
2091
|
s->strstart++;
|
2114
2092
|
}
|
@@ -2119,7 +2097,7 @@ local block_state deflate_rle(s, flush)
|
|
2119
2097
|
FLUSH_BLOCK(s, 1);
|
2120
2098
|
return finish_done;
|
2121
2099
|
}
|
2122
|
-
if (s->
|
2100
|
+
if (s->sym_next)
|
2123
2101
|
FLUSH_BLOCK(s, 0);
|
2124
2102
|
return block_done;
|
2125
2103
|
}
|
@@ -2128,10 +2106,7 @@ local block_state deflate_rle(s, flush)
|
|
2128
2106
|
* For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
|
2129
2107
|
* (It will be regenerated if this run of deflate switches away from Huffman.)
|
2130
2108
|
*/
|
2131
|
-
local block_state deflate_huff(s, flush)
|
2132
|
-
deflate_state *s;
|
2133
|
-
int flush;
|
2134
|
-
{
|
2109
|
+
local block_state deflate_huff(deflate_state *s, int flush) {
|
2135
2110
|
int bflush; /* set if current block must be flushed */
|
2136
2111
|
|
2137
2112
|
for (;;) {
|
@@ -2148,7 +2123,7 @@ local block_state deflate_huff(s, flush)
|
|
2148
2123
|
/* Output a literal byte */
|
2149
2124
|
s->match_length = 0;
|
2150
2125
|
Tracevv((stderr,"%c", s->window[s->strstart]));
|
2151
|
-
_tr_tally_lit
|
2126
|
+
_tr_tally_lit(s, s->window[s->strstart], bflush);
|
2152
2127
|
s->lookahead--;
|
2153
2128
|
s->strstart++;
|
2154
2129
|
if (bflush) FLUSH_BLOCK(s, 0);
|
@@ -2158,7 +2133,7 @@ local block_state deflate_huff(s, flush)
|
|
2158
2133
|
FLUSH_BLOCK(s, 1);
|
2159
2134
|
return finish_done;
|
2160
2135
|
}
|
2161
|
-
if (s->
|
2136
|
+
if (s->sym_next)
|
2162
2137
|
FLUSH_BLOCK(s, 0);
|
2163
2138
|
return block_done;
|
2164
2139
|
}
|