mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-19 17:18:24 +08:00
Sync zlib sources with GCC, upgrading to 1.2.10.
Changes in 1.2.10 (2 Jan 2017) - Avoid warnings on snprintf() return value - Fix bug in deflate_stored() for zero-length input - Fix bug in gzwrite.c that produced corrupt gzip files - Remove files to be installed before copying them in Makefile.in - Add warnings when compiling with assembler code Changes in 1.2.9 (31 Dec 2016) - Fix contrib/minizip to permit unzipping with desktop API [Zouzou] - Improve contrib/blast to return unused bytes - Assure that gzoffset() is correct when appending - Improve compress() and uncompress() to support large lengths - Fix bug in test/example.c where error code not saved - Remedy Coverity warning [Randers-Pehrson] - Improve speed of gzprintf() in transparent mode - Fix inflateInit2() bug when windowBits is 16 or 32 - Change DEBUG macro to ZLIB_DEBUG - Avoid uninitialized access by gzclose_w() - Allow building zlib outside of the source directory - Fix bug that accepted invalid zlib header when windowBits is zero - Fix gzseek() problem on MinGW due to buggy _lseeki64 there - Loop on write() calls in gzwrite.c in case of non-blocking I/O - Add --warn (-w) option to ./configure for more compiler warnings - Reject a window size of 256 bytes if not using the zlib wrapper - Fix bug when level 0 used with Z_HUFFMAN or Z_RLE - Add --debug (-d) option to ./configure to define ZLIB_DEBUG - Fix bugs in creating a very large gzip header - Add uncompress2() function, which returns the input size used - Assure that deflateParams() will not switch functions mid-block - Dramatically speed up deflation for level 0 (storing) - Add gzfread(), duplicating the interface of fread() - Add gzfwrite(), duplicating the interface of fwrite() - Add deflateGetDictionary() function - Use snprintf() for later versions of Microsoft C - Fix *Init macros to use z_ prefix when requested - Replace as400 with os400 for OS/400 support [Monnerat] - Add crc32_z() and adler32_z() functions with size_t lengths - Update Visual Studio project files [AraHaan]
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
/* blast.c
|
||||
* Copyright (C) 2003, 2012 Mark Adler
|
||||
* Copyright (C) 2003, 2012, 2013 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in blast.h
|
||||
* version 1.2, 24 Oct 2012
|
||||
* version 1.3, 24 Aug 2013
|
||||
*
|
||||
* blast.c decompresses data compressed by the PKWare Compression Library.
|
||||
* This function provides functionality similar to the explode() function of
|
||||
@ -24,8 +24,12 @@
|
||||
* 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data
|
||||
* 1.2 24 Oct 2012 - Add note about using binary mode in stdio
|
||||
* - Fix comparisons of differently signed integers
|
||||
* 1.3 24 Aug 2013 - Return unused input from blast()
|
||||
* - Fix test code to correctly report unused input
|
||||
* - Enable the provision of initial input to blast()
|
||||
*/
|
||||
|
||||
#include <stddef.h> /* for NULL */
|
||||
#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
|
||||
#include "blast.h" /* prototype for blast() */
|
||||
|
||||
@ -256,7 +260,7 @@ local int construct(struct huffman *h, const unsigned char *rep, int n)
|
||||
* next, 0 for literals, 1 for length/distance.
|
||||
*
|
||||
* - If literals are uncoded, then the next eight bits are the literal, in the
|
||||
* normal bit order in th stream, i.e. no bit-reversal is needed. Similarly,
|
||||
* normal bit order in the stream, i.e. no bit-reversal is needed. Similarly,
|
||||
* no bit reversal is needed for either the length extra bits or the distance
|
||||
* extra bits.
|
||||
*
|
||||
@ -376,7 +380,8 @@ local int decomp(struct state *s)
|
||||
}
|
||||
|
||||
/* See comments in blast.h */
|
||||
int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow)
|
||||
int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
|
||||
unsigned *left, unsigned char **in)
|
||||
{
|
||||
struct state s; /* input/output state */
|
||||
int err; /* return value */
|
||||
@ -384,7 +389,12 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow)
|
||||
/* initialize input state */
|
||||
s.infun = infun;
|
||||
s.inhow = inhow;
|
||||
s.left = 0;
|
||||
if (left != NULL && *left) {
|
||||
s.left = *left;
|
||||
s.in = *in;
|
||||
}
|
||||
else
|
||||
s.left = 0;
|
||||
s.bitbuf = 0;
|
||||
s.bitcnt = 0;
|
||||
|
||||
@ -400,6 +410,12 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow)
|
||||
else
|
||||
err = decomp(&s); /* decompress */
|
||||
|
||||
/* return unused input */
|
||||
if (left != NULL)
|
||||
*left = s.left;
|
||||
if (in != NULL)
|
||||
*in = s.left ? s.in : NULL;
|
||||
|
||||
/* write any leftover output and update the error code if needed */
|
||||
if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0)
|
||||
err = 1;
|
||||
@ -429,16 +445,20 @@ local int outf(void *how, unsigned char *buf, unsigned len)
|
||||
/* Decompress a PKWare Compression Library stream from stdin to stdout */
|
||||
int main(void)
|
||||
{
|
||||
int ret, n;
|
||||
int ret;
|
||||
unsigned left;
|
||||
|
||||
/* decompress to stdout */
|
||||
ret = blast(inf, stdin, outf, stdout);
|
||||
if (ret != 0) fprintf(stderr, "blast error: %d\n", ret);
|
||||
left = 0;
|
||||
ret = blast(inf, stdin, outf, stdout, &left, NULL);
|
||||
if (ret != 0)
|
||||
fprintf(stderr, "blast error: %d\n", ret);
|
||||
|
||||
/* see if there are any leftover bytes */
|
||||
n = 0;
|
||||
while (getchar() != EOF) n++;
|
||||
if (n) fprintf(stderr, "blast warning: %d unused bytes of input\n", n);
|
||||
/* count any leftover bytes */
|
||||
while (getchar() != EOF)
|
||||
left++;
|
||||
if (left)
|
||||
fprintf(stderr, "blast warning: %u unused bytes of input\n", left);
|
||||
|
||||
/* return blast() error code */
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user