mirror of
				https://github.com/eledio-devices/thirdparty-miniz.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Merge branch 'master' of github.com:richgel999/miniz
This commit is contained in:
		| @@ -1,5 +1,11 @@ | |||||||
| cmake_minimum_required(VERSION 3.0) | cmake_minimum_required(VERSION 3.0) | ||||||
|  |  | ||||||
|  | # determine whether this is a standalone project or included by other projects | ||||||
|  | set (MINIZ_STANDALONE_PROJECT ON) | ||||||
|  | if(DEFINED PROJECT_NAME) | ||||||
|  |   set(MINIZ_STANDALONE_PROJECT OFF) | ||||||
|  | endif() | ||||||
|  |  | ||||||
| if(CMAKE_MINOR_VERSION LESS 12) | if(CMAKE_MINOR_VERSION LESS 12) | ||||||
|   project(miniz) |   project(miniz) | ||||||
|   # see issue https://gitlab.kitware.com/cmake/cmake/merge_requests/1799 |   # see issue https://gitlab.kitware.com/cmake/cmake/merge_requests/1799 | ||||||
| @@ -7,8 +13,6 @@ else() | |||||||
|   project(miniz C) |   project(miniz C) | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
| include(GNUInstallDirs) |  | ||||||
|  |  | ||||||
| set(MINIZ_API_VERSION 2) | set(MINIZ_API_VERSION 2) | ||||||
| set(MINIZ_MINOR_VERSION 1) | set(MINIZ_MINOR_VERSION 1) | ||||||
| set(MINIZ_PATCH_VERSION 0) | set(MINIZ_PATCH_VERSION 0) | ||||||
| @@ -23,14 +27,19 @@ if(CMAKE_BUILD_TYPE STREQUAL "") | |||||||
| CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) | CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) | ||||||
| endif () | endif () | ||||||
|  |  | ||||||
| option(BUILD_EXAMPLES "Build examples" ON) | option(BUILD_EXAMPLES "Build examples" ${MINIZ_STANDALONE_PROJECT}) | ||||||
| option(BUILD_FUZZERS "Build fuzz targets" OFF) | option(BUILD_FUZZERS "Build fuzz targets" OFF) | ||||||
| option(AMALGAMATE_SOURCES "Amalgamate sources into miniz.h/c" OFF) | option(AMALGAMATE_SOURCES "Amalgamate sources into miniz.h/c" OFF) | ||||||
| option(BUILD_HEADER_ONLY "Build a header-only version" OFF) | option(BUILD_HEADER_ONLY "Build a header-only version" OFF) | ||||||
| option(BUILD_SHARED_LIBS "Build shared library instead of static" ON) | option(BUILD_SHARED_LIBS "Build shared library instead of static" ON) | ||||||
|  | option(INSTALL_PROJECT "Install project" ${MINIZ_STANDALONE_PROJECT}) | ||||||
|  |  | ||||||
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) | ||||||
|  |  | ||||||
|  | if(INSTALL_PROJECT) | ||||||
|  |   include(GNUInstallDirs) | ||||||
|  | endif() | ||||||
|  |  | ||||||
| if(BUILD_HEADER_ONLY) | if(BUILD_HEADER_ONLY) | ||||||
|   set(AMALGAMATE_SOURCES ON CACHE BOOL "Build a header-only version" FORCE) |   set(AMALGAMATE_SOURCES ON CACHE BOOL "Build a header-only version" FORCE) | ||||||
| endif(BUILD_HEADER_ONLY) | endif(BUILD_HEADER_ONLY) | ||||||
| @@ -124,11 +133,13 @@ if(NOT BUILD_HEADER_ONLY) | |||||||
|     PRIVATE $<$<C_COMPILER_ID:GNU>:_GNU_SOURCE>) |     PRIVATE $<$<C_COMPILER_ID:GNU>:_GNU_SOURCE>) | ||||||
|  |  | ||||||
|   # pkg-config file |   # pkg-config file | ||||||
|   configure_file(miniz.pc.in ${CMAKE_BINARY_DIR}/miniz.pc @ONLY) |   configure_file(miniz.pc.in ${CMAKE_CURRENT_BINARY_DIR}/miniz.pc @ONLY) | ||||||
|  |  | ||||||
|  |   if(INSTALL_PROJECT) | ||||||
|     install(FILES |     install(FILES | ||||||
|     ${CMAKE_BINARY_DIR}/miniz.pc |       ${CMAKE_CURRENT_BINARY_DIR}/miniz.pc | ||||||
|       DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig) |       DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig) | ||||||
|  |   endif() | ||||||
| endif() | endif() | ||||||
|  |  | ||||||
| set_property(TARGET ${PROJECT_NAME} PROPERTY | set_property(TARGET ${PROJECT_NAME} PROPERTY | ||||||
| @@ -137,40 +148,41 @@ set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY | |||||||
|   COMPATIBLE_INTERFACE_STRING ${PROJECT_NAME}_MAJOR_VERSION |   COMPATIBLE_INTERFACE_STRING ${PROJECT_NAME}_MAJOR_VERSION | ||||||
| ) | ) | ||||||
|  |  | ||||||
| install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets | if(INSTALL_PROJECT) | ||||||
|  |   install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets | ||||||
|     RUNTIME  DESTINATION ${CMAKE_INSTALL_BINDIR} |     RUNTIME  DESTINATION ${CMAKE_INSTALL_BINDIR} | ||||||
|     ARCHIVE  DESTINATION ${CMAKE_INSTALL_LIBDIR} |     ARCHIVE  DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||
|     LIBRARY  DESTINATION ${CMAKE_INSTALL_LIBDIR} |     LIBRARY  DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||||||
|     # users can use <miniz.h> or <miniz/miniz.h> |     # users can use <miniz.h> or <miniz/miniz.h> | ||||||
|     INCLUDES DESTINATION include ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} |     INCLUDES DESTINATION include ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} | ||||||
| ) |   ) | ||||||
|  |  | ||||||
| include(CMakePackageConfigHelpers) |   include(CMakePackageConfigHelpers) | ||||||
| write_basic_package_version_file( |   write_basic_package_version_file( | ||||||
|     "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" |     "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" | ||||||
|     VERSION ${MINIZ_VERSION} |     VERSION ${MINIZ_VERSION} | ||||||
|     COMPATIBILITY AnyNewerVersion |     COMPATIBILITY AnyNewerVersion | ||||||
| ) |   ) | ||||||
|  |  | ||||||
| export(EXPORT ${PROJECT_NAME}Targets |   export(EXPORT ${PROJECT_NAME}Targets | ||||||
|     FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake" |     FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Targets.cmake" | ||||||
|     NAMESPACE ${PROJECT_NAME}:: |     NAMESPACE ${PROJECT_NAME}:: | ||||||
| ) |   ) | ||||||
| configure_file(Config.cmake.in |   configure_file(Config.cmake.in | ||||||
|     "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" |     "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" | ||||||
|     @ONLY |     @ONLY | ||||||
| ) |   ) | ||||||
|  |  | ||||||
| set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) |   set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) | ||||||
| install(EXPORT ${PROJECT_NAME}Targets |   install(EXPORT ${PROJECT_NAME}Targets | ||||||
|     FILE |     FILE | ||||||
|       ${PROJECT_NAME}Targets.cmake |       ${PROJECT_NAME}Targets.cmake | ||||||
|     NAMESPACE |     NAMESPACE | ||||||
|       ${PROJECT_NAME}:: |       ${PROJECT_NAME}:: | ||||||
|     DESTINATION |     DESTINATION | ||||||
|       ${ConfigPackageLocation} |       ${ConfigPackageLocation} | ||||||
| ) |   ) | ||||||
| install( |   install( | ||||||
|     FILES |     FILES | ||||||
|       "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" |       "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake" | ||||||
|       "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" |       "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}ConfigVersion.cmake" | ||||||
| @@ -178,7 +190,8 @@ install( | |||||||
|       ${ConfigPackageLocation} |       ${ConfigPackageLocation} | ||||||
|     COMPONENT |     COMPONENT | ||||||
|       Devel |       Devel | ||||||
| ) |   ) | ||||||
|  | endif() | ||||||
|  |  | ||||||
| if(BUILD_EXAMPLES) | if(BUILD_EXAMPLES) | ||||||
|   set(EXAMPLE1_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example1.c") |   set(EXAMPLE1_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example1.c") | ||||||
| @@ -250,6 +263,7 @@ endif() | |||||||
|  |  | ||||||
| set(INCLUDE_INSTALL_DIR "include") | set(INCLUDE_INSTALL_DIR "include") | ||||||
|  |  | ||||||
| install(FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) | if(INSTALL_PROJECT) | ||||||
|  |   install(FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}) | ||||||
|  | endif() | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,7 +82,7 @@ The inflator now has a new failure status TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRE | |||||||
| - The inflator coroutine func. is subtle and complex so I'm being cautious about this release. I would greatly appreciate any help with testing or any feedback. | - The inflator coroutine func. is subtle and complex so I'm being cautious about this release. I would greatly appreciate any help with testing or any feedback. | ||||||
|          I feel good about these changes, and they've been through several hours of automated testing, but they will probably not fix anything for the majority of prev. users so I'm |          I feel good about these changes, and they've been through several hours of automated testing, but they will probably not fix anything for the majority of prev. users so I'm | ||||||
|          going to mark this release as beta for a few weeks and continue testing it at work/home on various things. |          going to mark this release as beta for a few weeks and continue testing it at work/home on various things. | ||||||
| - The inflator in raw (non-zlib) mode is now usable on gzip or similiar data streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). | - The inflator in raw (non-zlib) mode is now usable on gzip or similar data streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). | ||||||
|          This version should *never* read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. This issue was caused by the various Huffman bitbuffer lookahead optimizations, and |          This version should *never* read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. This issue was caused by the various Huffman bitbuffer lookahead optimizations, and | ||||||
|          would not be an issue if the caller knew and enforced the precise size of the raw compressed data *or* if the compressed data was in zlib format (i.e. always followed by the byte aligned zlib adler32). |          would not be an issue if the caller knew and enforced the precise size of the raw compressed data *or* if the compressed data was in zlib format (i.e. always followed by the byte aligned zlib adler32). | ||||||
|          So in other words, you can now call the inflator on deflate streams that are followed by arbitrary amounts of data and it's guaranteed that decompression will stop exactly on the last byte. |          So in other words, you can now call the inflator on deflate streams that are followed by arbitrary amounts of data and it's guaranteed that decompression will stop exactly on the last byte. | ||||||
|   | |||||||
| @@ -1074,8 +1074,6 @@ static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match | |||||||
|     s0 = s_tdefl_small_dist_sym[match_dist & 511]; |     s0 = s_tdefl_small_dist_sym[match_dist & 511]; | ||||||
|     s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; |     s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127]; | ||||||
|     d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; |     d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++; | ||||||
|  |  | ||||||
|     if (match_len >= TDEFL_MIN_MATCH_LEN) |  | ||||||
|     d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; |     d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -1333,6 +1331,7 @@ tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_fun | |||||||
|     d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0; |     d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0; | ||||||
|     d->m_pLZ_code_buf = d->m_lz_code_buf + 1; |     d->m_pLZ_code_buf = d->m_lz_code_buf + 1; | ||||||
|     d->m_pLZ_flags = d->m_lz_code_buf; |     d->m_pLZ_flags = d->m_lz_code_buf; | ||||||
|  |     *d->m_pLZ_flags = 0; | ||||||
|     d->m_num_flags_left = 8; |     d->m_num_flags_left = 8; | ||||||
|     d->m_pOutput_buf = d->m_output_buf; |     d->m_pOutput_buf = d->m_output_buf; | ||||||
|     d->m_pOutput_buf_end = d->m_output_buf; |     d->m_pOutput_buf_end = d->m_output_buf; | ||||||
|   | |||||||
| @@ -31,4 +31,4 @@ Thanks to Bruce Dawson for reporting a problem with the level_and_flags archive | |||||||
|  |  | ||||||
| ## Patents | ## Patents | ||||||
|  |  | ||||||
| I was recently asked if miniz avoids patent issues. miniz purposely uses the same core algorithms as the ones used by zlib. The compressor uses vanilla hash chaining as described [here](http://www.gzip.org/zlib/rfc-deflate.html#algorithm). Also see the [gzip FAQ](http://www.gzip.org/#faq11). In my opinion, if miniz falls prey to a patent attack then zlib/gzip are likely to be at serious risk too. | I was recently asked if miniz avoids patent issues. miniz purposely uses the same core algorithms as the ones used by zlib. The compressor uses vanilla hash chaining as described [here](https://datatracker.ietf.org/doc/html/rfc1951#section-4). Also see the [gzip FAQ](https://web.archive.org/web/20160308045258/http://www.gzip.org/#faq11). In my opinion, if miniz falls prey to a patent attack then zlib/gzip are likely to be at serious risk too. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user