summaryrefslogtreecommitdiffstats
path: root/zlib
diff options
context:
space:
mode:
authorMatthias Klose <doko@ubuntu.com>2012-11-16 18:35:05 +0000
committerMatthias Klose <doko@gcc.gnu.org>2012-11-16 18:35:05 +0000
commit9acb8ddf3e7cf312de229eae11e0a1df29548ec9 (patch)
tree134aeb9aadb88e8719595edaaa40522b99d2a56a /zlib
parentwhatis.cc: New file. (diff)
downloadgcc-9acb8ddf3e7cf312de229eae11e0a1df29548ec9.tar.gz
gcc-9acb8ddf3e7cf312de229eae11e0a1df29548ec9.tar.bz2
gcc-9acb8ddf3e7cf312de229eae11e0a1df29548ec9.tar.xz
2012-11-16 Matthias Klose <doko@ubuntu.com>
* Imported zlib 1.2.7; merged local changes. From-SVN: r193574
Diffstat (limited to 'zlib')
-rw-r--r--zlib/CMakeLists.txt75
-rw-r--r--zlib/ChangeLog203
-rw-r--r--zlib/ChangeLog.gcj4
-rw-r--r--zlib/FAQ12
-rw-r--r--zlib/INDEX13
-rw-r--r--zlib/README24
-rw-r--r--zlib/adler32.c68
-rw-r--r--zlib/as400/bndsrc (renamed from zlib/old/as400/bndsrc)73
-rw-r--r--zlib/as400/compile.clp110
-rw-r--r--zlib/as400/readme.txt (renamed from zlib/old/as400/readme.txt)14
-rw-r--r--zlib/as400/zlib.inc (renamed from zlib/old/as400/zlib.inc)154
-rw-r--r--zlib/contrib/asm686/match.S16
-rw-r--r--zlib/contrib/delphi/ZLib.pas2
-rw-r--r--zlib/contrib/delphi/zlibd32.mak4
-rw-r--r--zlib/contrib/dotzlib/DotZLib/UnitTests.cs2
-rw-r--r--zlib/contrib/infback9/inftree9.c6
-rw-r--r--zlib/contrib/masmx86/inffas32.asm9
-rw-r--r--zlib/contrib/masmx86/match686.asm1
-rw-r--r--zlib/contrib/minizip/Makefile.am45
-rw-r--r--zlib/contrib/minizip/configure.ac32
-rw-r--r--zlib/contrib/minizip/ioapi.c22
-rw-r--r--zlib/contrib/minizip/ioapi.h10
-rw-r--r--zlib/contrib/minizip/miniunz.c38
-rw-r--r--zlib/contrib/minizip/minizip.c39
-rw-r--r--zlib/contrib/minizip/minizip.pc.in12
-rw-r--r--zlib/contrib/minizip/mztools.c24
-rw-r--r--zlib/contrib/minizip/mztools.h6
-rw-r--r--zlib/contrib/minizip/unzip.c12
-rw-r--r--zlib/contrib/minizip/zip.c13
-rw-r--r--zlib/contrib/pascal/zlibd32.mak4
-rw-r--r--zlib/contrib/pascal/zlibpas.pas42
-rw-r--r--zlib/contrib/puff/Makefile40
-rw-r--r--zlib/contrib/puff/puff.c252
-rw-r--r--zlib/contrib/puff/puff.h8
-rw-r--r--zlib/contrib/puff/pufftest.c165
-rw-r--r--zlib/contrib/vstudio/readme.txt14
-rw-r--r--zlib/contrib/vstudio/vc10/testzlibdll.vcxproj12
-rw-r--r--zlib/contrib/vstudio/vc10/zlib.rc8
-rw-r--r--zlib/contrib/vstudio/vc10/zlibvc.def11
-rw-r--r--zlib/contrib/vstudio/vc10/zlibvc.vcxproj22
-rw-r--r--zlib/contrib/vstudio/vc9/zlib.rc8
-rw-r--r--zlib/contrib/vstudio/vc9/zlibvc.def11
-rw-r--r--zlib/crc32.c83
-rw-r--r--zlib/crc32.h2
-rw-r--r--zlib/deflate.c259
-rw-r--r--zlib/deflate.h10
-rw-r--r--zlib/doc/algorithm.txt2
-rw-r--r--zlib/gzguts.h87
-rw-r--r--zlib/gzlib.c165
-rw-r--r--zlib/gzread.c418
-rw-r--r--zlib/gzwrite.c146
-rw-r--r--zlib/infback.c14
-rw-r--r--zlib/inffixed.h6
-rw-r--r--zlib/inflate.c90
-rw-r--r--zlib/inftrees.c46
-rw-r--r--zlib/make_vms.com403
-rw-r--r--zlib/msdos/Makefile.bor4
-rw-r--r--zlib/msdos/Makefile.msc4
-rw-r--r--zlib/msdos/Makefile.tc4
-rw-r--r--zlib/old/Makefile.emx (renamed from zlib/win32/Makefile.emx)0
-rw-r--r--zlib/old/as400/compile.clp123
-rw-r--r--zlib/old/visualc6/README.txt73
-rw-r--r--zlib/old/visualc6/example.dsp278
-rw-r--r--zlib/old/visualc6/minigzip.dsp278
-rw-r--r--zlib/old/visualc6/zlib.dsp621
-rw-r--r--zlib/old/visualc6/zlib.dsw59
-rw-r--r--zlib/qnx/package.qpg10
-rw-r--r--zlib/test/example.c601
-rw-r--r--zlib/test/infcover.c671
-rw-r--r--zlib/test/minigzip.c631
-rw-r--r--zlib/treebuild.xml4
-rw-r--r--zlib/trees.c40
-rw-r--r--zlib/win32/Makefile.bor4
-rw-r--r--zlib/win32/Makefile.gcc72
-rw-r--r--zlib/win32/Makefile.msc13
-rw-r--r--zlib/win32/README-WIN32.txt8
-rw-r--r--zlib/win32/zlib.def14
-rw-r--r--zlib/zconf.h196
-rw-r--r--zlib/zconf.h.cmakein196
-rw-r--r--zlib/zconf.h.in196
-rw-r--r--zlib/zlib.318
-rw-r--r--zlib/zlib.h309
-rw-r--r--zlib/zlib.map10
-rw-r--r--zlib/zlib.pc.cmakein13
-rw-r--r--zlib/zutil.c24
-rw-r--r--zlib/zutil.h98
86 files changed, 4982 insertions, 2961 deletions
diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt
index a64fe0b2cae..7ee3bc41bc9 100644
--- a/zlib/CMakeLists.txt
+++ b/zlib/CMakeLists.txt
@@ -3,9 +3,13 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
3 3
4project(zlib C) 4project(zlib C)
5 5
6if(NOT DEFINED BUILD_SHARED_LIBS) 6set(VERSION "1.2.7")
7 option(BUILD_SHARED_LIBS "Build a shared library form of zlib" ON) 7
8endif() 8set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
9set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
10set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
11set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
12set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
9 13
10include(CheckTypeSize) 14include(CheckTypeSize)
11include(CheckFunctionExists) 15include(CheckFunctionExists)
@@ -56,23 +60,27 @@ if(MSVC)
56 set(CMAKE_DEBUG_POSTFIX "d") 60 set(CMAKE_DEBUG_POSTFIX "d")
57 add_definitions(-D_CRT_SECURE_NO_DEPRECATE) 61 add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
58 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) 62 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
63 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
59endif() 64endif()
60 65
61if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) 66if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
62 # If we're doing an out of source build and the user has a zconf.h 67 # If we're doing an out of source build and the user has a zconf.h
63 # in their source tree... 68 # in their source tree...
64 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) 69 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
65 message(FATAL_ERROR 70 message(STATUS "Renaming")
66 "You must remove ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h " 71 message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
67 "from the source tree. This file is included with zlib " 72 message(STATUS "to 'zconf.h.included' because this file is included with zlib")
68 "but CMake generates this file for you automatically " 73 message(STATUS "but CMake generates it automatically in the build directory.")
69 "in the build directory.") 74 file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
70 endif() 75 endif()
71endif() 76endif()
72 77
73configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein 78set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
74 ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) 79configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
75include_directories(${CMAKE_CURRENT_BINARY_DIR}) 80 ${ZLIB_PC} @ONLY)
81configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
82 ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
83include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
76 84
77 85
78#============================================================================ 86#============================================================================
@@ -110,18 +118,27 @@ set(ZLIB_SRCS
110 trees.c 118 trees.c
111 uncompr.c 119 uncompr.c
112 zutil.c 120 zutil.c
113 win32/zlib1.rc
114) 121)
115 122
123if(NOT MINGW)
124 set(ZLIB_SRCS ${ZLIB_SRCS}
125 win32/zlib1.rc # If present will override custom build rule below.
126 )
127endif()
128
116# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION 129# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
117file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) 130file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
118string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9A-Za-z.]+)\".*" 131string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
119 "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) 132 "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
120 133
121if(MINGW) 134if(MINGW)
122 # This gets us DLL resource information when compiling on MinGW. 135 # This gets us DLL resource information when compiling on MinGW.
136 if(NOT CMAKE_RC_COMPILER)
137 SET(CMAKE_RC_COMPILER windres.exe)
138 endif()
139
123 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj 140 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
124 COMMAND windres.exe 141 COMMAND ${CMAKE_RC_COMPILER}
125 -D GCC_WINDRES 142 -D GCC_WINDRES
126 -I ${CMAKE_CURRENT_SOURCE_DIR} 143 -I ${CMAKE_CURRENT_SOURCE_DIR}
127 -I ${CMAKE_CURRENT_BINARY_DIR} 144 -I ${CMAKE_CURRENT_BINARY_DIR}
@@ -130,9 +147,9 @@ if(MINGW)
130 set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) 147 set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
131endif(MINGW) 148endif(MINGW)
132 149
133add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 150add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
151add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
134set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) 152set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
135
136set_target_properties(zlib PROPERTIES SOVERSION 1) 153set_target_properties(zlib PROPERTIES SOVERSION 1)
137 154
138if(NOT CYGWIN) 155if(NOT CYGWIN)
@@ -148,43 +165,47 @@ endif()
148 165
149if(UNIX) 166if(UNIX)
150 # On unix-like platforms the library is almost always called libz 167 # On unix-like platforms the library is almost always called libz
151 set_target_properties(zlib PROPERTIES OUTPUT_NAME z) 168 set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
169 set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/zlib.map")
152elseif(BUILD_SHARED_LIBS AND WIN32) 170elseif(BUILD_SHARED_LIBS AND WIN32)
153 # Creates zlib1.dll when building shared library version 171 # Creates zlib1.dll when building shared library version
154 set_target_properties(zlib PROPERTIES SUFFIX "1.dll") 172 set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
155endif() 173endif()
156 174
157if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) 175if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
158 install(TARGETS zlib 176 install(TARGETS zlib zlibstatic
159 RUNTIME DESTINATION bin 177 RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
160 ARCHIVE DESTINATION lib 178 ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
161 LIBRARY DESTINATION lib ) 179 LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
162endif() 180endif()
163if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) 181if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
164 install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include) 182 install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
183endif()
184if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
185 install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
165endif() 186endif()
166if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) 187if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
167 install(FILES zlib.3 DESTINATION share/man/man3) 188 install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
168endif() 189endif()
169 190
170#============================================================================ 191#============================================================================
171# Example binaries 192# Example binaries
172#============================================================================ 193#============================================================================
173 194
174add_executable(example example.c) 195add_executable(example test/example.c)
175target_link_libraries(example zlib) 196target_link_libraries(example zlib)
176add_test(example example) 197add_test(example example)
177 198
178add_executable(minigzip minigzip.c) 199add_executable(minigzip test/minigzip.c)
179target_link_libraries(minigzip zlib) 200target_link_libraries(minigzip zlib)
180 201
181if(HAVE_OFF64_T) 202if(HAVE_OFF64_T)
182 add_executable(example64 example.c) 203 add_executable(example64 test/example.c)
183 target_link_libraries(example64 zlib) 204 target_link_libraries(example64 zlib)
184 set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") 205 set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
185 add_test(example64 example64) 206 add_test(example64 example64)
186 207
187 add_executable(minigzip64 minigzip.c) 208 add_executable(minigzip64 test/minigzip.c)
188 target_link_libraries(minigzip64 zlib) 209 target_link_libraries(minigzip64 zlib)
189 set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") 210 set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
190endif() 211endif()
diff --git a/zlib/ChangeLog b/zlib/ChangeLog
index fd4cae655e3..d9b5030e35f 100644
--- a/zlib/ChangeLog
+++ b/zlib/ChangeLog
@@ -1,12 +1,213 @@
1 1
2 ChangeLog file for zlib 2 ChangeLog file for zlib
3 3
4Changes in 1.2.7 (2 May 2012)
5- Replace use of memmove() with a simple copy for portability
6- Test for existence of strerror
7- Restore gzgetc_ for backward compatibility with 1.2.6
8- Fix build with non-GNU make on Solaris
9- Require gcc 4.0 or later on Mac OS X to use the hidden attribute
10- Include unistd.h for Watcom C
11- Use __WATCOMC__ instead of __WATCOM__
12- Do not use the visibility attribute if NO_VIZ defined
13- Improve the detection of no hidden visibility attribute
14- Avoid using __int64 for gcc or solo compilation
15- Cast to char * in gzprintf to avoid warnings [Zinser]
16- Fix make_vms.com for VAX [Zinser]
17- Don't use library or built-in byte swaps
18- Simplify test and use of gcc hidden attribute
19- Fix bug in gzclose_w() when gzwrite() fails to allocate memory
20- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen()
21- Fix bug in test/minigzip.c for configure --solo
22- Fix contrib/vstudio project link errors [Mohanathas]
23- Add ability to choose the builder in make_vms.com [Schweda]
24- Add DESTDIR support to mingw32 win32/Makefile.gcc
25- Fix comments in win32/Makefile.gcc for proper usage
26- Allow overriding the default install locations for cmake
27- Generate and install the pkg-config file with cmake
28- Build both a static and a shared version of zlib with cmake
29- Include version symbols for cmake builds
30- If using cmake with MSVC, add the source directory to the includes
31- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta]
32- Move obsolete emx makefile to old [Truta]
33- Allow the use of -Wundef when compiling or using zlib
34- Avoid the use of the -u option with mktemp
35- Improve inflate() documentation on the use of Z_FINISH
36- Recognize clang as gcc
37- Add gzopen_w() in Windows for wide character path names
38- Rename zconf.h in CMakeLists.txt to move it out of the way
39- Add source directory in CMakeLists.txt for building examples
40- Look in build directory for zlib.pc in CMakeLists.txt
41- Remove gzflags from zlibvc.def in vc9 and vc10
42- Fix contrib/minizip compilation in the MinGW environment
43- Update ./configure for Solaris, support --64 [Mooney]
44- Remove -R. from Solaris shared build (possible security issue)
45- Avoid race condition for parallel make (-j) running example
46- Fix type mismatch between get_crc_table() and crc_table
47- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler]
48- Fix the path to zlib.map in CMakeLists.txt
49- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe]
50- Add instructions to win32/Makefile.gcc for shared install [Torri]
51
52Changes in 1.2.6.1 (12 Feb 2012)
53- Avoid the use of the Objective-C reserved name "id"
54- Include io.h in gzguts.h for Microsoft compilers
55- Fix problem with ./configure --prefix and gzgetc macro
56- Include gz_header definition when compiling zlib solo
57- Put gzflags() functionality back in zutil.c
58- Avoid library header include in crc32.c for Z_SOLO
59- Use name in GCC_CLASSIC as C compiler for coverage testing, if set
60- Minor cleanup in contrib/minizip/zip.c [Vollant]
61- Update make_vms.com [Zinser]
62- Remove unnecessary gzgetc_ function
63- Use optimized byte swap operations for Microsoft and GNU [Snyder]
64- Fix minor typo in zlib.h comments [Rzesniowiecki]
65
66Changes in 1.2.6 (29 Jan 2012)
67- Update the Pascal interface in contrib/pascal
68- Fix function numbers for gzgetc_ in zlibvc.def files
69- Fix configure.ac for contrib/minizip [Schiffer]
70- Fix large-entry detection in minizip on 64-bit systems [Schiffer]
71- Have ./configure use the compiler return code for error indication
72- Fix CMakeLists.txt for cross compilation [McClure]
73- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes]
74- Fix compilation of contrib/minizip on FreeBSD [Marquez]
75- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath]
76- Include io.h for Turbo C / Borland C on all platforms [Truta]
77- Make version explicit in contrib/minizip/configure.ac [Bosmans]
78- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant]
79- Minor cleanup up contrib/minizip/unzip.c [Vollant]
80- Fix bug when compiling minizip with C++ [Vollant]
81- Protect for long name and extra fields in contrib/minizip [Vollant]
82- Avoid some warnings in contrib/minizip [Vollant]
83- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip
84- Add missing libs to minizip linker command
85- Add support for VPATH builds in contrib/minizip
86- Add an --enable-demos option to contrib/minizip/configure
87- Add the generation of configure.log by ./configure
88- Exit when required parameters not provided to win32/Makefile.gcc
89- Have gzputc return the character written instead of the argument
90- Use the -m option on ldconfig for BSD systems [Tobias]
91- Correct in zlib.map when deflateResetKeep was added
92
93Changes in 1.2.5.3 (15 Jan 2012)
94- Restore gzgetc function for binary compatibility
95- Do not use _lseeki64 under Borland C++ [Truta]
96- Update win32/Makefile.msc to build test/*.c [Truta]
97- Remove old/visualc6 given CMakefile and other alternatives
98- Update AS400 build files and documentation [Monnerat]
99- Update win32/Makefile.gcc to build test/*.c [Truta]
100- Permit stronger flushes after Z_BLOCK flushes
101- Avoid extraneous empty blocks when doing empty flushes
102- Permit Z_NULL arguments to deflatePending
103- Allow deflatePrime() to insert bits in the middle of a stream
104- Remove second empty static block for Z_PARTIAL_FLUSH
105- Write out all of the available bits when using Z_BLOCK
106- Insert the first two strings in the hash table after a flush
107
108Changes in 1.2.5.2 (17 Dec 2011)
109- fix ld error: unable to find version dependency 'ZLIB_1.2.5'
110- use relative symlinks for shared libs
111- Avoid searching past window for Z_RLE strategy
112- Assure that high-water mark initialization is always applied in deflate
113- Add assertions to fill_window() in deflate.c to match comments
114- Update python link in README
115- Correct spelling error in gzread.c
116- Fix bug in gzgets() for a concatenated empty gzip stream
117- Correct error in comment for gz_make()
118- Change gzread() and related to ignore junk after gzip streams
119- Allow gzread() and related to continue after gzclearerr()
120- Allow gzrewind() and gzseek() after a premature end-of-file
121- Simplify gzseek() now that raw after gzip is ignored
122- Change gzgetc() to a macro for speed (~40% speedup in testing)
123- Fix gzclose() to return the actual error last encountered
124- Always add large file support for windows
125- Include zconf.h for windows large file support
126- Include zconf.h.cmakein for windows large file support
127- Update zconf.h.cmakein on make distclean
128- Merge vestigial vsnprintf determination from zutil.h to gzguts.h
129- Clarify how gzopen() appends in zlib.h comments
130- Correct documentation of gzdirect() since junk at end now ignored
131- Add a transparent write mode to gzopen() when 'T' is in the mode
132- Update python link in zlib man page
133- Get inffixed.h and MAKEFIXED result to match
134- Add a ./config --solo option to make zlib subset with no libary use
135- Add undocumented inflateResetKeep() function for CAB file decoding
136- Add --cover option to ./configure for gcc coverage testing
137- Add #define ZLIB_CONST option to use const in the z_stream interface
138- Add comment to gzdopen() in zlib.h to use dup() when using fileno()
139- Note behavior of uncompress() to provide as much data as it can
140- Add files in contrib/minizip to aid in building libminizip
141- Split off AR options in Makefile.in and configure
142- Change ON macro to Z_ARG to avoid application conflicts
143- Facilitate compilation with Borland C++ for pragmas and vsnprintf
144- Include io.h for Turbo C / Borland C++
145- Move example.c and minigzip.c to test/
146- Simplify incomplete code table filling in inflate_table()
147- Remove code from inflate.c and infback.c that is impossible to execute
148- Test the inflate code with full coverage
149- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw)
150- Add deflateResetKeep and fix inflateResetKeep to retain dictionary
151- Fix gzwrite.c to accommodate reduced memory zlib compilation
152- Have inflate() with Z_FINISH avoid the allocation of a window
153- Do not set strm->adler when doing raw inflate
154- Fix gzeof() to behave just like feof() when read is not past end of file
155- Fix bug in gzread.c when end-of-file is reached
156- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF
157- Document gzread() capability to read concurrently written files
158- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo]
159
160Changes in 1.2.5.1 (10 Sep 2011)
161- Update FAQ entry on shared builds (#13)
162- Avoid symbolic argument to chmod in Makefile.in
163- Fix bug and add consts in contrib/puff [Oberhumer]
164- Update contrib/puff/zeros.raw test file to have all block types
165- Add full coverage test for puff in contrib/puff/Makefile
166- Fix static-only-build install in Makefile.in
167- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno]
168- Add libz.a dependency to shared in Makefile.in for parallel builds
169- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out
170- Replace $(...) with `...` in configure for non-bash sh [Bowler]
171- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen]
172- Add solaris* to Linux* in configure to allow gcc use [Groffen]
173- Add *bsd* to Linux* case in configure [Bar-Lev]
174- Add inffast.obj to dependencies in win32/Makefile.msc
175- Correct spelling error in deflate.h [Kohler]
176- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc
177- Add test to configure for GNU C looking for gcc in output of $cc -v
178- Add zlib.pc generation to win32/Makefile.gcc [Weigelt]
179- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not
180- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense
181- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser)
182- Make stronger test in zconf.h to include unistd.h for LFS
183- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack]
184- Fix zlib.h LFS support when Z_PREFIX used
185- Add updated as400 support (removed from old) [Monnerat]
186- Avoid deflate sensitivity to volatile input data
187- Avoid division in adler32_combine for NO_DIVIDE
188- Clarify the use of Z_FINISH with deflateBound() amount of space
189- Set binary for output file in puff.c
190- Use u4 type for crc_table to avoid conversion warnings
191- Apply casts in zlib.h to avoid conversion warnings
192- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller]
193- Improve inflateSync() documentation to note indeterminancy
194- Add deflatePending() function to return the amount of pending output
195- Correct the spelling of "specification" in FAQ [Randers-Pehrson]
196- Add a check in configure for stdarg.h, use for gzprintf()
197- Check that pointers fit in ints when gzprint() compiled old style
198- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler]
199- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt]
200- Add debug records in assmebler code [Londer]
201- Update RFC references to use http://tools.ietf.org/html/... [Li]
202- Add --archs option, use of libtool to configure for Mac OS X [Borstel]
203
4Changes in 1.2.5 (19 Apr 2010) 204Changes in 1.2.5 (19 Apr 2010)
5- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] 205- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev]
6- Default to libdir as sharedlibdir in configure [Nieder] 206- Default to libdir as sharedlibdir in configure [Nieder]
7- Update copyright dates on modified source files 207- Update copyright dates on modified source files
8- Update trees.c to be able to generate modified trees.h 208- Update trees.c to be able to generate modified trees.h
9- Exit configure for MinGW, suggesting win32/Makefile.gcc 209- Exit configure for MinGW, suggesting win32/Makefile.gcc
210- Check for NULL path in gz_open [Homurlu]
10 211
11Changes in 1.2.4.5 (18 Apr 2010) 212Changes in 1.2.4.5 (18 Apr 2010)
12- Set sharedlibdir in configure [Torok] 213- Set sharedlibdir in configure [Torok]
@@ -261,7 +462,7 @@ Changes in 1.2.3.4 (21 Dec 2009)
261- Clear bytes after deflate lookahead to avoid use of uninitialized data 462- Clear bytes after deflate lookahead to avoid use of uninitialized data
262- Change a limit in inftrees.c to be more transparent to Coverity Prevent 463- Change a limit in inftrees.c to be more transparent to Coverity Prevent
263- Update win32/zlib.def with exported symbols from zlib.h 464- Update win32/zlib.def with exported symbols from zlib.h
264- Correct spelling error in zlib.h [Willem] 465- Correct spelling errors in zlib.h [Willem, Sobrado]
265- Allow Z_BLOCK for deflate() to force a new block 466- Allow Z_BLOCK for deflate() to force a new block
266- Allow negative bits in inflatePrime() to delete existing bit buffer 467- Allow negative bits in inflatePrime() to delete existing bit buffer
267- Add Z_TREES flush option to inflate() to return at end of trees 468- Add Z_TREES flush option to inflate() to return at end of trees
diff --git a/zlib/ChangeLog.gcj b/zlib/ChangeLog.gcj
index 74e6155f539..13b62a4a129 100644
--- a/zlib/ChangeLog.gcj
+++ b/zlib/ChangeLog.gcj
@@ -1,3 +1,7 @@
12012-11-16 Matthias Klose <doko@ubuntu.com>
2
3 * Imported zlib 1.2.7; merged local changes.
4
12012-09-14 David Edelsohn <dje.gcc@gmail.com> 52012-09-14 David Edelsohn <dje.gcc@gmail.com>
2 6
3 * configure: Regenerated. 7 * configure: Regenerated.
diff --git a/zlib/FAQ b/zlib/FAQ
index 1a22750a58e..99b7cf92e45 100644
--- a/zlib/FAQ
+++ b/zlib/FAQ
@@ -44,8 +44,8 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
44 44
45 6. Where's the zlib documentation (man pages, etc.)? 45 6. Where's the zlib documentation (man pages, etc.)?
46 46
47 It's in zlib.h . Examples of zlib usage are in the files example.c and 47 It's in zlib.h . Examples of zlib usage are in the files test/example.c
48 minigzip.c, with more in examples/ . 48 and test/minigzip.c, with more in examples/ .
49 49
50 7. Why don't you use GNU autoconf or libtool or ...? 50 7. Why don't you use GNU autoconf or libtool or ...?
51 51
@@ -84,8 +84,10 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
84 84
8513. How can I make a Unix shared library? 8513. How can I make a Unix shared library?
86 86
87 make clean 87 By default a shared (and a static) library is built for Unix. So:
88 ./configure -s 88
89 make distclean
90 ./configure
89 make 91 make
90 92
9114. How do I install a shared zlib library on Unix? 9314. How do I install a shared zlib library on Unix?
@@ -325,7 +327,7 @@ The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
325 correctly points to the zlib specification in RFC 1950 for the "deflate" 327 correctly points to the zlib specification in RFC 1950 for the "deflate"
326 transfer encoding, there have been reports of servers and browsers that 328 transfer encoding, there have been reports of servers and browsers that
327 incorrectly produce or expect raw deflate data per the deflate 329 incorrectly produce or expect raw deflate data per the deflate
328 specficiation in RFC 1951, most notably Microsoft. So even though the 330 specification in RFC 1951, most notably Microsoft. So even though the
329 "deflate" transfer encoding using the zlib format would be the more 331 "deflate" transfer encoding using the zlib format would be the more
330 efficient approach (and in fact exactly what the zlib format was designed 332 efficient approach (and in fact exactly what the zlib format was designed
331 for), using the "gzip" transfer encoding is probably more reliable due to 333 for), using the "gzip" transfer encoding is probably more reliable due to
diff --git a/zlib/INDEX b/zlib/INDEX
index f6c51ca1759..2ba06412048 100644
--- a/zlib/INDEX
+++ b/zlib/INDEX
@@ -7,6 +7,9 @@ Makefile.in template for Unix Makefile
7README guess what 7README guess what
8configure configure script for Unix 8configure configure script for Unix
9make_vms.com makefile for VMS 9make_vms.com makefile for VMS
10test/example.c zlib usages examples for build testing
11test/minigzip.c minimal gzip-like functionality for build testing
12test/infcover.c inf*.c code coverage for build coverage testing
10treebuild.xml XML description of source file dependencies 13treebuild.xml XML description of source file dependencies
11zconf.h.cmakein zconf.h template for cmake 14zconf.h.cmakein zconf.h template for cmake
12zconf.h.in zconf.h template for configure 15zconf.h.in zconf.h template for configure
@@ -14,9 +17,11 @@ zlib.3 Man page for zlib
14zlib.3.pdf Man page in PDF format 17zlib.3.pdf Man page in PDF format
15zlib.map Linux symbol information 18zlib.map Linux symbol information
16zlib.pc.in Template for pkg-config descriptor 19zlib.pc.in Template for pkg-config descriptor
20zlib.pc.cmakein zlib.pc template for cmake
17zlib2ansi perl script to convert source files for C++ compilation 21zlib2ansi perl script to convert source files for C++ compilation
18 22
19amiga/ makefiles for Amiga SAS C 23amiga/ makefiles for Amiga SAS C
24as400/ makefiles for AS/400
20doc/ documentation for formats and algorithms 25doc/ documentation for formats and algorithms
21msdos/ makefiles for MSDOS 26msdos/ makefiles for MSDOS
22nintendods/ makefile for Nintendo DS 27nintendods/ makefile for Nintendo DS
@@ -56,10 +61,8 @@ uncompr.c
56zutil.c 61zutil.c
57zutil.h 62zutil.h
58 63
59 source files for sample programs: 64 source files for sample programs
60example.c 65See examples/README.examples
61minigzip.c
62See examples/README.examples for more
63 66
64 unsupported contribution by third parties 67 unsupported contributions by third parties
65See contrib/README.contrib 68See contrib/README.contrib
diff --git a/zlib/README b/zlib/README
index 2070218cf1e..7e50f1983a6 100644
--- a/zlib/README
+++ b/zlib/README
@@ -3,23 +3,23 @@ shipped with GCC as convenience.
3 3
4ZLIB DATA COMPRESSION LIBRARY 4ZLIB DATA COMPRESSION LIBRARY
5 5
6zlib 1.2.5 is a general purpose data compression library. All the code is 6zlib 1.2.7 is a general purpose data compression library. All the code is
7thread safe. The data format used by the zlib library is described by RFCs 7thread safe. The data format used by the zlib library is described by RFCs
8(Request for Comments) 1950 to 1952 in the files 8(Request for Comments) 1950 to 1952 in the files
9http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) 9http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
10and rfc1952.txt (gzip format). 10rfc1952 (gzip format).
11 11
12All functions of the compression library are documented in the file zlib.h 12All functions of the compression library are documented in the file zlib.h
13(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example 13(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
14of the library is given in the file example.c which also tests that the library 14of the library is given in the file test/example.c which also tests that
15is working correctly. Another example is given in the file minigzip.c. The 15the library is working correctly. Another example is given in the file
16compression library itself is composed of all source files except example.c and 16test/minigzip.c. The compression library itself is composed of all source
17minigzip.c. 17files in the root directory.
18 18
19To compile all files and run the test program, follow the instructions given at 19To compile all files and run the test program, follow the instructions given at
20the top of Makefile.in. In short "./configure; make test", and if that goes 20the top of Makefile.in. In short "./configure; make test", and if that goes
21well, "make install" should work for most flavors of Unix. For Windows, use one 21well, "make install" should work for most flavors of Unix. For Windows, use
22of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use 22one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
23make_vms.com. 23make_vms.com.
24 24
25Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant 25Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
@@ -34,7 +34,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
34issue of Dr. Dobb's Journal; a copy of the article is available at 34issue of Dr. Dobb's Journal; a copy of the article is available at
35http://marknelson.us/1997/01/01/zlib-engine/ . 35http://marknelson.us/1997/01/01/zlib-engine/ .
36 36
37The changes made in version 1.2.5 are documented in the file ChangeLog. 37The changes made in version 1.2.7 are documented in the file ChangeLog.
38 38
39Unsupported third party contributions are provided in directory contrib/ . 39Unsupported third party contributions are provided in directory contrib/ .
40 40
@@ -47,7 +47,7 @@ http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
47 47
48A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is 48A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
49available in Python 1.5 and later versions, see 49available in Python 1.5 and later versions, see
50http://www.python.org/doc/lib/module-zlib.html . 50http://docs.python.org/library/zlib.html .
51 51
52zlib is built into tcl: http://wiki.tcl.tk/4610 . 52zlib is built into tcl: http://wiki.tcl.tk/4610 .
53 53
@@ -87,7 +87,7 @@ Acknowledgments:
87 87
88Copyright notice: 88Copyright notice:
89 89
90 (C) 1995-2010 Jean-loup Gailly and Mark Adler 90 (C) 1995-2012 Jean-loup Gailly and Mark Adler
91 91
92 This software is provided 'as-is', without any express or implied 92 This software is provided 'as-is', without any express or implied
93 warranty. In no event will the authors be held liable for any damages 93 warranty. In no event will the authors be held liable for any damages
diff --git a/zlib/adler32.c b/zlib/adler32.c
index c772d935184..023c5df9b54 100644
--- a/zlib/adler32.c
+++ b/zlib/adler32.c
@@ -1,5 +1,5 @@
1/* adler32.c -- compute the Adler-32 checksum of a data stream 1/* adler32.c -- compute the Adler-32 checksum of a data stream
2 * Copyright (C) 1995-2007 Mark Adler 2 * Copyright (C) 1995-2011 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -9,9 +9,9 @@
9 9
10#define local static 10#define local static
11 11
12local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); 12local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
13 13
14#define BASE 65521UL /* largest prime smaller than 65536 */ 14#define BASE 65521 /* largest prime smaller than 65536 */
15#define NMAX 5552 15#define NMAX 5552
16/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 16/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
17 17
@@ -21,39 +21,44 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
21#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 21#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
22#define DO16(buf) DO8(buf,0); DO8(buf,8); 22#define DO16(buf) DO8(buf,0); DO8(buf,8);
23 23
24/* use NO_DIVIDE if your processor does not do division in hardware */ 24/* use NO_DIVIDE if your processor does not do division in hardware --
25 try it both ways to see which is faster */
25#ifdef NO_DIVIDE 26#ifdef NO_DIVIDE
26# define MOD(a) \ 27/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
28 (thank you to John Reiser for pointing this out) */
29# define CHOP(a) \
30 do { \
31 unsigned long tmp = a >> 16; \
32 a &= 0xffffUL; \
33 a += (tmp << 4) - tmp; \
34 } while (0)
35# define MOD28(a) \
27 do { \ 36 do { \
28 if (a >= (BASE << 16)) a -= (BASE << 16); \ 37 CHOP(a); \
29 if (a >= (BASE << 15)) a -= (BASE << 15); \
30 if (a >= (BASE << 14)) a -= (BASE << 14); \
31 if (a >= (BASE << 13)) a -= (BASE << 13); \
32 if (a >= (BASE << 12)) a -= (BASE << 12); \
33 if (a >= (BASE << 11)) a -= (BASE << 11); \
34 if (a >= (BASE << 10)) a -= (BASE << 10); \
35 if (a >= (BASE << 9)) a -= (BASE << 9); \
36 if (a >= (BASE << 8)) a -= (BASE << 8); \
37 if (a >= (BASE << 7)) a -= (BASE << 7); \
38 if (a >= (BASE << 6)) a -= (BASE << 6); \
39 if (a >= (BASE << 5)) a -= (BASE << 5); \
40 if (a >= (BASE << 4)) a -= (BASE << 4); \
41 if (a >= (BASE << 3)) a -= (BASE << 3); \
42 if (a >= (BASE << 2)) a -= (BASE << 2); \
43 if (a >= (BASE << 1)) a -= (BASE << 1); \
44 if (a >= BASE) a -= BASE; \ 38 if (a >= BASE) a -= BASE; \
45 } while (0) 39 } while (0)
46# define MOD4(a) \ 40# define MOD(a) \
47 do { \ 41 do { \
48 if (a >= (BASE << 4)) a -= (BASE << 4); \ 42 CHOP(a); \
49 if (a >= (BASE << 3)) a -= (BASE << 3); \ 43 MOD28(a); \
50 if (a >= (BASE << 2)) a -= (BASE << 2); \ 44 } while (0)
51 if (a >= (BASE << 1)) a -= (BASE << 1); \ 45# define MOD63(a) \
46 do { /* this assumes a is not negative */ \
47 z_off64_t tmp = a >> 32; \
48 a &= 0xffffffffL; \
49 a += (tmp << 8) - (tmp << 5) + tmp; \
50 tmp = a >> 16; \
51 a &= 0xffffL; \
52 a += (tmp << 4) - tmp; \
53 tmp = a >> 16; \
54 a &= 0xffffL; \
55 a += (tmp << 4) - tmp; \
52 if (a >= BASE) a -= BASE; \ 56 if (a >= BASE) a -= BASE; \
53 } while (0) 57 } while (0)
54#else 58#else
55# define MOD(a) a %= BASE 59# define MOD(a) a %= BASE
56# define MOD4(a) a %= BASE 60# define MOD28(a) a %= BASE
61# define MOD63(a) a %= BASE
57#endif 62#endif
58 63
59/* ========================================================================= */ 64/* ========================================================================= */
@@ -92,7 +97,7 @@ uLong ZEXPORT adler32(adler, buf, len)
92 } 97 }
93 if (adler >= BASE) 98 if (adler >= BASE)
94 adler -= BASE; 99 adler -= BASE;
95 MOD4(sum2); /* only added so many BASE's */ 100 MOD28(sum2); /* only added so many BASE's */
96 return adler | (sum2 << 16); 101 return adler | (sum2 << 16);
97 } 102 }
98 103
@@ -137,8 +142,13 @@ local uLong adler32_combine_(adler1, adler2, len2)
137 unsigned long sum2; 142 unsigned long sum2;
138 unsigned rem; 143 unsigned rem;
139 144
145 /* for negative len, return invalid adler32 as a clue for debugging */
146 if (len2 < 0)
147 return 0xffffffffUL;
148
140 /* the derivation of this formula is left as an exercise for the reader */ 149 /* the derivation of this formula is left as an exercise for the reader */
141 rem = (unsigned)(len2 % BASE); 150 MOD63(len2); /* assumes len2 >= 0 */
151 rem = (unsigned)len2;
142 sum1 = adler1 & 0xffff; 152 sum1 = adler1 & 0xffff;
143 sum2 = rem * sum1; 153 sum2 = rem * sum1;
144 MOD(sum2); 154 MOD(sum2);
diff --git a/zlib/old/as400/bndsrc b/zlib/as400/bndsrc
index 9cf94bb3567..52cc6613b30 100644
--- a/zlib/old/as400/bndsrc
+++ b/zlib/as400/bndsrc
@@ -129,4 +129,77 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
129 129
130 EXPORT SYMBOL("zlibCompileFlags") 130 EXPORT SYMBOL("zlibCompileFlags")
131 131
132/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
133/* Version 1.2.5 additional entry points. */
134/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
135
136/********************************************************************/
137/* *MODULE ADLER32 ZLIB 01/02/01 00:15:09 */
138/********************************************************************/
139
140 EXPORT SYMBOL("adler32_combine")
141 EXPORT SYMBOL("adler32_combine64")
142
143/********************************************************************/
144/* *MODULE CRC32 ZLIB 01/02/01 00:15:09 */
145/********************************************************************/
146
147 EXPORT SYMBOL("crc32_combine")
148 EXPORT SYMBOL("crc32_combine64")
149
150/********************************************************************/
151/* *MODULE GZLIB ZLIB 01/02/01 00:15:09 */
152/********************************************************************/
153
154 EXPORT SYMBOL("gzbuffer")
155 EXPORT SYMBOL("gzoffset")
156 EXPORT SYMBOL("gzoffset64")
157 EXPORT SYMBOL("gzopen64")
158 EXPORT SYMBOL("gzseek64")
159 EXPORT SYMBOL("gztell64")
160
161/********************************************************************/
162/* *MODULE GZREAD ZLIB 01/02/01 00:15:09 */
163/********************************************************************/
164
165 EXPORT SYMBOL("gzclose_r")
166
167/********************************************************************/
168/* *MODULE GZWRITE ZLIB 01/02/01 00:15:09 */
169/********************************************************************/
170
171 EXPORT SYMBOL("gzclose_w")
172
173/********************************************************************/
174/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
175/********************************************************************/
176
177 EXPORT SYMBOL("inflateMark")
178 EXPORT SYMBOL("inflatePrime")
179 EXPORT SYMBOL("inflateReset2")
180 EXPORT SYMBOL("inflateUndermine")
181
182/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
183/* Version 1.2.6 additional entry points. */
184/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
185
186/********************************************************************/
187/* *MODULE DEFLATE ZLIB 01/02/01 00:15:09 */
188/********************************************************************/
189
190 EXPORT SYMBOL("deflateResetKeep")
191 EXPORT SYMBOL("deflatePending")
192
193/********************************************************************/
194/* *MODULE GZWRITE ZLIB 01/02/01 00:15:09 */
195/********************************************************************/
196
197 EXPORT SYMBOL("gzgetc_")
198
199/********************************************************************/
200/* *MODULE INFLATE ZLIB 01/02/01 00:15:09 */
201/********************************************************************/
202
203 EXPORT SYMBOL("inflateResetKeep")
204
132ENDPGMEXP 205ENDPGMEXP
diff --git a/zlib/as400/compile.clp b/zlib/as400/compile.clp
new file mode 100644
index 00000000000..8d0c58f51e1
--- /dev/null
+++ b/zlib/as400/compile.clp
@@ -0,0 +1,110 @@
1/******************************************************************************/
2/* */
3/* ZLIB */
4/* */
5/* Compile sources into modules and link them into a service program. */
6/* */
7/******************************************************************************/
8
9 PGM
10
11/* Configuration adjustable parameters. */
12
13 DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10) +
14 VALUE('ZLIB') /* Source library. */
15 DCL VAR(&SRCFILE) TYPE(*CHAR) LEN(10) +
16 VALUE('SOURCES') /* Source member file. */
17 DCL VAR(&CTLFILE) TYPE(*CHAR) LEN(10) +
18 VALUE('TOOLS') /* Control member file. */
19
20 DCL VAR(&MODLIB) TYPE(*CHAR) LEN(10) +
21 VALUE('ZLIB') /* Module library. */
22
23 DCL VAR(&SRVLIB) TYPE(*CHAR) LEN(10) +
24 VALUE('LGPL') /* Service program library. */
25
26 DCL VAR(&CFLAGS) TYPE(*CHAR) +
27 VALUE('OPTIMIZE(40)') /* Compile options. */
28
29 DCL VAR(&TGTRLS) TYPE(*CHAR) +
30 VALUE('V5R3M0') /* Target release. */
31
32
33/* Working storage. */
34
35 DCL VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(300) /* Command length. */
36 DCL VAR(&CMD) TYPE(*CHAR) LEN(512)
37 DCL VAR(&FIXDCMD) TYPE(*CHAR) LEN(512)
38
39
40/* Compile sources into modules. */
41
42 CHGVAR VAR(&FIXDCMD) VALUE('CRTCMOD' *BCAT &CFLAGS *BCAT +
43 'SYSIFCOPT(*IFS64IO)' *BCAT +
44 'DEFINE(''_LARGEFILE64_SOURCE''' *BCAT +
45 '''_LFS64_LARGEFILE=1'') TGTRLS(' *TCAT &TGTRLS *TCAT +
46 ') SRCFILE(' *TCAT &SRCLIB *TCAT '/' *TCAT +
47 &SRCFILE *TCAT ') MODULE(' *TCAT &MODLIB *TCAT '/')
48
49
50 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'ADLER32)')
51 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
52
53 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'COMPRESS)')
54 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
55
56 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'CRC32)')
57 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
58
59 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'DEFLATE)')
60 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
61
62 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZCLOSE)')
63 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
64
65 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZLIB)')
66 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
67
68 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZREAD)')
69 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
70
71 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'GZWRITE)')
72 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
73
74 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFBACK)')
75 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
76
77 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFFAST)')
78 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
79
80 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFLATE)')
81 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
82
83 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'INFTREES)')
84 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
85
86 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'TREES)')
87 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
88
89 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'UNCOMPR)')
90 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
91
92 CHGVAR VAR(&CMD) VALUE(&FIXDCMD *TCAT 'ZUTIL)')
93 CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
94
95
96/* Link modules into a service program. */
97
98 CRTSRVPGM SRVPGM(&SRVLIB/ZLIB) +
99 MODULE(&MODLIB/ADLER32 &MODLIB/COMPRESS +
100 &MODLIB/CRC32 &MODLIB/DEFLATE +
101 &MODLIB/GZCLOSE &MODLIB/GZLIB +
102 &MODLIB/GZREAD &MODLIB/GZWRITE +
103 &MODLIB/INFBACK &MODLIB/INFFAST +
104 &MODLIB/INFLATE &MODLIB/INFTREES +
105 &MODLIB/TREES &MODLIB/UNCOMPR +
106 &MODLIB/ZUTIL) +
107 SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) +
108 TEXT('ZLIB 1.2.7') TGTRLS(&TGTRLS)
109
110 ENDPGM
diff --git a/zlib/old/as400/readme.txt b/zlib/as400/readme.txt
index beae13f565b..23cd1b8a3c5 100644
--- a/zlib/old/as400/readme.txt
+++ b/zlib/as400/readme.txt
@@ -1,4 +1,4 @@
1 ZLIB version 1.2.3 for AS400 installation instructions 1 ZLIB version 1.2.7 for AS400 installation instructions
2 2
3I) From an AS400 *SAVF file: 3I) From an AS400 *SAVF file:
4 4
@@ -8,7 +8,7 @@ On the AS400:
8 8
9_ Create the ZLIB AS400 library: 9_ Create the ZLIB AS400 library:
10 10
11 CRTLIB LIB(ZLIB) TYPE(PROD) TEXT('ZLIB compression API library') 11 CRTLIB LIB(ZLIB) TYPE(*PROD) TEXT('ZLIB compression API library')
12 12
13_ Create a work save file, for example: 13_ Create a work save file, for example:
14 14
@@ -52,7 +52,7 @@ II) From the original source distribution:
52 52
531) On the AS400, create the source library: 531) On the AS400, create the source library:
54 54
55 CRTLIB LIB(ZLIB) TYPE(PROD) TEXT('ZLIB compression API library') 55 CRTLIB LIB(ZLIB) TYPE(*PROD) TEXT('ZLIB compression API library')
56 56
572) Create the source files: 572) Create the source files:
58 58
@@ -70,7 +70,10 @@ II) From the original source distribution:
70 compress.c COMPRESS C ZLIB - Compress a memory buffer 70 compress.c COMPRESS C ZLIB - Compress a memory buffer
71 crc32.c CRC32 C ZLIB - Compute the CRC-32 of a data stream 71 crc32.c CRC32 C ZLIB - Compute the CRC-32 of a data stream
72 deflate.c DEFLATE C ZLIB - Compress data using the deflation algorithm 72 deflate.c DEFLATE C ZLIB - Compress data using the deflation algorithm
73 gzio.c GZIO C ZLIB - IO on .gz files 73 gzclose.c GZCLOSE C ZLIB - Close .gz files
74 gzlib.c GZLIB C ZLIB - Miscellaneous .gz files IO support
75 gzread.c GZREAD C ZLIB - Read .gz files
76 gzwrite.c GZWRITE C ZLIB - Write .gz files
74 infback.c INFBACK C ZLIB - Inflate using a callback interface 77 infback.c INFBACK C ZLIB - Inflate using a callback interface
75 inffast.c INFFAST C ZLIB - Fast proc. literals & length/distance pairs 78 inffast.c INFFAST C ZLIB - Fast proc. literals & length/distance pairs
76 inflate.c INFLATE C ZLIB - Interface to inflate modules 79 inflate.c INFLATE C ZLIB - Interface to inflate modules
@@ -81,6 +84,7 @@ II) From the original source distribution:
81 H Original ZLIB C and ILE/RPG include files 84 H Original ZLIB C and ILE/RPG include files
82 crc32.h CRC32 C ZLIB - CRC32 tables 85 crc32.h CRC32 C ZLIB - CRC32 tables
83 deflate.h DEFLATE C ZLIB - Internal compression state 86 deflate.h DEFLATE C ZLIB - Internal compression state
87 gzguts.h GZGUTS C ZLIB - Definitions for the gzclose module
84 inffast.h INFFAST C ZLIB - Header to use inffast.c 88 inffast.h INFFAST C ZLIB - Header to use inffast.c
85 inffixed.h INFFIXED C ZLIB - Table for decoding fixed codes 89 inffixed.h INFFIXED C ZLIB - Table for decoding fixed codes
86 inflate.h INFLATE C ZLIB - Internal inflate state definitions 90 inflate.h INFLATE C ZLIB - Internal inflate state definitions
@@ -108,4 +112,4 @@ Notes: For AS400 ILE RPG programmers, a /copy member defining the ZLIB
108 implementation does not handle conversion from/to ASCII, so 112 implementation does not handle conversion from/to ASCII, so
109 text data code conversions must be done explicitely. 113 text data code conversions must be done explicitely.
110 114
111 Always open zipped files in binary mode. 115 Mainly for the reason above, always open zipped files in binary mode.
diff --git a/zlib/old/as400/zlib.inc b/zlib/as400/zlib.inc
index a9a4f5cf4f6..747c598aa05 100644
--- a/zlib/old/as400/zlib.inc
+++ b/zlib/as400/zlib.inc
@@ -1,7 +1,7 @@
1 * ZLIB.INC - Interface to the general purpose compression library 1 * ZLIB.INC - Interface to the general purpose compression library
2 * 2 *
3 * ILE RPG400 version by Patrick Monnerat, DATASPHERE. 3 * ILE RPG400 version by Patrick Monnerat, DATASPHERE.
4 * Version 1.2.3.9 4 * Version 1.2.7
5 * 5 *
6 * 6 *
7 * WARNING: 7 * WARNING:
@@ -22,16 +22,25 @@
22 * 22 *
23 * Versioning information. 23 * Versioning information.
24 * 24 *
25 D ZLIB_VERSION C '1.2.3.9' 25 D ZLIB_VERSION C '1.2.7'
26 D ZLIB_VERNUM C X'1239' 26 D ZLIB_VERNUM C X'1270'
27 D ZLIB_VER_MAJOR C 1
28 D ZLIB_VER_MINOR C 2
29 D ZLIB_VER_REVISION...
30 D C 7
31 D ZLIB_VER_SUBREVISION...
32 D C 0
27 * 33 *
28 * Other equates. 34 * Other equates.
29 * 35 *
30 D Z_NO_FLUSH C 0 36 D Z_NO_FLUSH C 0
37 D Z_PARTIAL_FLUSH...
38 D C 1
31 D Z_SYNC_FLUSH C 2 39 D Z_SYNC_FLUSH C 2
32 D Z_FULL_FLUSH C 3 40 D Z_FULL_FLUSH C 3
33 D Z_FINISH C 4 41 D Z_FINISH C 4
34 D Z_BLOCK C 5 42 D Z_BLOCK C 5
43 D Z_TREES C 6
35 * 44 *
36 D Z_OK C 0 45 D Z_OK C 0
37 D Z_STREAM_END C 1 46 D Z_STREAM_END C 1
@@ -72,6 +81,7 @@
72 D z_streamp S * Stream struct ptr 81 D z_streamp S * Stream struct ptr
73 D gzFile S * File pointer 82 D gzFile S * File pointer
74 D z_off_t S 10i 0 Stream offsets 83 D z_off_t S 10i 0 Stream offsets
84 D z_off64_t S 20i 0 Stream offsets
75 * 85 *
76 ************************************************************************** 86 **************************************************************************
77 * Structures 87 * Structures
@@ -101,15 +111,15 @@
101 ************************************************************************** 111 **************************************************************************
102 * 112 *
103 D compress PR 10I 0 extproc('compress') 113 D compress PR 10I 0 extproc('compress')
104 D dest 32767 options(*varsize) Destination buffer 114 D dest 65535 options(*varsize) Destination buffer
105 D destLen 10U 0 Destination length 115 D destLen 10U 0 Destination length
106 D source 32767 const options(*varsize) Source buffer 116 D source 65535 const options(*varsize) Source buffer
107 D sourceLen 10u 0 value Source length 117 D sourceLen 10u 0 value Source length
108 * 118 *
109 D compress2 PR 10I 0 extproc('compress2') 119 D compress2 PR 10I 0 extproc('compress2')
110 D dest 32767 options(*varsize) Destination buffer 120 D dest 65535 options(*varsize) Destination buffer
111 D destLen 10U 0 Destination length 121 D destLen 10U 0 Destination length
112 D source 32767 const options(*varsize) Source buffer 122 D source 65535 const options(*varsize) Source buffer
113 D sourceLen 10U 0 value Source length 123 D sourceLen 10U 0 value Source length
114 D level 10I 0 value Compression level 124 D level 10I 0 value Compression level
115 * 125 *
@@ -117,34 +127,50 @@
117 D sourceLen 10U 0 value 127 D sourceLen 10U 0 value
118 * 128 *
119 D uncompress PR 10I 0 extproc('uncompress') 129 D uncompress PR 10I 0 extproc('uncompress')
120 D dest 32767 options(*varsize) Destination buffer 130 D dest 65535 options(*varsize) Destination buffer
121 D destLen 10U 0 Destination length 131 D destLen 10U 0 Destination length
122 D source 32767 const options(*varsize) Source buffer 132 D source 65535 const options(*varsize) Source buffer
123 D sourceLen 10U 0 value Source length 133 D sourceLen 10U 0 value Source length
124 * 134 *
135 /if not defined(LARGE_FILES)
125 D gzopen PR extproc('gzopen') 136 D gzopen PR extproc('gzopen')
126 D like(gzFile) 137 D like(gzFile)
127 D path * value options(*string) File pathname 138 D path * value options(*string) File pathname
128 D mode * value options(*string) Open mode 139 D mode * value options(*string) Open mode
140 /else
141 D gzopen PR extproc('gzopen64')
142 D like(gzFile)
143 D path * value options(*string) File pathname
144 D mode * value options(*string) Open mode
145 *
146 D gzopen64 PR extproc('gzopen64')
147 D like(gzFile)
148 D path * value options(*string) File pathname
149 D mode * value options(*string) Open mode
150 /endif
129 * 151 *
130 D gzdopen PR extproc('gzdopen') 152 D gzdopen PR extproc('gzdopen')
131 D like(gzFile) 153 D like(gzFile)
132 D fd 10i 0 value File descriptor 154 D fd 10I 0 value File descriptor
133 D mode * value options(*string) Open mode 155 D mode * value options(*string) Open mode
134 * 156 *
157 D gzbuffer PR 10I 0 extproc('gzbuffer')
158 D file value like(gzFile) File pointer
159 D size 10U 0 value
160 *
135 D gzsetparams PR 10I 0 extproc('gzsetparams') 161 D gzsetparams PR 10I 0 extproc('gzsetparams')
136 D file value like(gzFile) File pointer 162 D file value like(gzFile) File pointer
137 D level 10I 0 value 163 D level 10I 0 value
138 D strategy 10i 0 value 164 D strategy 10I 0 value
139 * 165 *
140 D gzread PR 10I 0 extproc('gzread') 166 D gzread PR 10I 0 extproc('gzread')
141 D file value like(gzFile) File pointer 167 D file value like(gzFile) File pointer
142 D buf 32767 options(*varsize) Buffer 168 D buf 65535 options(*varsize) Buffer
143 D len 10u 0 value Buffer length 169 D len 10u 0 value Buffer length
144 * 170 *
145 D gzwrite PR 10I 0 extproc('gzwrite') 171 D gzwrite PR 10I 0 extproc('gzwrite')
146 D file value like(gzFile) File pointer 172 D file value like(gzFile) File pointer
147 D buf 32767 const options(*varsize) Buffer 173 D buf 65535 const options(*varsize) Buffer
148 D len 10u 0 value Buffer length 174 D len 10u 0 value Buffer length
149 * 175 *
150 D gzputs PR 10I 0 extproc('gzputs') 176 D gzputs PR 10I 0 extproc('gzputs')
@@ -153,29 +179,87 @@
153 * 179 *
154 D gzgets PR * extproc('gzgets') 180 D gzgets PR * extproc('gzgets')
155 D file value like(gzFile) File pointer 181 D file value like(gzFile) File pointer
156 D buf 32767 options(*varsize) Read buffer 182 D buf 65535 options(*varsize) Read buffer
157 D len 10i 0 value Buffer length 183 D len 10i 0 value Buffer length
158 * 184 *
185 D gzputc PR 10i 0 extproc('gzputc')
186 D file value like(gzFile) File pointer
187 D c 10I 0 value Character to write
188 *
189 D gzgetc PR 10i 0 extproc('gzgetc')
190 D file value like(gzFile) File pointer
191 *
192 D gzgetc_ PR 10i 0 extproc('gzgetc_')
193 D file value like(gzFile) File pointer
194 *
195 D gzungetc PR 10i 0 extproc('gzungetc')
196 D c 10I 0 value Character to push
197 D file value like(gzFile) File pointer
198 *
159 D gzflush PR 10i 0 extproc('gzflush') 199 D gzflush PR 10i 0 extproc('gzflush')
160 D file value like(gzFile) File pointer 200 D file value like(gzFile) File pointer
161 D flush 10I 0 value Type of flush 201 D flush 10I 0 value Type of flush
162 * 202 *
203 /if not defined(LARGE_FILES)
163 D gzseek PR extproc('gzseek') 204 D gzseek PR extproc('gzseek')
164 D like(z_off_t) 205 D like(z_off_t)
165 D file value like(gzFile) File pointer 206 D file value like(gzFile) File pointer
166 D offset value like(z_off_t) Offset 207 D offset value like(z_off_t) Offset
167 D whence 10i 0 value Origin 208 D whence 10i 0 value Origin
209 /else
210 D gzseek PR extproc('gzseek64')
211 D like(z_off_t)
212 D file value like(gzFile) File pointer
213 D offset value like(z_off_t) Offset
214 D whence 10i 0 value Origin
215 *
216 D gzseek64 PR extproc('gzseek64')
217 D like(z_off64_t)
218 D file value like(gzFile) File pointer
219 D offset value like(z_off64_t) Offset
220 D whence 10i 0 value Origin
221 /endif
168 * 222 *
169 D gzrewind PR 10i 0 extproc('gzrewind') 223 D gzrewind PR 10i 0 extproc('gzrewind')
170 D file value like(gzFile) File pointer 224 D file value like(gzFile) File pointer
171 * 225 *
226 /if not defined(LARGE_FILES)
172 D gztell PR extproc('gztell') 227 D gztell PR extproc('gztell')
173 D like(z_off_t) 228 D like(z_off_t)
174 D file value like(gzFile) File pointer 229 D file value like(gzFile) File pointer
230 /else
231 D gztell PR extproc('gztell64')
232 D like(z_off_t)
233 D file value like(gzFile) File pointer
234 *
235 D gztell64 PR extproc('gztell64')
236 D like(z_off64_t)
237 D file value like(gzFile) File pointer
238 /endif
239 *
240 /if not defined(LARGE_FILES)
241 D gzoffset PR extproc('gzoffset')
242 D like(z_off_t)
243 D file value like(gzFile) File pointer
244 /else
245 D gzoffset PR extproc('gzoffset64')
246 D like(z_off_t)
247 D file value like(gzFile) File pointer
248 *
249 D gzoffset64 PR extproc('gzoffset64')
250 D like(z_off64_t)
251 D file value like(gzFile) File pointer
252 /endif
175 * 253 *
176 D gzeof PR 10i 0 extproc('gzeof') 254 D gzeof PR 10i 0 extproc('gzeof')
177 D file value like(gzFile) File pointer 255 D file value like(gzFile) File pointer
178 * 256 *
257 D gzclose_r PR 10i 0 extproc('gzclose_r')
258 D file value like(gzFile) File pointer
259 *
260 D gzclose_w PR 10i 0 extproc('gzclose_w')
261 D file value like(gzFile) File pointer
262 *
179 D gzclose PR 10i 0 extproc('gzclose') 263 D gzclose PR 10i 0 extproc('gzclose')
180 D file value like(gzFile) File pointer 264 D file value like(gzFile) File pointer
181 * 265 *
@@ -234,7 +318,7 @@
234 D deflateSetDictionary... 318 D deflateSetDictionary...
235 D PR 10I 0 extproc('deflateSetDictionary') Init. dictionary 319 D PR 10I 0 extproc('deflateSetDictionary') Init. dictionary
236 D strm like(z_stream) Compression stream 320 D strm like(z_stream) Compression stream
237 D dictionary 32767 const options(*varsize) Dictionary bytes 321 D dictionary 65535 const options(*varsize) Dictionary bytes
238 D dictLength 10U 0 value Dictionary length 322 D dictLength 10U 0 value Dictionary length
239 * 323 *
240 D deflateCopy PR 10I 0 extproc('deflateCopy') Compress strm 2 strm 324 D deflateCopy PR 10I 0 extproc('deflateCopy') Compress strm 2 strm
@@ -253,9 +337,14 @@
253 D strm like(z_stream) Compression stream 337 D strm like(z_stream) Compression stream
254 D sourcelen 10U 0 value Compression level 338 D sourcelen 10U 0 value Compression level
255 * 339 *
340 D deflatePending PR 10I 0 extproc('deflatePending') Change level & strat
341 D strm like(z_stream) Compression stream
342 D pending 10U 0 Pending bytes
343 D bits 10I 0 Pending bits
344 *
256 D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat 345 D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat
257 D strm like(z_stream) Compression stream 346 D strm like(z_stream) Compression stream
258 D bits 10I 0 value Number of bits to insert 347 D bits 10I 0 value # of bits to insert
259 D value 10I 0 value Bits to insert 348 D value 10I 0 value Bits to insert
260 * 349 *
261 D inflateInit2 PR 10I 0 extproc('inflateInit2_') Init. expansion 350 D inflateInit2 PR 10I 0 extproc('inflateInit2_') Init. expansion
@@ -267,7 +356,7 @@
267 D inflateSetDictionary... 356 D inflateSetDictionary...
268 D PR 10I 0 extproc('inflateSetDictionary') Init. dictionary 357 D PR 10I 0 extproc('inflateSetDictionary') Init. dictionary
269 D strm like(z_stream) Expansion stream 358 D strm like(z_stream) Expansion stream
270 D dictionary 32767 const options(*varsize) Dictionary bytes 359 D dictionary 65535 const options(*varsize) Dictionary bytes
271 D dictLength 10U 0 value Dictionary length 360 D dictLength 10U 0 value Dictionary length
272 * 361 *
273 D inflateSync PR 10I 0 extproc('inflateSync') Sync. expansion 362 D inflateSync PR 10I 0 extproc('inflateSync') Sync. expansion
@@ -280,11 +369,23 @@
280 D inflateReset PR 10I 0 extproc('inflateReset') End and init. stream 369 D inflateReset PR 10I 0 extproc('inflateReset') End and init. stream
281 D strm like(z_stream) Expansion stream 370 D strm like(z_stream) Expansion stream
282 * 371 *
372 D inflateReset2 PR 10I 0 extproc('inflateReset2') End and init. stream
373 D strm like(z_stream) Expansion stream
374 D windowBits 10I 0 value Log2(buffer size)
375 *
376 D inflatePrime PR 10I 0 extproc('inflatePrime') Insert bits
377 D strm like(z_stream) Expansion stream
378 D bits 10I 0 value Bit count
379 D value 10I 0 value Bits to insert
380 *
381 D inflateMark PR 10I 0 extproc('inflateMark') Get inflate info
382 D strm like(z_stream) Expansion stream
383 *
283 D inflateBackInit... 384 D inflateBackInit...
284 D PR 10I 0 extproc('inflateBackInit_') 385 D PR 10I 0 extproc('inflateBackInit_')
285 D strm like(z_stream) Expansion stream 386 D strm like(z_stream) Expansion stream
286 D windowBits 10I 0 value Log2(buffer size) 387 D windowBits 10I 0 value Log2(buffer size)
287 D window 32767 options(*varsize) Buffer 388 D window 65535 options(*varsize) Buffer
288 D version * value options(*string) Version string 389 D version * value options(*string) Version string
289 D stream_size 10i 0 value Stream struct. size 390 D stream_size 10i 0 value Stream struct. size
290 * 391 *
@@ -307,12 +408,12 @@
307 * 408 *
308 D adler32 PR 10U 0 extproc('adler32') New checksum 409 D adler32 PR 10U 0 extproc('adler32') New checksum
309 D adler 10U 0 value Old checksum 410 D adler 10U 0 value Old checksum
310 D buf 32767 const options(*varsize) Bytes to accumulate 411 D buf 65535 const options(*varsize) Bytes to accumulate
311 D len 10U 0 value Buffer length 412 D len 10U 0 value Buffer length
312 * 413 *
313 D crc32 PR 10U 0 extproc('crc32') New checksum 414 D crc32 PR 10U 0 extproc('crc32') New checksum
314 D crc 10U 0 value Old checksum 415 D crc 10U 0 value Old checksum
315 D buf 32767 const options(*varsize) Bytes to accumulate 416 D buf 65535 const options(*varsize) Bytes to accumulate
316 D len 10U 0 value Buffer length 417 D len 10U 0 value Buffer length
317 * 418 *
318 ************************************************************************** 419 **************************************************************************
@@ -328,4 +429,17 @@
328 * 429 *
329 D get_crc_table PR * extproc('get_crc_table') Ptr to ulongs 430 D get_crc_table PR * extproc('get_crc_table') Ptr to ulongs
330 * 431 *
432 D inflateUndermine...
433 D PR 10I 0 extproc('inflateUndermine')
434 D strm like(z_stream) Expansion stream
435 D arg 10I 0 value Error code
436 *
437 D inflateResetKeep...
438 D PR 10I 0 extproc('inflateResetKeep') End and init. stream
439 D strm like(z_stream) Expansion stream
440 *
441 D deflateResetKeep...
442 D PR 10I 0 extproc('deflateResetKeep') End and init. stream
443 D strm like(z_stream) Expansion stream
444 *
331 /endif 445 /endif
diff --git a/zlib/contrib/asm686/match.S b/zlib/contrib/asm686/match.S
index 06817e1dd08..fa421092785 100644
--- a/zlib/contrib/asm686/match.S
+++ b/zlib/contrib/asm686/match.S
@@ -83,17 +83,25 @@
83.text 83.text
84 84
85/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */ 85/* uInt longest_match(deflate_state *deflatestate, IPos curmatch) */
86.cfi_sections .debug_frame
86 87
87longest_match: 88longest_match:
88 89
90.cfi_startproc
89/* Save registers that the compiler may be using, and adjust %esp to */ 91/* Save registers that the compiler may be using, and adjust %esp to */
90/* make room for our stack frame. */ 92/* make room for our stack frame. */
91 93
92 pushl %ebp 94 pushl %ebp
95 .cfi_def_cfa_offset 8
96 .cfi_offset ebp, -8
93 pushl %edi 97 pushl %edi
98 .cfi_def_cfa_offset 12
94 pushl %esi 99 pushl %esi
100 .cfi_def_cfa_offset 16
95 pushl %ebx 101 pushl %ebx
102 .cfi_def_cfa_offset 20
96 subl $LocalVarsSize, %esp 103 subl $LocalVarsSize, %esp
104 .cfi_def_cfa_offset LocalVarsSize+20
97 105
98/* Retrieve the function arguments. %ecx will hold cur_match */ 106/* Retrieve the function arguments. %ecx will hold cur_match */
99/* throughout the entire function. %edx will hold the pointer to the */ 107/* throughout the entire function. %edx will hold the pointer to the */
@@ -108,7 +116,7 @@ longest_match:
108/* if (s->prev_length >= s->good_match) { */ 116/* if (s->prev_length >= s->good_match) { */
109/* chain_length >>= 2; */ 117/* chain_length >>= 2; */
110/* } */ 118/* } */
111 119
112 movl dsPrevLen(%edx), %eax 120 movl dsPrevLen(%edx), %eax
113 movl dsGoodMatch(%edx), %ebx 121 movl dsGoodMatch(%edx), %ebx
114 cmpl %ebx, %eax 122 cmpl %ebx, %eax
@@ -336,8 +344,14 @@ LookaheadRet:
336/* Restore the stack and return from whence we came. */ 344/* Restore the stack and return from whence we came. */
337 345
338 addl $LocalVarsSize, %esp 346 addl $LocalVarsSize, %esp
347 .cfi_def_cfa_offset 20
339 popl %ebx 348 popl %ebx
349 .cfi_def_cfa_offset 16
340 popl %esi 350 popl %esi
351 .cfi_def_cfa_offset 12
341 popl %edi 352 popl %edi
353 .cfi_def_cfa_offset 8
342 popl %ebp 354 popl %ebp
355 .cfi_def_cfa_offset 4
356.cfi_endproc
343match_init: ret 357match_init: ret
diff --git a/zlib/contrib/delphi/ZLib.pas b/zlib/contrib/delphi/ZLib.pas
index 0d86fb52fcf..f24bb3eda0e 100644
--- a/zlib/contrib/delphi/ZLib.pas
+++ b/zlib/contrib/delphi/ZLib.pas
@@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
152 const OutBuf: Pointer; BufSize: Integer); 152 const OutBuf: Pointer; BufSize: Integer);
153 153
154const 154const
155 zlib_version = '1.2.5'; 155 zlib_version = '1.2.7';
156 156
157type 157type
158 EZlibError = class(Exception); 158 EZlibError = class(Exception);
diff --git a/zlib/contrib/delphi/zlibd32.mak b/zlib/contrib/delphi/zlibd32.mak
index 0d0699a69a3..9bb00b7cc42 100644
--- a/zlib/contrib/delphi/zlibd32.mak
+++ b/zlib/contrib/delphi/zlibd32.mak
@@ -63,9 +63,9 @@ uncompr.obj: uncompr.c zlib.h zconf.h
63 63
64zutil.obj: zutil.c zutil.h zlib.h zconf.h 64zutil.obj: zutil.c zutil.h zlib.h zconf.h
65 65
66example.obj: example.c zlib.h zconf.h 66example.obj: test/example.c zlib.h zconf.h
67 67
68minigzip.obj: minigzip.c zlib.h zconf.h 68minigzip.obj: test/minigzip.c zlib.h zconf.h
69 69
70 70
71# For the sake of the old Borland make, 71# For the sake of the old Borland make,
diff --git a/zlib/contrib/dotzlib/DotZLib/UnitTests.cs b/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
index 3bbcc8cee6e..109028841d6 100644
--- a/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
+++ b/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
@@ -156,7 +156,7 @@ namespace DotZLibTests
156 public void Info_Version() 156 public void Info_Version()
157 { 157 {
158 Info info = new Info(); 158 Info info = new Info();
159 Assert.AreEqual("1.2.5", Info.Version); 159 Assert.AreEqual("1.2.7", Info.Version);
160 Assert.AreEqual(32, info.SizeOfUInt); 160 Assert.AreEqual(32, info.SizeOfUInt);
161 Assert.AreEqual(32, info.SizeOfULong); 161 Assert.AreEqual(32, info.SizeOfULong);
162 Assert.AreEqual(32, info.SizeOfPointer); 162 Assert.AreEqual(32, info.SizeOfPointer);
diff --git a/zlib/contrib/infback9/inftree9.c b/zlib/contrib/infback9/inftree9.c
index 306c5f1b19e..5a0b3287efb 100644
--- a/zlib/contrib/infback9/inftree9.c
+++ b/zlib/contrib/infback9/inftree9.c
@@ -1,5 +1,5 @@
1/* inftree9.c -- generate Huffman trees for efficient decoding 1/* inftree9.c -- generate Huffman trees for efficient decoding
2 * Copyright (C) 1995-2010 Mark Adler 2 * Copyright (C) 1995-2012 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -9,7 +9,7 @@
9#define MAXBITS 15 9#define MAXBITS 15
10 10
11const char inflate9_copyright[] = 11const char inflate9_copyright[] =
12 " inflate9 1.2.5 Copyright 1995-2010 Mark Adler "; 12 " inflate9 1.2.7 Copyright 1995-2012 Mark Adler ";
13/* 13/*
14 If you use the zlib library in a product, an acknowledgment is welcome 14 If you use the zlib library in a product, an acknowledgment is welcome
15 in the documentation of your product. If for some reason you cannot 15 in the documentation of your product. If for some reason you cannot
@@ -64,7 +64,7 @@ unsigned short FAR *work;
64 static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 64 static const unsigned short lext[31] = { /* Length codes 257..285 extra */
65 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 65 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
66 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, 66 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
67 133, 133, 133, 133, 144, 73, 195}; 67 133, 133, 133, 133, 144, 78, 68};
68 static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ 68 static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
69 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 69 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
70 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 70 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
diff --git a/zlib/contrib/masmx86/inffas32.asm b/zlib/contrib/masmx86/inffas32.asm
index 92ac22ad9d9..03d20f838bf 100644
--- a/zlib/contrib/masmx86/inffas32.asm
+++ b/zlib/contrib/masmx86/inffas32.asm
@@ -73,11 +73,6 @@ inflate_fast_use_mmx:
73 73
74 74
75_TEXT segment 75_TEXT segment
76PUBLIC _inflate_fast
77
78ALIGN 4
79_inflate_fast:
80 jmp inflate_fast_entry
81 76
82 77
83 78
@@ -163,7 +158,8 @@ distbits_state equ (76+4+zlib1222sup) ;/* state->distbits */
163;SECTION .text 158;SECTION .text
164 159
165ALIGN 4 160ALIGN 4
166inflate_fast_entry: 161_inflate_fast proc near
162.FPO (16, 4, 0, 0, 1, 0)
167 push edi 163 push edi
168 push esi 164 push esi
169 push ebp 165 push ebp
@@ -1078,6 +1074,7 @@ L_done:
1078 pop esi 1074 pop esi
1079 pop edi 1075 pop edi
1080 ret 1076 ret
1077_inflate_fast endp
1081 1078
1082_TEXT ends 1079_TEXT ends
1083end 1080end
diff --git a/zlib/contrib/masmx86/match686.asm b/zlib/contrib/masmx86/match686.asm
index 1eaf555026f..3b09212f8a2 100644
--- a/zlib/contrib/masmx86/match686.asm
+++ b/zlib/contrib/masmx86/match686.asm
@@ -195,6 +195,7 @@ dsNiceMatch equ 136+zlib1222add
195 ELSE 195 ELSE
196 _longest_match proc near 196 _longest_match proc near
197 ENDIF 197 ENDIF
198.FPO (9, 4, 0, 0, 1, 0)
198 199
199;;; Save registers that the compiler may be using, and adjust esp to 200;;; Save registers that the compiler may be using, and adjust esp to
200;;; make room for our stack frame. 201;;; make room for our stack frame.
diff --git a/zlib/contrib/minizip/Makefile.am b/zlib/contrib/minizip/Makefile.am
new file mode 100644
index 00000000000..d343011ebc3
--- /dev/null
+++ b/zlib/contrib/minizip/Makefile.am
@@ -0,0 +1,45 @@
1lib_LTLIBRARIES = libminizip.la
2
3if COND_DEMOS
4bin_PROGRAMS = miniunzip minizip
5endif
6
7zlib_top_srcdir = $(top_srcdir)/../..
8zlib_top_builddir = $(top_builddir)/../..
9
10AM_CPPFLAGS = -I$(zlib_top_srcdir)
11AM_LDFLAGS = -L$(zlib_top_builddir)
12
13if WIN32
14iowin32_src = iowin32.c
15iowin32_h = iowin32.h
16endif
17
18libminizip_la_SOURCES = \
19 ioapi.c \
20 mztools.c \
21 unzip.c \
22 zip.c \
23 ${iowin32_src}
24
25libminizip_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 -lz
26
27minizip_includedir = $(includedir)/minizip
28minizip_include_HEADERS = \
29 crypt.h \
30 ioapi.h \
31 mztools.h \
32 unzip.h \
33 zip.h \
34 ${iowin32_h}
35
36pkgconfigdir = $(libdir)/pkgconfig
37pkgconfig_DATA = minizip.pc
38
39EXTRA_PROGRAMS = miniunzip minizip
40
41miniunzip_SOURCES = miniunz.c
42miniunzip_LDADD = libminizip.la
43
44minizip_SOURCES = minizip.c
45minizip_LDADD = libminizip.la -lz
diff --git a/zlib/contrib/minizip/configure.ac b/zlib/contrib/minizip/configure.ac
new file mode 100644
index 00000000000..6a9af21c317
--- /dev/null
+++ b/zlib/contrib/minizip/configure.ac
@@ -0,0 +1,32 @@
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_INIT([minizip], [1.2.7], [bugzilla.redhat.com])
5AC_CONFIG_SRCDIR([minizip.c])
6AM_INIT_AUTOMAKE([foreign])
7LT_INIT
8
9AC_MSG_CHECKING([whether to build example programs])
10AC_ARG_ENABLE([demos], AC_HELP_STRING([--enable-demos], [build example programs]))
11AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes])
12if test "$enable_demos" = yes
13then
14 AC_MSG_RESULT([yes])
15else
16 AC_MSG_RESULT([no])
17fi
18
19case "${host}" in
20 *-mingw* | mingw*)
21 WIN32="yes"
22 ;;
23 *)
24 ;;
25esac
26AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
27
28
29AC_SUBST([HAVE_UNISTD_H], [0])
30AC_CHECK_HEADER([unistd.h], [HAVE_UNISTD_H=1], [])
31AC_CONFIG_FILES([Makefile minizip.pc])
32AC_OUTPUT
diff --git a/zlib/contrib/minizip/ioapi.c b/zlib/contrib/minizip/ioapi.c
index 49958f61ffd..7f5c191b2af 100644
--- a/zlib/contrib/minizip/ioapi.c
+++ b/zlib/contrib/minizip/ioapi.c
@@ -10,10 +10,22 @@
10 10
11*/ 11*/
12 12
13#if (defined(_WIN32)) 13#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS)))
14 #define _CRT_SECURE_NO_WARNINGS 14 #define _CRT_SECURE_NO_WARNINGS
15#endif 15#endif
16 16
17#if defined(__APPLE__) || defined(IOAPI_NO_64)
18// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
19#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
20#define FTELLO_FUNC(stream) ftello(stream)
21#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
22#else
23#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
24#define FTELLO_FUNC(stream) ftello64(stream)
25#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
26#endif
27
28
17#include "ioapi.h" 29#include "ioapi.h"
18 30
19voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) 31voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
@@ -47,7 +59,7 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream
47 else 59 else
48 { 60 {
49 uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); 61 uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream);
50 if ((tell_uLong) == ((uLong)-1)) 62 if ((tell_uLong) == MAXU32)
51 return (ZPOS64_T)-1; 63 return (ZPOS64_T)-1;
52 else 64 else
53 return tell_uLong; 65 return tell_uLong;
@@ -112,7 +124,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
112 mode_fopen = "wb"; 124 mode_fopen = "wb";
113 125
114 if ((filename!=NULL) && (mode_fopen != NULL)) 126 if ((filename!=NULL) && (mode_fopen != NULL))
115 file = fopen64((const char*)filename, mode_fopen); 127 file = FOPEN_FUNC((const char*)filename, mode_fopen);
116 return file; 128 return file;
117} 129}
118 130
@@ -142,7 +154,7 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
142static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) 154static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
143{ 155{
144 ZPOS64_T ret; 156 ZPOS64_T ret;
145 ret = ftello64((FILE *)stream); 157 ret = FTELLO_FUNC((FILE *)stream);
146 return ret; 158 return ret;
147} 159}
148 160
@@ -188,7 +200,7 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
188 } 200 }
189 ret = 0; 201 ret = 0;
190 202
191 if(fseeko64((FILE *)stream, offset, fseek_origin) != 0) 203 if(FSEEKO_FUNC((FILE *)stream, offset, fseek_origin) != 0)
192 ret = -1; 204 ret = -1;
193 205
194 return ret; 206 return ret;
diff --git a/zlib/contrib/minizip/ioapi.h b/zlib/contrib/minizip/ioapi.h
index 8309c4cf8f4..8dcbdb06e35 100644
--- a/zlib/contrib/minizip/ioapi.h
+++ b/zlib/contrib/minizip/ioapi.h
@@ -21,7 +21,7 @@
21#ifndef _ZLIBIOAPI64_H 21#ifndef _ZLIBIOAPI64_H
22#define _ZLIBIOAPI64_H 22#define _ZLIBIOAPI64_H
23 23
24#if (!defined(_WIN32)) && (!defined(WIN32)) 24#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
25 25
26 // Linux needs this to support file operation on files larger then 4+GB 26 // Linux needs this to support file operation on files larger then 4+GB
27 // But might need better if/def to select just the platforms that needs them. 27 // But might need better if/def to select just the platforms that needs them.
@@ -38,6 +38,7 @@
38 #ifndef _FILE_OFFSET_BIT 38 #ifndef _FILE_OFFSET_BIT
39 #define _FILE_OFFSET_BIT 64 39 #define _FILE_OFFSET_BIT 64
40 #endif 40 #endif
41
41#endif 42#endif
42 43
43#include <stdio.h> 44#include <stdio.h>
@@ -49,6 +50,11 @@
49#define ftello64 ftell 50#define ftello64 ftell
50#define fseeko64 fseek 51#define fseeko64 fseek
51#else 52#else
53#ifdef __FreeBSD__
54#define fopen64 fopen
55#define ftello64 ftello
56#define fseeko64 fseeko
57#endif
52#ifdef _MSC_VER 58#ifdef _MSC_VER
53 #define fopen64 fopen 59 #define fopen64 fopen
54 #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) 60 #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC)))
@@ -85,6 +91,8 @@ typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
85typedef uint64_t ZPOS64_T; 91typedef uint64_t ZPOS64_T;
86#else 92#else
87 93
94/* Maximum unsigned 32-bit value used as placeholder for zip64 */
95#define MAXU32 0xffffffff
88 96
89#if defined(_MSC_VER) || defined(__BORLANDC__) 97#if defined(_MSC_VER) || defined(__BORLANDC__)
90typedef unsigned __int64 ZPOS64_T; 98typedef unsigned __int64 ZPOS64_T;
diff --git a/zlib/contrib/minizip/miniunz.c b/zlib/contrib/minizip/miniunz.c
index 9ed009fbd99..3d65401be5c 100644
--- a/zlib/contrib/minizip/miniunz.c
+++ b/zlib/contrib/minizip/miniunz.c
@@ -12,7 +12,7 @@
12 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) 12 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
13*/ 13*/
14 14
15#ifndef _WIN32 15#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
16 #ifndef __USE_FILE_OFFSET64 16 #ifndef __USE_FILE_OFFSET64
17 #define __USE_FILE_OFFSET64 17 #define __USE_FILE_OFFSET64
18 #endif 18 #endif
@@ -27,6 +27,18 @@
27 #endif 27 #endif
28#endif 28#endif
29 29
30#ifdef __APPLE__
31// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
32#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
33#define FTELLO_FUNC(stream) ftello(stream)
34#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
35#else
36#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
37#define FTELLO_FUNC(stream) ftello64(stream)
38#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
39#endif
40
41
30#include <stdio.h> 42#include <stdio.h>
31#include <stdlib.h> 43#include <stdlib.h>
32#include <string.h> 44#include <string.h>
@@ -34,14 +46,15 @@
34#include <errno.h> 46#include <errno.h>
35#include <fcntl.h> 47#include <fcntl.h>
36 48
37#ifdef unix 49#ifdef _WIN32
38# include <unistd.h>
39# include <utime.h>
40#else
41# include <direct.h> 50# include <direct.h>
42# include <io.h> 51# include <io.h>
52#else
53# include <unistd.h>
54# include <utime.h>
43#endif 55#endif
44 56
57
45#include "unzip.h" 58#include "unzip.h"
46 59
47#define CASESENSITIVITY (0) 60#define CASESENSITIVITY (0)
@@ -84,7 +97,7 @@ void change_file_date(filename,dosdate,tmu_date)
84 SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); 97 SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
85 CloseHandle(hFile); 98 CloseHandle(hFile);
86#else 99#else
87#ifdef unix 100#ifdef unix || __APPLE__
88 struct utimbuf ut; 101 struct utimbuf ut;
89 struct tm newdate; 102 struct tm newdate;
90 newdate.tm_sec = tmu_date.tm_sec; 103 newdate.tm_sec = tmu_date.tm_sec;
@@ -114,10 +127,10 @@ int mymkdir(dirname)
114 int ret=0; 127 int ret=0;
115#ifdef _WIN32 128#ifdef _WIN32
116 ret = _mkdir(dirname); 129 ret = _mkdir(dirname);
117#else 130#elif unix
118#ifdef unix 131 ret = mkdir (dirname,0775);
132#elif __APPLE__
119 ret = mkdir (dirname,0775); 133 ret = mkdir (dirname,0775);
120#endif
121#endif 134#endif
122 return ret; 135 return ret;
123} 136}
@@ -364,7 +377,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
364 { 377 {
365 char rep=0; 378 char rep=0;
366 FILE* ftestexist; 379 FILE* ftestexist;
367 ftestexist = fopen64(write_filename,"rb"); 380 ftestexist = FOPEN_FUNC(write_filename,"rb");
368 if (ftestexist!=NULL) 381 if (ftestexist!=NULL)
369 { 382 {
370 fclose(ftestexist); 383 fclose(ftestexist);
@@ -395,8 +408,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
395 408
396 if ((skip==0) && (err==UNZ_OK)) 409 if ((skip==0) && (err==UNZ_OK))
397 { 410 {
398 fout=fopen64(write_filename,"wb"); 411 fout=FOPEN_FUNC(write_filename,"wb");
399
400 /* some zipfile don't contain directory alone before file */ 412 /* some zipfile don't contain directory alone before file */
401 if ((fout==NULL) && ((*popt_extract_without_path)==0) && 413 if ((fout==NULL) && ((*popt_extract_without_path)==0) &&
402 (filename_withoutpath!=(char*)filename_inzip)) 414 (filename_withoutpath!=(char*)filename_inzip))
@@ -405,7 +417,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
405 *(filename_withoutpath-1)='\0'; 417 *(filename_withoutpath-1)='\0';
406 makedir(write_filename); 418 makedir(write_filename);
407 *(filename_withoutpath-1)=c; 419 *(filename_withoutpath-1)=c;
408 fout=fopen64(write_filename,"wb"); 420 fout=FOPEN_FUNC(write_filename,"wb");
409 } 421 }
410 422
411 if (fout==NULL) 423 if (fout==NULL)
diff --git a/zlib/contrib/minizip/minizip.c b/zlib/contrib/minizip/minizip.c
index 7a4fa5a643e..4288962ecef 100644
--- a/zlib/contrib/minizip/minizip.c
+++ b/zlib/contrib/minizip/minizip.c
@@ -13,7 +13,7 @@
13*/ 13*/
14 14
15 15
16#ifndef _WIN32 16#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
17 #ifndef __USE_FILE_OFFSET64 17 #ifndef __USE_FILE_OFFSET64
18 #define __USE_FILE_OFFSET64 18 #define __USE_FILE_OFFSET64
19 #endif 19 #endif
@@ -28,6 +28,19 @@
28 #endif 28 #endif
29#endif 29#endif
30 30
31#ifdef __APPLE__
32// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
33#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
34#define FTELLO_FUNC(stream) ftello(stream)
35#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)
36#else
37#define FOPEN_FUNC(filename, mode) fopen64(filename, mode)
38#define FTELLO_FUNC(stream) ftello64(stream)
39#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin)
40#endif
41
42
43
31#include <stdio.h> 44#include <stdio.h>
32#include <stdlib.h> 45#include <stdlib.h>
33#include <string.h> 46#include <string.h>
@@ -35,14 +48,14 @@
35#include <errno.h> 48#include <errno.h>
36#include <fcntl.h> 49#include <fcntl.h>
37 50
38#ifdef unix 51#ifdef _WIN32
52# include <direct.h>
53# include <io.h>
54#else
39# include <unistd.h> 55# include <unistd.h>
40# include <utime.h> 56# include <utime.h>
41# include <sys/types.h> 57# include <sys/types.h>
42# include <sys/stat.h> 58# include <sys/stat.h>
43#else
44# include <direct.h>
45# include <io.h>
46#endif 59#endif
47 60
48#include "zip.h" 61#include "zip.h"
@@ -81,7 +94,7 @@ uLong filetime(f, tmzip, dt)
81 return ret; 94 return ret;
82} 95}
83#else 96#else
84#ifdef unix 97#ifdef unix || __APPLE__
85uLong filetime(f, tmzip, dt) 98uLong filetime(f, tmzip, dt)
86 char *f; /* name of file to get info on */ 99 char *f; /* name of file to get info on */
87 tm_zip *tmzip; /* return value: access, modific. and creation times */ 100 tm_zip *tmzip; /* return value: access, modific. and creation times */
@@ -142,7 +155,7 @@ int check_exist_file(filename)
142{ 155{
143 FILE* ftestexist; 156 FILE* ftestexist;
144 int ret = 1; 157 int ret = 1;
145 ftestexist = fopen64(filename,"rb"); 158 ftestexist = FOPEN_FUNC(filename,"rb");
146 if (ftestexist==NULL) 159 if (ftestexist==NULL)
147 ret = 0; 160 ret = 0;
148 else 161 else
@@ -173,7 +186,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
173{ 186{
174 unsigned long calculate_crc=0; 187 unsigned long calculate_crc=0;
175 int err=ZIP_OK; 188 int err=ZIP_OK;
176 FILE * fin = fopen64(filenameinzip,"rb"); 189 FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
190
177 unsigned long size_read = 0; 191 unsigned long size_read = 0;
178 unsigned long total_read = 0; 192 unsigned long total_read = 0;
179 if (fin==NULL) 193 if (fin==NULL)
@@ -211,13 +225,12 @@ int isLargeFile(const char* filename)
211{ 225{
212 int largeFile = 0; 226 int largeFile = 0;
213 ZPOS64_T pos = 0; 227 ZPOS64_T pos = 0;
214 FILE* pFile = fopen64(filename, "rb"); 228 FILE* pFile = FOPEN_FUNC(filename, "rb");
215 229
216 if(pFile != NULL) 230 if(pFile != NULL)
217 { 231 {
218 int n = fseeko64(pFile, 0, SEEK_END); 232 int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
219 233 pos = FTELLO_FUNC(pFile);
220 pos = ftello64(pFile);
221 234
222 printf("File : %s is %lld bytes\n", filename, pos); 235 printf("File : %s is %lld bytes\n", filename, pos);
223 236
@@ -447,7 +460,7 @@ int main(argc,argv)
447 printf("error in opening %s in zipfile\n",filenameinzip); 460 printf("error in opening %s in zipfile\n",filenameinzip);
448 else 461 else
449 { 462 {
450 fin = fopen64(filenameinzip,"rb"); 463 fin = FOPEN_FUNC(filenameinzip,"rb");
451 if (fin==NULL) 464 if (fin==NULL)
452 { 465 {
453 err=ZIP_ERRNO; 466 err=ZIP_ERRNO;
diff --git a/zlib/contrib/minizip/minizip.pc.in b/zlib/contrib/minizip/minizip.pc.in
new file mode 100644
index 00000000000..69b5b7fdcb3
--- /dev/null
+++ b/zlib/contrib/minizip/minizip.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@/minizip
5
6Name: minizip
7Description: Minizip zip file manipulation library
8Requires:
9Version: @PACKAGE_VERSION@
10Libs: -L${libdir} -lminizip
11Libs.private: -lz
12Cflags: -I${includedir}
diff --git a/zlib/contrib/minizip/mztools.c b/zlib/contrib/minizip/mztools.c
index f9092e65ae6..96891c2e0b7 100644
--- a/zlib/contrib/minizip/mztools.c
+++ b/zlib/contrib/minizip/mztools.c
@@ -42,7 +42,7 @@ uLong* bytesRecovered;
42 int entries = 0; 42 int entries = 0;
43 uLong totalBytes = 0; 43 uLong totalBytes = 0;
44 char header[30]; 44 char header[30];
45 char filename[256]; 45 char filename[1024];
46 char extra[1024]; 46 char extra[1024];
47 int offset = 0; 47 int offset = 0;
48 int offsetCD = 0; 48 int offsetCD = 0;
@@ -73,9 +73,14 @@ uLong* bytesRecovered;
73 73
74 /* Filename */ 74 /* Filename */
75 if (fnsize > 0) { 75 if (fnsize > 0) {
76 if (fread(filename, 1, fnsize, fpZip) == fnsize) { 76 if (fnsize < sizeof(filename)) {
77 if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { 77 if (fread(filename, 1, fnsize, fpZip) == fnsize) {
78 offset += fnsize; 78 if (fwrite(filename, 1, fnsize, fpOut) == fnsize) {
79 offset += fnsize;
80 } else {
81 err = Z_ERRNO;
82 break;
83 }
79 } else { 84 } else {
80 err = Z_ERRNO; 85 err = Z_ERRNO;
81 break; 86 break;
@@ -91,9 +96,14 @@ uLong* bytesRecovered;
91 96
92 /* Extra field */ 97 /* Extra field */
93 if (extsize > 0) { 98 if (extsize > 0) {
94 if (fread(extra, 1, extsize, fpZip) == extsize) { 99 if (extsize < sizeof(extra)) {
95 if (fwrite(extra, 1, extsize, fpOut) == extsize) { 100 if (fread(extra, 1, extsize, fpZip) == extsize) {
96 offset += extsize; 101 if (fwrite(extra, 1, extsize, fpOut) == extsize) {
102 offset += extsize;
103 } else {
104 err = Z_ERRNO;
105 break;
106 }
97 } else { 107 } else {
98 err = Z_ERRNO; 108 err = Z_ERRNO;
99 break; 109 break;
diff --git a/zlib/contrib/minizip/mztools.h b/zlib/contrib/minizip/mztools.h
index 88b34592bf5..a49a426ec2f 100644
--- a/zlib/contrib/minizip/mztools.h
+++ b/zlib/contrib/minizip/mztools.h
@@ -28,4 +28,10 @@ extern int ZEXPORT unzRepair(const char* file,
28 uLong* nRecovered, 28 uLong* nRecovered,
29 uLong* bytesRecovered); 29 uLong* bytesRecovered);
30 30
31
32#ifdef __cplusplus
33}
34#endif
35
36
31#endif 37#endif
diff --git a/zlib/contrib/minizip/unzip.c b/zlib/contrib/minizip/unzip.c
index 7617f41f1cc..affad4bfeb2 100644
--- a/zlib/contrib/minizip/unzip.c
+++ b/zlib/contrib/minizip/unzip.c
@@ -1040,26 +1040,26 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
1040 { 1040 {
1041 uLong uL; 1041 uLong uL;
1042 1042
1043 if(file_info.uncompressed_size == (ZPOS64_T)(unsigned long)-1) 1043 if(file_info.uncompressed_size == MAXU32)
1044 { 1044 {
1045 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) 1045 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
1046 err=UNZ_ERRNO; 1046 err=UNZ_ERRNO;
1047 } 1047 }
1048 1048
1049 if(file_info.compressed_size == (ZPOS64_T)(unsigned long)-1) 1049 if(file_info.compressed_size == MAXU32)
1050 { 1050 {
1051 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) 1051 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
1052 err=UNZ_ERRNO; 1052 err=UNZ_ERRNO;
1053 } 1053 }
1054 1054
1055 if(file_info_internal.offset_curfile == (ZPOS64_T)(unsigned long)-1) 1055 if(file_info_internal.offset_curfile == MAXU32)
1056 { 1056 {
1057 /* Relative Header offset */ 1057 /* Relative Header offset */
1058 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) 1058 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
1059 err=UNZ_ERRNO; 1059 err=UNZ_ERRNO;
1060 } 1060 }
1061 1061
1062 if(file_info.disk_num_start == (unsigned long)-1) 1062 if(file_info.disk_num_start == MAXU32)
1063 { 1063 {
1064 /* Disk Start Number */ 1064 /* Disk Start Number */
1065 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) 1065 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
@@ -1145,7 +1145,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
1145 szFileName,fileNameBufferSize, 1145 szFileName,fileNameBufferSize,
1146 extraField,extraFieldBufferSize, 1146 extraField,extraFieldBufferSize,
1147 szComment,commentBufferSize); 1147 szComment,commentBufferSize);
1148 if (err==UNZ_OK) 1148 if ((err==UNZ_OK) && (pfile_info != NULL))
1149 { 1149 {
1150 pfile_info->version = file_info64.version; 1150 pfile_info->version = file_info64.version;
1151 pfile_info->version_needed = file_info64.version_needed; 1151 pfile_info->version_needed = file_info64.version_needed;
@@ -1696,7 +1696,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
1696 return UNZ_PARAMERROR; 1696 return UNZ_PARAMERROR;
1697 1697
1698 1698
1699 if ((pfile_in_zip_read_info->read_buffer == NULL)) 1699 if (pfile_in_zip_read_info->read_buffer == NULL)
1700 return UNZ_END_OF_LIST_OF_FILE; 1700 return UNZ_END_OF_LIST_OF_FILE;
1701 if (len==0) 1701 if (len==0)
1702 return 0; 1702 return 0;
diff --git a/zlib/contrib/minizip/zip.c b/zlib/contrib/minizip/zip.c
index 3c34fc8bd49..147934c75d3 100644
--- a/zlib/contrib/minizip/zip.c
+++ b/zlib/contrib/minizip/zip.c
@@ -1067,6 +1067,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
1067 int err = ZIP_OK; 1067 int err = ZIP_OK;
1068 1068
1069# ifdef NOCRYPT 1069# ifdef NOCRYPT
1070 (crcForCrypting);
1070 if (password != NULL) 1071 if (password != NULL)
1071 return ZIP_PARAMERROR; 1072 return ZIP_PARAMERROR;
1072# endif 1073# endif
@@ -1114,9 +1115,9 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
1114 zi->ci.flag = flagBase; 1115 zi->ci.flag = flagBase;
1115 if ((level==8) || (level==9)) 1116 if ((level==8) || (level==9))
1116 zi->ci.flag |= 2; 1117 zi->ci.flag |= 2;
1117 if ((level==2)) 1118 if (level==2)
1118 zi->ci.flag |= 4; 1119 zi->ci.flag |= 4;
1119 if ((level==1)) 1120 if (level==1)
1120 zi->ci.flag |= 6; 1121 zi->ci.flag |= 6;
1121 if (password != NULL) 1122 if (password != NULL)
1122 zi->ci.flag |= 1; 1123 zi->ci.flag |= 1;
@@ -1710,7 +1711,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
1710 if (err==ZIP_OK) 1711 if (err==ZIP_OK)
1711 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ 1712 err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */
1712 1713
1713 if(uncompressed_size >= 0xffffffff) 1714 if(uncompressed_size >= 0xffffffff || compressed_size >= 0xffffffff )
1714 { 1715 {
1715 if(zi->ci.pos_zip64extrainfo > 0) 1716 if(zi->ci.pos_zip64extrainfo > 0)
1716 { 1717 {
@@ -1724,6 +1725,8 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
1724 if (err==ZIP_OK) /* uncompressed size, unknown */ 1725 if (err==ZIP_OK) /* uncompressed size, unknown */
1725 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8); 1726 err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8);
1726 } 1727 }
1728 else
1729 err = ZIP_BADZIPFILE; // Caller passed zip64 = 0, so no room for zip64 info -> fatal
1727 } 1730 }
1728 else 1731 else
1729 { 1732 {
@@ -1852,7 +1855,7 @@ int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir,
1852 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4); 1855 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4);
1853 } 1856 }
1854 else 1857 else
1855 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); 1858 err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4);
1856 } 1859 }
1857 1860
1858 return err; 1861 return err;
@@ -1919,7 +1922,7 @@ extern int ZEXPORT zipClose (zipFile file, const char* global_comment)
1919 free_linkedlist(&(zi->central_dir)); 1922 free_linkedlist(&(zi->central_dir));
1920 1923
1921 pos = centraldir_pos_inzip - zi->add_position_when_writting_offset; 1924 pos = centraldir_pos_inzip - zi->add_position_when_writting_offset;
1922 if(pos >= 0xffffffff) 1925 if(pos >= 0xffffffff || zi->number_entry > 0xFFFF)
1923 { 1926 {
1924 ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); 1927 ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream);
1925 Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); 1928 Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip);
diff --git a/zlib/contrib/pascal/zlibd32.mak b/zlib/contrib/pascal/zlibd32.mak
index 0d0699a69a3..9bb00b7cc42 100644
--- a/zlib/contrib/pascal/zlibd32.mak
+++ b/zlib/contrib/pascal/zlibd32.mak
@@ -63,9 +63,9 @@ uncompr.obj: uncompr.c zlib.h zconf.h
63 63
64zutil.obj: zutil.c zutil.h zlib.h zconf.h 64zutil.obj: zutil.c zutil.h zlib.h zconf.h
65 65
66example.obj: example.c zlib.h zconf.h 66example.obj: test/example.c zlib.h zconf.h
67 67
68minigzip.obj: minigzip.c zlib.h zconf.h 68minigzip.obj: test/minigzip.c zlib.h zconf.h
69 69
70 70
71# For the sake of the old Borland make, 71# For the sake of the old Borland make,
diff --git a/zlib/contrib/pascal/zlibpas.pas b/zlib/contrib/pascal/zlibpas.pas
index 637ae3a3f8e..7abd862ae66 100644
--- a/zlib/contrib/pascal/zlibpas.pas
+++ b/zlib/contrib/pascal/zlibpas.pas
@@ -10,7 +10,8 @@ unit zlibpas;
10interface 10interface
11 11
12const 12const
13 ZLIB_VERSION = '1.2.5'; 13 ZLIB_VERSION = '1.2.7';
14 ZLIB_VERNUM = $1270;
14 15
15type 16type
16 alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; 17 alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
@@ -45,6 +46,23 @@ type
45 reserved: LongInt; (* reserved for future use *) 46 reserved: LongInt; (* reserved for future use *)
46 end; 47 end;
47 48
49 gz_headerp = ^gz_header;
50 gz_header = packed record
51 text: Integer; (* true if compressed data believed to be text *)
52 time: LongInt; (* modification time *)
53 xflags: Integer; (* extra flags (not used when writing a gzip file) *)
54 os: Integer; (* operating system *)
55 extra: PChar; (* pointer to extra field or Z_NULL if none *)
56 extra_len: Integer; (* extra field length (valid if extra != Z_NULL) *)
57 extra_max: Integer; (* space at extra (only when reading header) *)
58 name: PChar; (* pointer to zero-terminated file name or Z_NULL *)
59 name_max: Integer; (* space at name (only when reading header) *)
60 comment: PChar; (* pointer to zero-terminated comment or Z_NULL *)
61 comm_max: Integer; (* space at comment (only when reading header) *)
62 hcrc: Integer; (* true if there was or will be a header crc *)
63 done: Integer; (* true when done reading gzip header *)
64 end;
65
48(* constants *) 66(* constants *)
49const 67const
50 Z_NO_FLUSH = 0; 68 Z_NO_FLUSH = 0;
@@ -52,6 +70,8 @@ const
52 Z_SYNC_FLUSH = 2; 70 Z_SYNC_FLUSH = 2;
53 Z_FULL_FLUSH = 3; 71 Z_FULL_FLUSH = 3;
54 Z_FINISH = 4; 72 Z_FINISH = 4;
73 Z_BLOCK = 5;
74 Z_TREES = 6;
55 75
56 Z_OK = 0; 76 Z_OK = 0;
57 Z_STREAM_END = 1; 77 Z_STREAM_END = 1;
@@ -71,9 +91,11 @@ const
71 Z_FILTERED = 1; 91 Z_FILTERED = 1;
72 Z_HUFFMAN_ONLY = 2; 92 Z_HUFFMAN_ONLY = 2;
73 Z_RLE = 3; 93 Z_RLE = 3;
94 Z_FIXED = 4;
74 Z_DEFAULT_STRATEGY = 0; 95 Z_DEFAULT_STRATEGY = 0;
75 96
76 Z_BINARY = 0; 97 Z_BINARY = 0;
98 Z_TEXT = 1;
77 Z_ASCII = 1; 99 Z_ASCII = 1;
78 Z_UNKNOWN = 2; 100 Z_UNKNOWN = 2;
79 101
@@ -96,14 +118,21 @@ function deflateSetDictionary(var strm: z_stream; const dictionary: PChar;
96function deflateCopy(var dest, source: z_stream): Integer; 118function deflateCopy(var dest, source: z_stream): Integer;
97function deflateReset(var strm: z_stream): Integer; 119function deflateReset(var strm: z_stream): Integer;
98function deflateParams(var strm: z_stream; level, strategy: Integer): Integer; 120function deflateParams(var strm: z_stream; level, strategy: Integer): Integer;
121function deflateTune(var strm: z_stream; good_length, max_lazy, nice_length, max_chain: Integer): Integer;
99function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt; 122function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt;
123function deflatePending(var strm: z_stream; var pending: Integer; var bits: Integer): Integer;
100function deflatePrime(var strm: z_stream; bits, value: Integer): Integer; 124function deflatePrime(var strm: z_stream; bits, value: Integer): Integer;
125function deflateSetHeader(var strm: z_stream; head: gz_header): Integer;
101function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; 126function inflateInit2(var strm: z_stream; windowBits: Integer): Integer;
102function inflateSetDictionary(var strm: z_stream; const dictionary: PChar; 127function inflateSetDictionary(var strm: z_stream; const dictionary: PChar;
103 dictLength: Integer): Integer; 128 dictLength: Integer): Integer;
104function inflateSync(var strm: z_stream): Integer; 129function inflateSync(var strm: z_stream): Integer;
105function inflateCopy(var dest, source: z_stream): Integer; 130function inflateCopy(var dest, source: z_stream): Integer;
106function inflateReset(var strm: z_stream): Integer; 131function inflateReset(var strm: z_stream): Integer;
132function inflateReset2(var strm: z_stream; windowBits: Integer): Integer;
133function inflatePrime(var strm: z_stream; bits, value: Integer): Integer;
134function inflateMark(var strm: z_stream): LongInt;
135function inflateGetHeader(var strm: z_stream; var head: gz_header): Integer;
107function inflateBackInit(var strm: z_stream; 136function inflateBackInit(var strm: z_stream;
108 windowBits: Integer; window: PChar): Integer; 137 windowBits: Integer; window: PChar): Integer;
109function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer; 138function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer;
@@ -123,7 +152,9 @@ function uncompress(dest: PChar; var destLen: LongInt;
123 152
124(* checksum functions *) 153(* checksum functions *)
125function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; 154function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt;
155function adler32_combine(adler1, adler2, len2: LongInt): LongInt;
126function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt; 156function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt;
157function crc32_combine(crc1, crc2, len2: LongInt): LongInt;
127 158
128(* various hacks, don't look :) *) 159(* various hacks, don't look :) *)
129function deflateInit_(var strm: z_stream; level: Integer; 160function deflateInit_(var strm: z_stream; level: Integer;
@@ -155,10 +186,12 @@ implementation
155{$L zutil.obj} 186{$L zutil.obj}
156 187
157function adler32; external; 188function adler32; external;
189function adler32_combine; external;
158function compress; external; 190function compress; external;
159function compress2; external; 191function compress2; external;
160function compressBound; external; 192function compressBound; external;
161function crc32; external; 193function crc32; external;
194function crc32_combine; external;
162function deflate; external; 195function deflate; external;
163function deflateBound; external; 196function deflateBound; external;
164function deflateCopy; external; 197function deflateCopy; external;
@@ -166,18 +199,25 @@ function deflateEnd; external;
166function deflateInit_; external; 199function deflateInit_; external;
167function deflateInit2_; external; 200function deflateInit2_; external;
168function deflateParams; external; 201function deflateParams; external;
202function deflatePending; external;
169function deflatePrime; external; 203function deflatePrime; external;
170function deflateReset; external; 204function deflateReset; external;
171function deflateSetDictionary; external; 205function deflateSetDictionary; external;
206function deflateSetHeader; external;
207function deflateTune; external;
172function inflate; external; 208function inflate; external;
173function inflateBack; external; 209function inflateBack; external;
174function inflateBackEnd; external; 210function inflateBackEnd; external;
175function inflateBackInit_; external; 211function inflateBackInit_; external;
176function inflateCopy; external; 212function inflateCopy; external;
177function inflateEnd; external; 213function inflateEnd; external;
214function inflateGetHeader; external;
178function inflateInit_; external; 215function inflateInit_; external;
179function inflateInit2_; external; 216function inflateInit2_; external;
217function inflateMark; external;
218function inflatePrime; external;
180function inflateReset; external; 219function inflateReset; external;
220function inflateReset2; external;
181function inflateSetDictionary; external; 221function inflateSetDictionary; external;
182function inflateSync; external; 222function inflateSync; external;
183function uncompress; external; 223function uncompress; external;
diff --git a/zlib/contrib/puff/Makefile b/zlib/contrib/puff/Makefile
index b6b69404c74..0e2594c8088 100644
--- a/zlib/contrib/puff/Makefile
+++ b/zlib/contrib/puff/Makefile
@@ -1,8 +1,42 @@
1puff: puff.c puff.h 1CFLAGS=-O
2 cc -DTEST -o puff puff.c 2
3puff: puff.o pufftest.o
4
5puff.o: puff.h
6
7pufftest.o: puff.h
3 8
4test: puff 9test: puff
5 puff zeros.raw 10 puff zeros.raw
6 11
12puft: puff.c puff.h pufftest.o
13 cc -fprofile-arcs -ftest-coverage -o puft puff.c pufftest.o
14
15# puff full coverage test (should say 100%)
16cov: puft
17 @rm -f *.gcov *.gcda
18 @puft -w zeros.raw 2>&1 | cat > /dev/null
19 @echo '04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
20 @echo '00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
21 @echo '00 00 00 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 254
22 @echo '00 01 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
23 @echo '01 01 00 fe ff 0a' | xxd -r -p | puft -f 2>&1 | cat > /dev/null
24 @echo '02 7e ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246
25 @echo '02' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
26 @echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2
27 @echo '04 80 49 92 24 49 92 24 71 ff ff 93 11 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 249
28 @echo '04 c0 81 08 00 00 00 00 20 7f eb 0b 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246
29 @echo '0b 00 00' | xxd -r -p | puft -f 2>&1 | cat > /dev/null
30 @echo '1a 07' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246
31 @echo '0c c0 81 00 00 00 00 00 90 ff 6b 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 245
32 @puft -f zeros.raw 2>&1 | cat > /dev/null
33 @echo 'fc 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 253
34 @echo '04 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 252
35 @echo '04 00 24 49' | xxd -r -p | puft 2> /dev/null || test $$? -eq 251
36 @echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 84' | xxd -r -p | puft 2> /dev/null || test $$? -eq 248
37 @echo '04 00 24 e9 ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 250
38 @echo '04 00 24 e9 ff 6d' | xxd -r -p | puft 2> /dev/null || test $$? -eq 247
39 @gcov -n puff.c
40
7clean: 41clean:
8 rm -f puff puff.o 42 rm -f puff puft *.o *.gc*
diff --git a/zlib/contrib/puff/puff.c b/zlib/contrib/puff/puff.c
index 650694e9ed8..df8470c9373 100644
--- a/zlib/contrib/puff/puff.c
+++ b/zlib/contrib/puff/puff.c
@@ -2,7 +2,7 @@
2 * puff.c 2 * puff.c
3 * Copyright (C) 2002-2010 Mark Adler 3 * Copyright (C) 2002-2010 Mark Adler
4 * For conditions of distribution and use, see copyright notice in puff.h 4 * For conditions of distribution and use, see copyright notice in puff.h
5 * version 2.1, 4 Apr 2010 5 * version 2.2, 25 Apr 2010
6 * 6 *
7 * puff.c is a simple inflate written to be an unambiguous way to specify the 7 * puff.c is a simple inflate written to be an unambiguous way to specify the
8 * deflate format. It is not written for speed but rather simplicity. As a 8 * deflate format. It is not written for speed but rather simplicity. As a
@@ -49,9 +49,9 @@
49 * - Fix fixed codes table error 49 * - Fix fixed codes table error
50 * - Provide a scanning mode for determining size of 50 * - Provide a scanning mode for determining size of
51 * uncompressed data 51 * uncompressed data
52 * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Jean-loup] 52 * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Gailly]
53 * - Add a puff.h file for the interface 53 * - Add a puff.h file for the interface
54 * - Add braces in puff() for else do [Jean-loup] 54 * - Add braces in puff() for else do [Gailly]
55 * - Use indexes instead of pointers for readability 55 * - Use indexes instead of pointers for readability
56 * 1.4 31 Mar 2002 - Simplify construct() code set check 56 * 1.4 31 Mar 2002 - Simplify construct() code set check
57 * - Fix some comments 57 * - Fix some comments
@@ -69,13 +69,19 @@
69 * - Allow TEST code to read from piped stdin 69 * - Allow TEST code to read from piped stdin
70 * 2.1 4 Apr 2010 - Avoid variable initialization for happier compilers 70 * 2.1 4 Apr 2010 - Avoid variable initialization for happier compilers
71 * - Avoid unsigned comparisons for even happier compilers 71 * - Avoid unsigned comparisons for even happier compilers
72 * 2.2 25 Apr 2010 - Fix bug in variable initializations [Oberhumer]
73 * - Add const where appropriate [Oberhumer]
74 * - Split if's and ?'s for coverage testing
75 * - Break out test code to separate file
76 * - Move NIL to puff.h
77 * - Allow incomplete code only if single code length is 1
78 * - Add full code coverage test to Makefile
72 */ 79 */
73 80
74#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */ 81#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
75#include "puff.h" /* prototype for puff() */ 82#include "puff.h" /* prototype for puff() */
76 83
77#define local static /* for local function definitions */ 84#define local static /* for local function definitions */
78#define NIL ((unsigned char *)0) /* for no output option */
79 85
80/* 86/*
81 * Maximums for allocations and loops. It is not useful to change these -- 87 * Maximums for allocations and loops. It is not useful to change these --
@@ -95,7 +101,7 @@ struct state {
95 unsigned long outcnt; /* bytes written to out so far */ 101 unsigned long outcnt; /* bytes written to out so far */
96 102
97 /* input state */ 103 /* input state */
98 unsigned char *in; /* input buffer */ 104 const unsigned char *in; /* input buffer */
99 unsigned long inlen; /* available input at in */ 105 unsigned long inlen; /* available input at in */
100 unsigned long incnt; /* bytes read so far */ 106 unsigned long incnt; /* bytes read so far */
101 int bitbuf; /* bit buffer */ 107 int bitbuf; /* bit buffer */
@@ -123,7 +129,8 @@ local int bits(struct state *s, int need)
123 /* load at least need bits into val */ 129 /* load at least need bits into val */
124 val = s->bitbuf; 130 val = s->bitbuf;
125 while (s->bitcnt < need) { 131 while (s->bitcnt < need) {
126 if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ 132 if (s->incnt == s->inlen)
133 longjmp(s->env, 1); /* out of input */
127 val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */ 134 val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */
128 s->bitcnt += 8; 135 s->bitcnt += 8;
129 } 136 }
@@ -162,7 +169,8 @@ local int stored(struct state *s)
162 s->bitcnt = 0; 169 s->bitcnt = 0;
163 170
164 /* get length and check against its one's complement */ 171 /* get length and check against its one's complement */
165 if (s->incnt + 4 > s->inlen) return 2; /* not enough input */ 172 if (s->incnt + 4 > s->inlen)
173 return 2; /* not enough input */
166 len = s->in[s->incnt++]; 174 len = s->in[s->incnt++];
167 len |= s->in[s->incnt++] << 8; 175 len |= s->in[s->incnt++] << 8;
168 if (s->in[s->incnt++] != (~len & 0xff) || 176 if (s->in[s->incnt++] != (~len & 0xff) ||
@@ -170,7 +178,8 @@ local int stored(struct state *s)
170 return -2; /* didn't match complement! */ 178 return -2; /* didn't match complement! */
171 179
172 /* copy len bytes from in to out */ 180 /* copy len bytes from in to out */
173 if (s->incnt + len > s->inlen) return 2; /* not enough input */ 181 if (s->incnt + len > s->inlen)
182 return 2; /* not enough input */
174 if (s->out != NIL) { 183 if (s->out != NIL) {
175 if (s->outcnt + len > s->outlen) 184 if (s->outcnt + len > s->outlen)
176 return 1; /* not enough output space */ 185 return 1; /* not enough output space */
@@ -222,7 +231,7 @@ struct huffman {
222 * in the deflate format. See the format notes for fixed() and dynamic(). 231 * in the deflate format. See the format notes for fixed() and dynamic().
223 */ 232 */
224#ifdef SLOW 233#ifdef SLOW
225local int decode(struct state *s, struct huffman *h) 234local int decode(struct state *s, const struct huffman *h)
226{ 235{
227 int len; /* current number of bits in code */ 236 int len; /* current number of bits in code */
228 int code; /* len bits being decoded */ 237 int code; /* len bits being decoded */
@@ -250,7 +259,7 @@ local int decode(struct state *s, struct huffman *h)
250 * a few percent larger. 259 * a few percent larger.
251 */ 260 */
252#else /* !SLOW */ 261#else /* !SLOW */
253local int decode(struct state *s, struct huffman *h) 262local int decode(struct state *s, const struct huffman *h)
254{ 263{
255 int len; /* current number of bits in code */ 264 int len; /* current number of bits in code */
256 int code; /* len bits being decoded */ 265 int code; /* len bits being decoded */
@@ -283,10 +292,13 @@ local int decode(struct state *s, struct huffman *h)
283 len++; 292 len++;
284 } 293 }
285 left = (MAXBITS+1) - len; 294 left = (MAXBITS+1) - len;
286 if (left == 0) break; 295 if (left == 0)
287 if (s->incnt == s->inlen) longjmp(s->env, 1); /* out of input */ 296 break;
297 if (s->incnt == s->inlen)
298 longjmp(s->env, 1); /* out of input */
288 bitbuf = s->in[s->incnt++]; 299 bitbuf = s->in[s->incnt++];
289 if (left > 8) left = 8; 300 if (left > 8)
301 left = 8;
290 } 302 }
291 return -10; /* ran out of codes */ 303 return -10; /* ran out of codes */
292} 304}
@@ -324,7 +336,7 @@ local int decode(struct state *s, struct huffman *h)
324 * - Within a given code length, the symbols are kept in ascending order for 336 * - Within a given code length, the symbols are kept in ascending order for
325 * the code bits definition. 337 * the code bits definition.
326 */ 338 */
327local int construct(struct huffman *h, short *length, int n) 339local int construct(struct huffman *h, const short *length, int n)
328{ 340{
329 int symbol; /* current symbol when stepping through length[] */ 341 int symbol; /* current symbol when stepping through length[] */
330 int len; /* current length when stepping through h->count[] */ 342 int len; /* current length when stepping through h->count[] */
@@ -344,7 +356,8 @@ local int construct(struct huffman *h, short *length, int n)
344 for (len = 1; len <= MAXBITS; len++) { 356 for (len = 1; len <= MAXBITS; len++) {
345 left <<= 1; /* one more bit, double codes left */ 357 left <<= 1; /* one more bit, double codes left */
346 left -= h->count[len]; /* deduct count from possible codes */ 358 left -= h->count[len]; /* deduct count from possible codes */
347 if (left < 0) return left; /* over-subscribed--return negative */ 359 if (left < 0)
360 return left; /* over-subscribed--return negative */
348 } /* left > 0 means incomplete */ 361 } /* left > 0 means incomplete */
349 362
350 /* generate offsets into symbol table for each length for sorting */ 363 /* generate offsets into symbol table for each length for sorting */
@@ -420,8 +433,8 @@ local int construct(struct huffman *h, short *length, int n)
420 * defined to do the wrong thing in this case. 433 * defined to do the wrong thing in this case.
421 */ 434 */
422local int codes(struct state *s, 435local int codes(struct state *s,
423 struct huffman *lencode, 436 const struct huffman *lencode,
424 struct huffman *distcode) 437 const struct huffman *distcode)
425{ 438{
426 int symbol; /* decoded symbol */ 439 int symbol; /* decoded symbol */
427 int len; /* length for copy */ 440 int len; /* length for copy */
@@ -444,11 +457,13 @@ local int codes(struct state *s,
444 /* decode literals and length/distance pairs */ 457 /* decode literals and length/distance pairs */
445 do { 458 do {
446 symbol = decode(s, lencode); 459 symbol = decode(s, lencode);
447 if (symbol < 0) return symbol; /* invalid symbol */ 460 if (symbol < 0)
461 return symbol; /* invalid symbol */
448 if (symbol < 256) { /* literal: symbol is the byte */ 462 if (symbol < 256) { /* literal: symbol is the byte */
449 /* write out the literal */ 463 /* write out the literal */
450 if (s->out != NIL) { 464 if (s->out != NIL) {
451 if (s->outcnt == s->outlen) return 1; 465 if (s->outcnt == s->outlen)
466 return 1;
452 s->out[s->outcnt] = symbol; 467 s->out[s->outcnt] = symbol;
453 } 468 }
454 s->outcnt++; 469 s->outcnt++;
@@ -456,12 +471,14 @@ local int codes(struct state *s,
456 else if (symbol > 256) { /* length */ 471 else if (symbol > 256) { /* length */
457 /* get and compute length */ 472 /* get and compute length */
458 symbol -= 257; 473 symbol -= 257;
459 if (symbol >= 29) return -10; /* invalid fixed code */ 474 if (symbol >= 29)
475 return -10; /* invalid fixed code */
460 len = lens[symbol] + bits(s, lext[symbol]); 476 len = lens[symbol] + bits(s, lext[symbol]);
461 477
462 /* get and check distance */ 478 /* get and check distance */
463 symbol = decode(s, distcode); 479 symbol = decode(s, distcode);
464 if (symbol < 0) return symbol; /* invalid symbol */ 480 if (symbol < 0)
481 return symbol; /* invalid symbol */
465 dist = dists[symbol] + bits(s, dext[symbol]); 482 dist = dists[symbol] + bits(s, dext[symbol]);
466#ifndef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR 483#ifndef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
467 if (dist > s->outcnt) 484 if (dist > s->outcnt)
@@ -470,13 +487,15 @@ local int codes(struct state *s,
470 487
471 /* copy length bytes from distance bytes back */ 488 /* copy length bytes from distance bytes back */
472 if (s->out != NIL) { 489 if (s->out != NIL) {
473 if (s->outcnt + len > s->outlen) return 1; 490 if (s->outcnt + len > s->outlen)
491 return 1;
474 while (len--) { 492 while (len--) {
475 s->out[s->outcnt] = 493 s->out[s->outcnt] =
476#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR 494#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
477 dist > s->outcnt ? 0 : 495 dist > s->outcnt ?
496 0 :
478#endif 497#endif
479 s->out[s->outcnt - dist]; 498 s->out[s->outcnt - dist];
480 s->outcnt++; 499 s->outcnt++;
481 } 500 }
482 } 501 }
@@ -525,6 +544,12 @@ local int fixed(struct state *s)
525 int symbol; 544 int symbol;
526 short lengths[FIXLCODES]; 545 short lengths[FIXLCODES];
527 546
547 /* construct lencode and distcode */
548 lencode.count = lencnt;
549 lencode.symbol = lensym;
550 distcode.count = distcnt;
551 distcode.symbol = distsym;
552
528 /* literal/length table */ 553 /* literal/length table */
529 for (symbol = 0; symbol < 144; symbol++) 554 for (symbol = 0; symbol < 144; symbol++)
530 lengths[symbol] = 8; 555 lengths[symbol] = 8;
@@ -541,12 +566,6 @@ local int fixed(struct state *s)
541 lengths[symbol] = 5; 566 lengths[symbol] = 5;
542 construct(&distcode, lengths, MAXDCODES); 567 construct(&distcode, lengths, MAXDCODES);
543 568
544 /* construct lencode and distcode */
545 lencode.count = lencnt;
546 lencode.symbol = lensym;
547 distcode.count = distcnt;
548 distcode.symbol = distsym;
549
550 /* do this just once */ 569 /* do this just once */
551 virgin = 0; 570 virgin = 0;
552 } 571 }
@@ -675,7 +694,8 @@ local int dynamic(struct state *s)
675 694
676 /* build huffman table for code lengths codes (use lencode temporarily) */ 695 /* build huffman table for code lengths codes (use lencode temporarily) */
677 err = construct(&lencode, lengths, 19); 696 err = construct(&lencode, lengths, 19);
678 if (err != 0) return -4; /* require complete code set here */ 697 if (err != 0) /* require complete code set here */
698 return -4;
679 699
680 /* read length/literal and distance code length tables */ 700 /* read length/literal and distance code length tables */
681 index = 0; 701 index = 0;
@@ -689,7 +709,8 @@ local int dynamic(struct state *s)
689 else { /* repeat instruction */ 709 else { /* repeat instruction */
690 len = 0; /* assume repeating zeros */ 710 len = 0; /* assume repeating zeros */
691 if (symbol == 16) { /* repeat last length 3..6 times */ 711 if (symbol == 16) { /* repeat last length 3..6 times */
692 if (index == 0) return -5; /* no last length! */ 712 if (index == 0)
713 return -5; /* no last length! */
693 len = lengths[index - 1]; /* last length */ 714 len = lengths[index - 1]; /* last length */
694 symbol = 3 + bits(s, 2); 715 symbol = 3 + bits(s, 2);
695 } 716 }
@@ -710,13 +731,13 @@ local int dynamic(struct state *s)
710 731
711 /* build huffman table for literal/length codes */ 732 /* build huffman table for literal/length codes */
712 err = construct(&lencode, lengths, nlen); 733 err = construct(&lencode, lengths, nlen);
713 if (err < 0 || (err > 0 && nlen - lencode.count[0] != 1)) 734 if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
714 return -7; /* only allow incomplete codes if just one code */ 735 return -7; /* incomplete code ok only for single length 1 code */
715 736
716 /* build huffman table for distance codes */ 737 /* build huffman table for distance codes */
717 err = construct(&distcode, lengths + nlen, ndist); 738 err = construct(&distcode, lengths + nlen, ndist);
718 if (err < 0 || (err > 0 && ndist - distcode.count[0] != 1)) 739 if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
719 return -8; /* only allow incomplete codes if just one code */ 740 return -8; /* incomplete code ok only for single length 1 code */
720 741
721 /* decode data until end-of-block code */ 742 /* decode data until end-of-block code */
722 return codes(s, &lencode, &distcode); 743 return codes(s, &lencode, &distcode);
@@ -768,7 +789,7 @@ local int dynamic(struct state *s)
768 */ 789 */
769int puff(unsigned char *dest, /* pointer to destination pointer */ 790int puff(unsigned char *dest, /* pointer to destination pointer */
770 unsigned long *destlen, /* amount of output space */ 791 unsigned long *destlen, /* amount of output space */
771 unsigned char *source, /* pointer to source data pointer */ 792 const unsigned char *source, /* pointer to source data pointer */
772 unsigned long *sourcelen) /* amount of input available */ 793 unsigned long *sourcelen) /* amount of input available */
773{ 794{
774 struct state s; /* input/output state */ 795 struct state s; /* input/output state */
@@ -795,11 +816,15 @@ int puff(unsigned char *dest, /* pointer to destination pointer */
795 do { 816 do {
796 last = bits(&s, 1); /* one if last block */ 817 last = bits(&s, 1); /* one if last block */
797 type = bits(&s, 2); /* block type 0..3 */ 818 type = bits(&s, 2); /* block type 0..3 */
798 err = type == 0 ? stored(&s) : 819 err = type == 0 ?
799 (type == 1 ? fixed(&s) : 820 stored(&s) :
800 (type == 2 ? dynamic(&s) : 821 (type == 1 ?
801 -1)); /* type == 3, invalid */ 822 fixed(&s) :
802 if (err != 0) break; /* return with error */ 823 (type == 2 ?
824 dynamic(&s) :
825 -1)); /* type == 3, invalid */
826 if (err != 0)
827 break; /* return with error */
803 } while (!last); 828 } while (!last);
804 } 829 }
805 830
@@ -810,146 +835,3 @@ int puff(unsigned char *dest, /* pointer to destination pointer */
810 } 835 }
811 return err; 836 return err;
812} 837}
813
814#ifdef TEST
815/* Examples of how to use puff().
816
817 Usage: puff [-w] [-nnn] file
818 ... | puff [-w] [-nnn]
819
820 where file is the input file with deflate data, nnn is the number of bytes
821 of input to skip before inflating (e.g. to skip a zlib or gzip header), and
822 -w is used to write the decompressed data to stdout */
823
824#include <stdio.h>
825#include <stdlib.h>
826
827/* Return size times approximately the cube root of 2, keeping the result as 1,
828 3, or 5 times a power of 2 -- the result is always > size, until the result
829 is the maximum value of an unsigned long, where it remains. This is useful
830 to keep reallocations less than ~33% over the actual data. */
831local size_t bythirds(size_t size)
832{
833 int n;
834 size_t m;
835
836 m = size;
837 for (n = 0; m; n++)
838 m >>= 1;
839 if (n < 3)
840 return size + 1;
841 n -= 3;
842 m = size >> n;
843 m += m == 6 ? 2 : 1;
844 m <<= n;
845 return m > size ? m : (size_t)(-1);
846}
847
848/* Read the input file *name, or stdin if name is NULL, into allocated memory.
849 Reallocate to larger buffers until the entire file is read in. Return a
850 pointer to the allocated data, or NULL if there was a memory allocation
851 failure. *len is the number of bytes of data read from the input file (even
852 if load() returns NULL). If the input file was empty or could not be opened
853 or read, *len is zero. */
854local void *load(char *name, size_t *len)
855{
856 size_t size;
857 void *buf, *swap;
858 FILE *in;
859
860 *len = 0;
861 buf = malloc(size = 4096);
862 if (buf == NULL)
863 return NULL;
864 in = name == NULL ? stdin : fopen(name, "rb");
865 if (in != NULL) {
866 for (;;) {
867 *len += fread((char *)buf + *len, 1, size - *len, in);
868 if (*len < size) break;
869 size = bythirds(size);
870 if (size == *len || (swap = realloc(buf, size)) == NULL) {
871 free(buf);
872 buf = NULL;
873 break;
874 }
875 buf = swap;
876 }
877 fclose(in);
878 }
879 return buf;
880}
881
882int main(int argc, char **argv)
883{
884 int ret, put = 0;
885 unsigned skip = 0;
886 char *arg, *name = NULL;
887 unsigned char *source = NULL, *dest;
888 size_t len = 0;
889 unsigned long sourcelen, destlen;
890
891 /* process arguments */
892 while (arg = *++argv, --argc)
893 if (arg[0] == '-') {
894 if (arg[1] == 'w' && arg[2] == 0)
895 put = 1;
896 else if (arg[1] >= '0' && arg[1] <= '9')
897 skip = (unsigned)atoi(arg + 1);
898 else {
899 fprintf(stderr, "invalid option %s\n", arg);
900 return 3;
901 }
902 }
903 else if (name != NULL) {
904 fprintf(stderr, "only one file name allowed\n");
905 return 3;
906 }
907 else
908 name = arg;
909 source = load(name, &len);
910 if (source == NULL) {
911 fprintf(stderr, "memory allocation failure\n");
912 return 4;
913 }
914 if (len == 0) {
915 fprintf(stderr, "could not read %s, or it was empty\n",
916 name == NULL ? "<stdin>" : name);
917 free(source);
918 return 3;
919 }
920 if (skip >= len) {
921 fprintf(stderr, "skip request of %d leaves no input\n", skip);
922 free(source);
923 return 3;
924 }
925
926 /* test inflate data with offset skip */
927 len -= skip;
928 sourcelen = (unsigned long)len;
929 ret = puff(NIL, &destlen, source + skip, &sourcelen);
930 if (ret)
931 fprintf(stderr, "puff() failed with return code %d\n", ret);
932 else {
933 fprintf(stderr, "puff() succeeded uncompressing %lu bytes\n", destlen);
934 if (sourcelen < len) fprintf(stderr, "%lu compressed bytes unused\n",
935 len - sourcelen);
936 }
937
938 /* if requested, inflate again and write decompressd data to stdout */
939 if (put) {
940 dest = malloc(destlen);
941 if (dest == NULL) {
942 fprintf(stderr, "memory allocation failure\n");
943 free(source);
944 return 4;
945 }
946 puff(dest, &destlen, source + skip, &sourcelen);
947 fwrite(dest, 1, destlen, stdout);
948 free(dest);
949 }
950
951 /* clean up */
952 free(source);
953 return ret;
954}
955#endif
diff --git a/zlib/contrib/puff/puff.h b/zlib/contrib/puff/puff.h
index 88d1b3844ff..6a0080ae1a7 100644
--- a/zlib/contrib/puff/puff.h
+++ b/zlib/contrib/puff/puff.h
@@ -1,6 +1,6 @@
1/* puff.h 1/* puff.h
2 Copyright (C) 2002-2010 Mark Adler, all rights reserved 2 Copyright (C) 2002-2010 Mark Adler, all rights reserved
3 version 2.1, 4 Apr 2010 3 version 2.2, 25 Apr 2010
4 4
5 This software is provided 'as-is', without any express or implied 5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the author be held liable for any damages 6 warranty. In no event will the author be held liable for any damages
@@ -25,7 +25,11 @@
25/* 25/*
26 * See puff.c for purpose and usage. 26 * See puff.c for purpose and usage.
27 */ 27 */
28#ifndef NIL
29# define NIL ((unsigned char *)0) /* for no output option */
30#endif
31
28int puff(unsigned char *dest, /* pointer to destination pointer */ 32int puff(unsigned char *dest, /* pointer to destination pointer */
29 unsigned long *destlen, /* amount of output space */ 33 unsigned long *destlen, /* amount of output space */
30 unsigned char *source, /* pointer to source data pointer */ 34 const unsigned char *source, /* pointer to source data pointer */
31 unsigned long *sourcelen); /* amount of input available */ 35 unsigned long *sourcelen); /* amount of input available */
diff --git a/zlib/contrib/puff/pufftest.c b/zlib/contrib/puff/pufftest.c
new file mode 100644
index 00000000000..76e35f66bf6
--- /dev/null
+++ b/zlib/contrib/puff/pufftest.c
@@ -0,0 +1,165 @@
1/*
2 * pufftest.c
3 * Copyright (C) 2002-2010 Mark Adler
4 * For conditions of distribution and use, see copyright notice in puff.h
5 * version 2.2, 25 Apr 2010
6 */
7
8/* Example of how to use puff().
9
10 Usage: puff [-w] [-f] [-nnn] file
11 ... | puff [-w] [-f] [-nnn]
12
13 where file is the input file with deflate data, nnn is the number of bytes
14 of input to skip before inflating (e.g. to skip a zlib or gzip header), and
15 -w is used to write the decompressed data to stdout. -f is for coverage
16 testing, and causes pufftest to fail with not enough output space (-f does
17 a write like -w, so -w is not required). */
18
19#include <stdio.h>
20#include <stdlib.h>
21#include "puff.h"
22
23#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
24# include <fcntl.h>
25# include <io.h>
26# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
27#else
28# define SET_BINARY_MODE(file)
29#endif
30
31#define local static
32
33/* Return size times approximately the cube root of 2, keeping the result as 1,
34 3, or 5 times a power of 2 -- the result is always > size, until the result
35 is the maximum value of an unsigned long, where it remains. This is useful
36 to keep reallocations less than ~33% over the actual data. */
37local size_t bythirds(size_t size)
38{
39 int n;
40 size_t m;
41
42 m = size;
43 for (n = 0; m; n++)
44 m >>= 1;
45 if (n < 3)
46 return size + 1;
47 n -= 3;
48 m = size >> n;
49 m += m == 6 ? 2 : 1;
50 m <<= n;
51 return m > size ? m : (size_t)(-1);
52}
53
54/* Read the input file *name, or stdin if name is NULL, into allocated memory.
55 Reallocate to larger buffers until the entire file is read in. Return a
56 pointer to the allocated data, or NULL if there was a memory allocation
57 failure. *len is the number of bytes of data read from the input file (even
58 if load() returns NULL). If the input file was empty or could not be opened
59 or read, *len is zero. */
60local void *load(const char *name, size_t *len)
61{
62 size_t size;
63 void *buf, *swap;
64 FILE *in;
65
66 *len = 0;
67 buf = malloc(size = 4096);
68 if (buf == NULL)
69 return NULL;
70 in = name == NULL ? stdin : fopen(name, "rb");
71 if (in != NULL) {
72 for (;;) {
73 *len += fread((char *)buf + *len, 1, size - *len, in);
74 if (*len < size) break;
75 size = bythirds(size);
76 if (size == *len || (swap = realloc(buf, size)) == NULL) {
77 free(buf);
78 buf = NULL;
79 break;
80 }
81 buf = swap;
82 }
83 fclose(in);
84 }
85 return buf;
86}
87
88int main(int argc, char **argv)
89{
90 int ret, put = 0, fail = 0;
91 unsigned skip = 0;
92 char *arg, *name = NULL;
93 unsigned char *source = NULL, *dest;
94 size_t len = 0;
95 unsigned long sourcelen, destlen;
96
97 /* process arguments */
98 while (arg = *++argv, --argc)
99 if (arg[0] == '-') {
100 if (arg[1] == 'w' && arg[2] == 0)
101 put = 1;
102 else if (arg[1] == 'f' && arg[2] == 0)
103 fail = 1, put = 1;
104 else if (arg[1] >= '0' && arg[1] <= '9')
105 skip = (unsigned)atoi(arg + 1);
106 else {
107 fprintf(stderr, "invalid option %s\n", arg);
108 return 3;
109 }
110 }
111 else if (name != NULL) {
112 fprintf(stderr, "only one file name allowed\n");
113 return 3;
114 }
115 else
116 name = arg;
117 source = load(name, &len);
118 if (source == NULL) {
119 fprintf(stderr, "memory allocation failure\n");
120 return 4;
121 }
122 if (len == 0) {
123 fprintf(stderr, "could not read %s, or it was empty\n",
124 name == NULL ? "<stdin>" : name);
125 free(source);
126 return 3;
127 }
128 if (skip >= len) {
129 fprintf(stderr, "skip request of %d leaves no input\n", skip);
130 free(source);
131 return 3;
132 }
133
134 /* test inflate data with offset skip */
135 len -= skip;
136 sourcelen = (unsigned long)len;
137 ret = puff(NIL, &destlen, source + skip, &sourcelen);
138 if (ret)
139 fprintf(stderr, "puff() failed with return code %d\n", ret);
140 else {
141 fprintf(stderr, "puff() succeeded uncompressing %lu bytes\n", destlen);
142 if (sourcelen < len) fprintf(stderr, "%lu compressed bytes unused\n",
143 len - sourcelen);
144 }
145
146 /* if requested, inflate again and write decompressd data to stdout */
147 if (put && ret == 0) {
148 if (fail)
149 destlen >>= 1;
150 dest = malloc(destlen);
151 if (dest == NULL) {
152 fprintf(stderr, "memory allocation failure\n");
153 free(source);
154 return 4;
155 }
156 puff(dest, &destlen, source + skip, &sourcelen);
157 SET_BINARY_MODE(stdout);
158 fwrite(dest, 1, destlen, stdout);
159 free(dest);
160 }
161
162 /* clean up */
163 free(source);
164 return ret;
165}
diff --git a/zlib/contrib/vstudio/readme.txt b/zlib/contrib/vstudio/readme.txt
index 904888ba393..59c8b8b4707 100644
--- a/zlib/contrib/vstudio/readme.txt
+++ b/zlib/contrib/vstudio/readme.txt
@@ -1,8 +1,8 @@
1Building instructions for the DLL versions of Zlib 1.2.4 1Building instructions for the DLL versions of Zlib 1.2.7
2======================================================== 2========================================================
3 3
4This directory contains projects that build zlib and minizip using 4This directory contains projects that build zlib and minizip using
5Microsoft Visual C++ 9.0/10.0, and Visual C++ . 5Microsoft Visual C++ 9.0/10.0.
6 6
7You don't need to build these projects yourself. You can download the 7You don't need to build these projects yourself. You can download the
8binaries from: 8binaries from:
@@ -10,9 +10,6 @@ binaries from:
10 10
11More information can be found at this site. 11More information can be found at this site.
12 12
13first compile assembly code by running
14bld_ml64.bat in contrib\masmx64
15bld_ml32.bat in contrib\masmx86
16 13
17 14
18 15
@@ -20,13 +17,16 @@ bld_ml32.bat in contrib\masmx86
20Build instructions for Visual Studio 2008 (32 bits or 64 bits) 17Build instructions for Visual Studio 2008 (32 bits or 64 bits)
21-------------------------------------------------------------- 18--------------------------------------------------------------
22- Uncompress current zlib, including all contrib/* files 19- Uncompress current zlib, including all contrib/* files
23- Open contrib\vstudio\vc9\zlibvc.sln with Microsoft Visual C++ 2008.0 20- Compile assembly code (with Visual Studio Command Prompt) by running:
21 bld_ml64.bat (in contrib\masmx64)
22 bld_ml32.bat (in contrib\masmx86)
23- Open contrib\vstudio\vc9\zlibvc.sln with Microsoft Visual C++ 2008
24- Or run: vcbuild /rebuild contrib\vstudio\vc9\zlibvc.sln "Release|Win32" 24- Or run: vcbuild /rebuild contrib\vstudio\vc9\zlibvc.sln "Release|Win32"
25 25
26Build instructions for Visual Studio 2010 (32 bits or 64 bits) 26Build instructions for Visual Studio 2010 (32 bits or 64 bits)
27-------------------------------------------------------------- 27--------------------------------------------------------------
28- Uncompress current zlib, including all contrib/* files 28- Uncompress current zlib, including all contrib/* files
29- Open contrib\vstudio\vc10\zlibvc.sln with Microsoft Visual C++ 2010.0 29- Open contrib\vstudio\vc10\zlibvc.sln with Microsoft Visual C++ 2010
30 30
31 31
32Important 32Important
diff --git a/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj b/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj
index 2d628158b47..bcb08ff95d3 100644
--- a/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj
+++ b/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj
@@ -139,7 +139,7 @@
139 </ClCompile> 139 </ClCompile>
140 <Link> 140 <Link>
141 <AdditionalDependencies>x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> 141 <AdditionalDependencies>x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
142 <OutputFile>$(OutDir)testzlib.exe</OutputFile> 142 <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
143 <GenerateDebugInformation>true</GenerateDebugInformation> 143 <GenerateDebugInformation>true</GenerateDebugInformation>
144 <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile> 144 <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
145 <SubSystem>Console</SubSystem> 145 <SubSystem>Console</SubSystem>
@@ -169,7 +169,7 @@
169 </ClCompile> 169 </ClCompile>
170 <Link> 170 <Link>
171 <AdditionalDependencies>x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> 171 <AdditionalDependencies>x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
172 <OutputFile>$(OutDir)testzlib.exe</OutputFile> 172 <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
173 <GenerateDebugInformation>true</GenerateDebugInformation> 173 <GenerateDebugInformation>true</GenerateDebugInformation>
174 <SubSystem>Console</SubSystem> 174 <SubSystem>Console</SubSystem>
175 <OptimizeReferences>true</OptimizeReferences> 175 <OptimizeReferences>true</OptimizeReferences>
@@ -200,7 +200,7 @@
200 </ClCompile> 200 </ClCompile>
201 <Link> 201 <Link>
202 <AdditionalDependencies>x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> 202 <AdditionalDependencies>x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
203 <OutputFile>$(OutDir)testzlib.exe</OutputFile> 203 <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
204 <GenerateDebugInformation>true</GenerateDebugInformation> 204 <GenerateDebugInformation>true</GenerateDebugInformation>
205 <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile> 205 <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
206 <SubSystem>Console</SubSystem> 206 <SubSystem>Console</SubSystem>
@@ -227,7 +227,7 @@
227 </ClCompile> 227 </ClCompile>
228 <Link> 228 <Link>
229 <AdditionalDependencies>ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> 229 <AdditionalDependencies>ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
230 <OutputFile>$(OutDir)testzlib.exe</OutputFile> 230 <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
231 <GenerateDebugInformation>true</GenerateDebugInformation> 231 <GenerateDebugInformation>true</GenerateDebugInformation>
232 <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile> 232 <ProgramDatabaseFile>$(OutDir)testzlib.pdb</ProgramDatabaseFile>
233 <SubSystem>Console</SubSystem> 233 <SubSystem>Console</SubSystem>
@@ -257,7 +257,7 @@
257 </ClCompile> 257 </ClCompile>
258 <Link> 258 <Link>
259 <AdditionalDependencies>x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> 259 <AdditionalDependencies>x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
260 <OutputFile>$(OutDir)testzlib.exe</OutputFile> 260 <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
261 <GenerateDebugInformation>true</GenerateDebugInformation> 261 <GenerateDebugInformation>true</GenerateDebugInformation>
262 <SubSystem>Console</SubSystem> 262 <SubSystem>Console</SubSystem>
263 <OptimizeReferences>true</OptimizeReferences> 263 <OptimizeReferences>true</OptimizeReferences>
@@ -288,7 +288,7 @@
288 </ClCompile> 288 </ClCompile>
289 <Link> 289 <Link>
290 <AdditionalDependencies>ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> 290 <AdditionalDependencies>ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
291 <OutputFile>$(OutDir)testzlib.exe</OutputFile> 291 <OutputFile>$(OutDir)testzlibdll.exe</OutputFile>
292 <GenerateDebugInformation>true</GenerateDebugInformation> 292 <GenerateDebugInformation>true</GenerateDebugInformation>
293 <SubSystem>Console</SubSystem> 293 <SubSystem>Console</SubSystem>
294 <OptimizeReferences>true</OptimizeReferences> 294 <OptimizeReferences>true</OptimizeReferences>
diff --git a/zlib/contrib/vstudio/vc10/zlib.rc b/zlib/contrib/vstudio/vc10/zlib.rc
index f82245087dd..8eca4dbbc1b 100644
--- a/zlib/contrib/vstudio/vc10/zlib.rc
+++ b/zlib/contrib/vstudio/vc10/zlib.rc
@@ -2,8 +2,8 @@
2 2
3#define IDR_VERSION1 1 3#define IDR_VERSION1 1
4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
5 FILEVERSION 1,2,5,0 5 FILEVERSION 1.2.7,0
6 PRODUCTVERSION 1,2,5,0 6 PRODUCTVERSION 1.2.7,0
7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
8 FILEFLAGS 0 8 FILEFLAGS 0
9 FILEOS VOS_DOS_WINDOWS32 9 FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
17 17
18 BEGIN 18 BEGIN
19 VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 19 VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
20 VALUE "FileVersion", "1.2.5\0" 20 VALUE "FileVersion", "1.2.7\0"
21 VALUE "InternalName", "zlib\0" 21 VALUE "InternalName", "zlib\0"
22 VALUE "OriginalFilename", "zlib.dll\0" 22 VALUE "OriginalFilename", "zlib.dll\0"
23 VALUE "ProductName", "ZLib.DLL\0" 23 VALUE "ProductName", "ZLib.DLL\0"
24 VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 24 VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
25 VALUE "LegalCopyright", "(C) 1995-2010 Jean-loup Gailly & Mark Adler\0" 25 VALUE "LegalCopyright", "(C) 1995-2012 Jean-loup Gailly & Mark Adler\0"
26 END 26 END
27 END 27 END
28 BLOCK "VarFileInfo" 28 BLOCK "VarFileInfo"
diff --git a/zlib/contrib/vstudio/vc10/zlibvc.def b/zlib/contrib/vstudio/vc10/zlibvc.def
index 0269ef722c1..18ddf50eea3 100644
--- a/zlib/contrib/vstudio/vc10/zlibvc.def
+++ b/zlib/contrib/vstudio/vc10/zlibvc.def
@@ -1,7 +1,7 @@
1LIBRARY 1LIBRARY
2; zlib data compression and ZIP file I/O library 2; zlib data compression and ZIP file I/O library
3 3
4VERSION 1.24 4VERSION 1.2.7
5 5
6EXPORTS 6EXPORTS
7 adler32 @1 7 adler32 @1
@@ -55,6 +55,7 @@ EXPORTS
55 gzungetc @49 55 gzungetc @49
56 zlibCompileFlags @50 56 zlibCompileFlags @50
57 deflatePrime @51 57 deflatePrime @51
58 deflatePending @52
58 59
59 unzOpen @61 60 unzOpen @61
60 unzClose @62 61 unzClose @62
@@ -128,3 +129,11 @@ EXPORTS
128 inflatePrime @158 129 inflatePrime @158
129 inflateReset2 @159 130 inflateReset2 @159
130 inflateUndermine @160 131 inflateUndermine @160
132
133; zlib1 v1.2.6 added:
134 gzgetc_ @161
135 inflateResetKeep @163
136 deflateResetKeep @164
137
138; zlib1 v1.2.7 added:
139 gzopen_w @165
diff --git a/zlib/contrib/vstudio/vc10/zlibvc.vcxproj b/zlib/contrib/vstudio/vc10/zlibvc.vcxproj
index 98623989343..9218fdce920 100644
--- a/zlib/contrib/vstudio/vc10/zlibvc.vcxproj
+++ b/zlib/contrib/vstudio/vc10/zlibvc.vcxproj
@@ -180,6 +180,12 @@
180 <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet> 180 <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
181 <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> 181 <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
182 <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" /> 182 <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
183 <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">zlibwapi</TargetName>
184 <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">zlibwapi</TargetName>
185 <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">zlibwapi</TargetName>
186 <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">zlibwapi</TargetName>
187 <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|x64'">zlibwapi</TargetName>
188 <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">zlibwapi</TargetName>
183 </PropertyGroup> 189 </PropertyGroup>
184 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> 190 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
185 <Midl> 191 <Midl>
@@ -227,6 +233,10 @@
227 </DataExecutionPrevention> 233 </DataExecutionPrevention>
228 <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary> 234 <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
229 </Link> 235 </Link>
236 <PreBuildEvent>
237 <Command>cd ..\..\masmx86
238bld_ml32.bat</Command>
239 </PreBuildEvent>
230 </ItemDefinitionGroup> 240 </ItemDefinitionGroup>
231 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'"> 241 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseWithoutAsm|Win32'">
232 <Midl> 242 <Midl>
@@ -324,6 +334,10 @@
324 </DataExecutionPrevention> 334 </DataExecutionPrevention>
325 <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary> 335 <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
326 </Link> 336 </Link>
337 <PreBuildEvent>
338 <Command>cd ..\..\masmx86
339bld_ml32.bat</Command>
340 </PreBuildEvent>
327 </ItemDefinitionGroup> 341 </ItemDefinitionGroup>
328 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> 342 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
329 <Midl> 343 <Midl>
@@ -368,6 +382,10 @@
368 <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary> 382 <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
369 <TargetMachine>MachineX64</TargetMachine> 383 <TargetMachine>MachineX64</TargetMachine>
370 </Link> 384 </Link>
385 <PreBuildEvent>
386 <Command>cd ..\..\contrib\masmx64
387bld_ml64.bat</Command>
388 </PreBuildEvent>
371 </ItemDefinitionGroup> 389 </ItemDefinitionGroup>
372 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'"> 390 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Itanium'">
373 <Midl> 391 <Midl>
@@ -547,6 +565,10 @@
547 <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary> 565 <ImportLibrary>$(OutDir)zlibwapi.lib</ImportLibrary>
548 <TargetMachine>MachineX64</TargetMachine> 566 <TargetMachine>MachineX64</TargetMachine>
549 </Link> 567 </Link>
568 <PreBuildEvent>
569 <Command>cd ..\..\masmx64
570bld_ml64.bat</Command>
571 </PreBuildEvent>
550 </ItemDefinitionGroup> 572 </ItemDefinitionGroup>
551 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'"> 573 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Itanium'">
552 <Midl> 574 <Midl>
diff --git a/zlib/contrib/vstudio/vc9/zlib.rc b/zlib/contrib/vstudio/vc9/zlib.rc
index f82245087dd..8eca4dbbc1b 100644
--- a/zlib/contrib/vstudio/vc9/zlib.rc
+++ b/zlib/contrib/vstudio/vc9/zlib.rc
@@ -2,8 +2,8 @@
2 2
3#define IDR_VERSION1 1 3#define IDR_VERSION1 1
4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 4IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
5 FILEVERSION 1,2,5,0 5 FILEVERSION 1.2.7,0
6 PRODUCTVERSION 1,2,5,0 6 PRODUCTVERSION 1.2.7,0
7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 7 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
8 FILEFLAGS 0 8 FILEFLAGS 0
9 FILEOS VOS_DOS_WINDOWS32 9 FILEOS VOS_DOS_WINDOWS32
@@ -17,12 +17,12 @@ BEGIN
17 17
18 BEGIN 18 BEGIN
19 VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" 19 VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
20 VALUE "FileVersion", "1.2.5\0" 20 VALUE "FileVersion", "1.2.7\0"
21 VALUE "InternalName", "zlib\0" 21 VALUE "InternalName", "zlib\0"
22 VALUE "OriginalFilename", "zlib.dll\0" 22 VALUE "OriginalFilename", "zlib.dll\0"
23 VALUE "ProductName", "ZLib.DLL\0" 23 VALUE "ProductName", "ZLib.DLL\0"
24 VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" 24 VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
25 VALUE "LegalCopyright", "(C) 1995-2010 Jean-loup Gailly & Mark Adler\0" 25 VALUE "LegalCopyright", "(C) 1995-2012 Jean-loup Gailly & Mark Adler\0"
26 END 26 END
27 END 27 END
28 BLOCK "VarFileInfo" 28 BLOCK "VarFileInfo"
diff --git a/zlib/contrib/vstudio/vc9/zlibvc.def b/zlib/contrib/vstudio/vc9/zlibvc.def
index 0269ef722c1..2df8bb3a71c 100644
--- a/zlib/contrib/vstudio/vc9/zlibvc.def
+++ b/zlib/contrib/vstudio/vc9/zlibvc.def
@@ -1,7 +1,7 @@
1LIBRARY 1LIBRARY
2; zlib data compression and ZIP file I/O library 2; zlib data compression and ZIP file I/O library
3 3
4VERSION 1.24 4VERSION 1.2.7
5 5
6EXPORTS 6EXPORTS
7 adler32 @1 7 adler32 @1
@@ -55,6 +55,7 @@ EXPORTS
55 gzungetc @49 55 gzungetc @49
56 zlibCompileFlags @50 56 zlibCompileFlags @50
57 deflatePrime @51 57 deflatePrime @51
58 deflatePending @52
58 59
59 unzOpen @61 60 unzOpen @61
60 unzClose @62 61 unzClose @62
@@ -128,3 +129,11 @@ EXPORTS
128 inflatePrime @158 129 inflatePrime @158
129 inflateReset2 @159 130 inflateReset2 @159
130 inflateUndermine @160 131 inflateUndermine @160
132
133; zlib1 v1.2.6 added:
134 gzgetc_ @161
135 inflateResetKeep @163
136 deflateResetKeep @164
137
138; zlib1 v1.2.7 added:
139 gzopen_w @165
diff --git a/zlib/crc32.c b/zlib/crc32.c
index 74bbb1ea201..e2f5892df91 100644
--- a/zlib/crc32.c
+++ b/zlib/crc32.c
@@ -1,5 +1,5 @@
1/* crc32.c -- compute the CRC-32 of a data stream 1/* crc32.c -- compute the CRC-32 of a data stream
2 * Copyright (C) 1995-2006, 2010 Mark Adler 2 * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 * 4 *
5 * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster 5 * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@@ -17,6 +17,8 @@
17 of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should 17 of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
18 first call get_crc_table() to initialize the tables before allowing more than 18 first call get_crc_table() to initialize the tables before allowing more than
19 one thread to use crc32(). 19 one thread to use crc32().
20
21 DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
20 */ 22 */
21 23
22#ifdef MAKECRCH 24#ifdef MAKECRCH
@@ -30,31 +32,11 @@
30 32
31#define local static 33#define local static
32 34
33/* Find a four-byte integer type for crc32_little() and crc32_big(). */
34#ifndef NOBYFOUR
35# ifdef STDC /* need ANSI C limits.h to determine sizes */
36# include <limits.h>
37# define BYFOUR
38# if (UINT_MAX == 0xffffffffUL)
39 typedef unsigned int u4;
40# else
41# if (ULONG_MAX == 0xffffffffUL)
42 typedef unsigned long u4;
43# else
44# if (USHRT_MAX == 0xffffffffUL)
45 typedef unsigned short u4;
46# else
47# undef BYFOUR /* can't find a four-byte integer type! */
48# endif
49# endif
50# endif
51# endif /* STDC */
52#endif /* !NOBYFOUR */
53
54/* Definitions for doing the crc four data bytes at a time. */ 35/* Definitions for doing the crc four data bytes at a time. */
36#if !defined(NOBYFOUR) && defined(Z_U4)
37# define BYFOUR
38#endif
55#ifdef BYFOUR 39#ifdef BYFOUR
56# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
57 (((w)&0xff00)<<8)+(((w)&0xff)<<24))
58 local unsigned long crc32_little OF((unsigned long, 40 local unsigned long crc32_little OF((unsigned long,
59 const unsigned char FAR *, unsigned)); 41 const unsigned char FAR *, unsigned));
60 local unsigned long crc32_big OF((unsigned long, 42 local unsigned long crc32_big OF((unsigned long,
@@ -68,16 +50,16 @@
68local unsigned long gf2_matrix_times OF((unsigned long *mat, 50local unsigned long gf2_matrix_times OF((unsigned long *mat,
69 unsigned long vec)); 51 unsigned long vec));
70local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); 52local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
71local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2); 53local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
72 54
73 55
74#ifdef DYNAMIC_CRC_TABLE 56#ifdef DYNAMIC_CRC_TABLE
75 57
76local volatile int crc_table_empty = 1; 58local volatile int crc_table_empty = 1;
77local unsigned long FAR crc_table[TBLS][256]; 59local z_crc_t FAR crc_table[TBLS][256];
78local void make_crc_table OF((void)); 60local void make_crc_table OF((void));
79#ifdef MAKECRCH 61#ifdef MAKECRCH
80 local void write_table OF((FILE *, const unsigned long FAR *)); 62 local void write_table OF((FILE *, const z_crc_t FAR *));
81#endif /* MAKECRCH */ 63#endif /* MAKECRCH */
82/* 64/*
83 Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: 65 Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
@@ -107,9 +89,9 @@ local void make_crc_table OF((void));
107*/ 89*/
108local void make_crc_table() 90local void make_crc_table()
109{ 91{
110 unsigned long c; 92 z_crc_t c;
111 int n, k; 93 int n, k;
112 unsigned long poly; /* polynomial exclusive-or pattern */ 94 z_crc_t poly; /* polynomial exclusive-or pattern */
113 /* terms of polynomial defining this crc (except x^32): */ 95 /* terms of polynomial defining this crc (except x^32): */
114 static volatile int first = 1; /* flag to limit concurrent making */ 96 static volatile int first = 1; /* flag to limit concurrent making */
115 static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; 97 static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
@@ -121,13 +103,13 @@ local void make_crc_table()
121 first = 0; 103 first = 0;
122 104
123 /* make exclusive-or pattern from polynomial (0xedb88320UL) */ 105 /* make exclusive-or pattern from polynomial (0xedb88320UL) */
124 poly = 0UL; 106 poly = 0;
125 for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) 107 for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
126 poly |= 1UL << (31 - p[n]); 108 poly |= (z_crc_t)1 << (31 - p[n]);
127 109
128 /* generate a crc for every 8-bit value */ 110 /* generate a crc for every 8-bit value */
129 for (n = 0; n < 256; n++) { 111 for (n = 0; n < 256; n++) {
130 c = (unsigned long)n; 112 c = (z_crc_t)n;
131 for (k = 0; k < 8; k++) 113 for (k = 0; k < 8; k++)
132 c = c & 1 ? poly ^ (c >> 1) : c >> 1; 114 c = c & 1 ? poly ^ (c >> 1) : c >> 1;
133 crc_table[0][n] = c; 115 crc_table[0][n] = c;
@@ -138,11 +120,11 @@ local void make_crc_table()
138 and then the byte reversal of those as well as the first table */ 120 and then the byte reversal of those as well as the first table */
139 for (n = 0; n < 256; n++) { 121 for (n = 0; n < 256; n++) {
140 c = crc_table[0][n]; 122 c = crc_table[0][n];
141 crc_table[4][n] = REV(c); 123 crc_table[4][n] = ZSWAP32(c);
142 for (k = 1; k < 4; k++) { 124 for (k = 1; k < 4; k++) {
143 c = crc_table[0][c & 0xff] ^ (c >> 8); 125 c = crc_table[0][c & 0xff] ^ (c >> 8);
144 crc_table[k][n] = c; 126 crc_table[k][n] = c;
145 crc_table[k + 4][n] = REV(c); 127 crc_table[k + 4][n] = ZSWAP32(c);
146 } 128 }
147 } 129 }
148#endif /* BYFOUR */ 130#endif /* BYFOUR */
@@ -164,7 +146,7 @@ local void make_crc_table()
164 if (out == NULL) return; 146 if (out == NULL) return;
165 fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); 147 fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
166 fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); 148 fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
167 fprintf(out, "local const unsigned long FAR "); 149 fprintf(out, "local const z_crc_t FAR ");
168 fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); 150 fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
169 write_table(out, crc_table[0]); 151 write_table(out, crc_table[0]);
170# ifdef BYFOUR 152# ifdef BYFOUR
@@ -184,12 +166,13 @@ local void make_crc_table()
184#ifdef MAKECRCH 166#ifdef MAKECRCH
185local void write_table(out, table) 167local void write_table(out, table)
186 FILE *out; 168 FILE *out;
187 const unsigned long FAR *table; 169 const z_crc_t FAR *table;
188{ 170{
189 int n; 171 int n;
190 172
191 for (n = 0; n < 256; n++) 173 for (n = 0; n < 256; n++)
192 fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], 174 fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
175 (unsigned long)(table[n]),
193 n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); 176 n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
194} 177}
195#endif /* MAKECRCH */ 178#endif /* MAKECRCH */
@@ -204,13 +187,13 @@ local void write_table(out, table)
204/* ========================================================================= 187/* =========================================================================
205 * This function can be used by asm versions of crc32() 188 * This function can be used by asm versions of crc32()
206 */ 189 */
207const unsigned long FAR * ZEXPORT get_crc_table() 190const z_crc_t FAR * ZEXPORT get_crc_table()
208{ 191{
209#ifdef DYNAMIC_CRC_TABLE 192#ifdef DYNAMIC_CRC_TABLE
210 if (crc_table_empty) 193 if (crc_table_empty)
211 make_crc_table(); 194 make_crc_table();
212#endif /* DYNAMIC_CRC_TABLE */ 195#endif /* DYNAMIC_CRC_TABLE */
213 return (const unsigned long FAR *)crc_table; 196 return (const z_crc_t FAR *)crc_table;
214} 197}
215 198
216/* ========================================================================= */ 199/* ========================================================================= */
@@ -232,7 +215,7 @@ unsigned long ZEXPORT crc32(crc, buf, len)
232 215
233#ifdef BYFOUR 216#ifdef BYFOUR
234 if (sizeof(void *) == sizeof(ptrdiff_t)) { 217 if (sizeof(void *) == sizeof(ptrdiff_t)) {
235 u4 endian; 218 z_crc_t endian;
236 219
237 endian = 1; 220 endian = 1;
238 if (*((unsigned char *)(&endian))) 221 if (*((unsigned char *)(&endian)))
@@ -266,17 +249,17 @@ local unsigned long crc32_little(crc, buf, len)
266 const unsigned char FAR *buf; 249 const unsigned char FAR *buf;
267 unsigned len; 250 unsigned len;
268{ 251{
269 register u4 c; 252 register z_crc_t c;
270 register const u4 FAR *buf4; 253 register const z_crc_t FAR *buf4;
271 254
272 c = (u4)crc; 255 c = (z_crc_t)crc;
273 c = ~c; 256 c = ~c;
274 while (len && ((ptrdiff_t)buf & 3)) { 257 while (len && ((ptrdiff_t)buf & 3)) {
275 c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); 258 c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
276 len--; 259 len--;
277 } 260 }
278 261
279 buf4 = (const u4 FAR *)(const void FAR *)buf; 262 buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
280 while (len >= 32) { 263 while (len >= 32) {
281 DOLIT32; 264 DOLIT32;
282 len -= 32; 265 len -= 32;
@@ -306,17 +289,17 @@ local unsigned long crc32_big(crc, buf, len)
306 const unsigned char FAR *buf; 289 const unsigned char FAR *buf;
307 unsigned len; 290 unsigned len;
308{ 291{
309 register u4 c; 292 register z_crc_t c;
310 register const u4 FAR *buf4; 293 register const z_crc_t FAR *buf4;
311 294
312 c = REV((u4)crc); 295 c = ZSWAP32((z_crc_t)crc);
313 c = ~c; 296 c = ~c;
314 while (len && ((ptrdiff_t)buf & 3)) { 297 while (len && ((ptrdiff_t)buf & 3)) {
315 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); 298 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
316 len--; 299 len--;
317 } 300 }
318 301
319 buf4 = (const u4 FAR *)(const void FAR *)buf; 302 buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
320 buf4--; 303 buf4--;
321 while (len >= 32) { 304 while (len >= 32) {
322 DOBIG32; 305 DOBIG32;
@@ -333,7 +316,7 @@ local unsigned long crc32_big(crc, buf, len)
333 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); 316 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
334 } while (--len); 317 } while (--len);
335 c = ~c; 318 c = ~c;
336 return (unsigned long)(REV(c)); 319 return (unsigned long)(ZSWAP32(c));
337} 320}
338 321
339#endif /* BYFOUR */ 322#endif /* BYFOUR */
diff --git a/zlib/crc32.h b/zlib/crc32.h
index 8053b6117c0..9e0c7781025 100644
--- a/zlib/crc32.h
+++ b/zlib/crc32.h
@@ -2,7 +2,7 @@
2 * Generated automatically by crc32.c 2 * Generated automatically by crc32.c
3 */ 3 */
4 4
5local const unsigned long FAR crc_table[TBLS][256] = 5local const z_crc_t FAR crc_table[TBLS][256] =
6{ 6{
7 { 7 {
8 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, 8 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
diff --git a/zlib/deflate.c b/zlib/deflate.c
index 9d2ae7f5af7..99184ff0cef 100644
--- a/zlib/deflate.c
+++ b/zlib/deflate.c
@@ -1,5 +1,5 @@
1/* deflate.c -- compress data using the deflation algorithm 1/* deflate.c -- compress data using the deflation algorithm
2 * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler 2 * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -37,7 +37,7 @@
37 * REFERENCES 37 * REFERENCES
38 * 38 *
39 * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". 39 * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
40 * Available in http://www.ietf.org/rfc/rfc1951.txt 40 * Available in http://tools.ietf.org/html/rfc1951
41 * 41 *
42 * A description of the Rabin and Karp algorithm is given in the book 42 * A description of the Rabin and Karp algorithm is given in the book
43 * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. 43 * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
@@ -52,7 +52,7 @@
52#include "deflate.h" 52#include "deflate.h"
53 53
54const char deflate_copyright[] = 54const char deflate_copyright[] =
55 " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler "; 55 " deflate 1.2.7 Copyright 1995-2012 Jean-loup Gailly and Mark Adler ";
56/* 56/*
57 If you use the zlib library in a product, an acknowledgment is welcome 57 If you use the zlib library in a product, an acknowledgment is welcome
58 in the documentation of your product. If for some reason you cannot 58 in the documentation of your product. If for some reason you cannot
@@ -155,6 +155,9 @@ local const config configuration_table[10] = {
155struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ 155struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
156#endif 156#endif
157 157
158/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
159#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
160
158/* =========================================================================== 161/* ===========================================================================
159 * Update a hash value with the given input byte 162 * Update a hash value with the given input byte
160 * IN assertion: all calls to to UPDATE_HASH are made with consecutive 163 * IN assertion: all calls to to UPDATE_HASH are made with consecutive
@@ -235,10 +238,19 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
235 238
236 strm->msg = Z_NULL; 239 strm->msg = Z_NULL;
237 if (strm->zalloc == (alloc_func)0) { 240 if (strm->zalloc == (alloc_func)0) {
241#ifdef Z_SOLO
242 return Z_STREAM_ERROR;
243#else
238 strm->zalloc = zcalloc; 244 strm->zalloc = zcalloc;
239 strm->opaque = (voidpf)0; 245 strm->opaque = (voidpf)0;
246#endif
240 } 247 }
241 if (strm->zfree == (free_func)0) strm->zfree = zcfree; 248 if (strm->zfree == (free_func)0)
249#ifdef Z_SOLO
250 return Z_STREAM_ERROR;
251#else
252 strm->zfree = zcfree;
253#endif
242 254
243#ifdef FASTEST 255#ifdef FASTEST
244 if (level != 0) level = 1; 256 if (level != 0) level = 1;
@@ -314,43 +326,70 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
314 uInt dictLength; 326 uInt dictLength;
315{ 327{
316 deflate_state *s; 328 deflate_state *s;
317 uInt length = dictLength; 329 uInt str, n;
318 uInt n; 330 int wrap;
319 IPos hash_head = 0; 331 unsigned avail;
332 unsigned char *next;
320 333
321 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || 334 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
322 strm->state->wrap == 2 ||
323 (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
324 return Z_STREAM_ERROR; 335 return Z_STREAM_ERROR;
325
326 s = strm->state; 336 s = strm->state;
327 if (s->wrap) 337 wrap = s->wrap;
328 strm->adler = adler32(strm->adler, dictionary, dictLength); 338 if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
339 return Z_STREAM_ERROR;
329 340
330 if (length < MIN_MATCH) return Z_OK; 341 /* when using zlib wrappers, compute Adler-32 for provided dictionary */
331 if (length > s->w_size) { 342 if (wrap == 1)
332 length = s->w_size; 343 strm->adler = adler32(strm->adler, dictionary, dictLength);
333 dictionary += dictLength - length; /* use the tail of the dictionary */ 344 s->wrap = 0; /* avoid computing Adler-32 in read_buf */
345
346 /* if dictionary would fill window, just replace the history */
347 if (dictLength >= s->w_size) {
348 if (wrap == 0) { /* already empty otherwise */
349 CLEAR_HASH(s);
350 s->strstart = 0;
351 s->block_start = 0L;
352 s->insert = 0;
353