[libpng16] Cleaned up (char*) casts of zlib messages. The latest version of

the Intel C compiler complains about casting a string literal as (char*), so
copied the treatment of z_const from the library code into pngfix.c
This commit is contained in:
John Bowler 2013-10-04 20:13:17 -05:00 committed by Glenn Randers-Pehrson
parent 940b37b197
commit 5b1df53a82
3 changed files with 31 additions and 2 deletions

View File

@ -62,6 +62,9 @@ Version 1.6.7beta02 [October 5, 2013]
way of handling the dependencies of sources that are machine generated; way of handling the dependencies of sources that are machine generated;
unfortunately it only works if the user does 'make all' or 'make check', unfortunately it only works if the user does 'make all' or 'make check',
so the dependencies (3) are still required. so the dependencies (3) are still required.
Cleaned up (char*) casts of zlib messages. The latest version of the Intel C
compiler complains about casting a string literal as (char*), so copied the
treatment of z_const from the library code into pngfix.c
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -4676,6 +4676,9 @@ Version 1.6.7beta02 [October 5, 2013]
way of handling the dependencies of sources that are machine generated; way of handling the dependencies of sources that are machine generated;
unfortunately it only works if the user does 'make all' or 'make check', unfortunately it only works if the user does 'make all' or 'make check',
so the dependencies (3) are still required. so the dependencies (3) are still required.
Cleaned up (char*) casts of zlib messages. The latest version of the Intel C
compiler complains about casting a string literal as (char*), so copied the
treatment of z_const from the library code into pngfix.c
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -50,7 +50,30 @@
#endif #endif
#ifdef PNG_READ_SUPPORTED #ifdef PNG_READ_SUPPORTED
/* zlib.h defines the structure z_stream, an instance of which is included
* in this structure and is required for decompressing the LZ compressed
* data in PNG files.
*/
#ifndef ZLIB_CONST
/* We must ensure that zlib uses 'const' in declarations. */
# define ZLIB_CONST
#endif
#include <zlib.h> #include <zlib.h>
#ifdef const
/* zlib.h sometimes #defines const to nothing, undo this. */
# undef const
#endif
/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
* with older builds.
*/
#if ZLIB_VERNUM < 0x1260
# define PNGZ_MSG_CAST(s) png_constcast(char*,s)
# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
#else
# define PNGZ_MSG_CAST(s) (s)
# define PNGZ_INPUT_CAST(b) (b)
#endif
#ifndef PNG_MAXIMUM_INFLATE_WINDOW #ifndef PNG_MAXIMUM_INFLATE_WINDOW
# error "pngfix not supported in this libpng version" # error "pngfix not supported in this libpng version"
@ -2636,7 +2659,7 @@ zlib_check(struct file *file, png_uint_32 offset)
case ZLIB_OK: case ZLIB_OK:
/* Truncated stream; unrecoverable, gets converted to ZLIB_FATAL */ /* Truncated stream; unrecoverable, gets converted to ZLIB_FATAL */
zlib.z.msg = png_constcast(char*, "[truncated]"); zlib.z.msg = PNGZ_MSG_CAST("[truncated]");
zlib_message(&zlib, 0/*expected*/); zlib_message(&zlib, 0/*expected*/);
/* FALL THROUGH */ /* FALL THROUGH */
@ -2675,7 +2698,7 @@ zlib_check(struct file *file, png_uint_32 offset)
/* Output the error that wasn't output before: */ /* Output the error that wasn't output before: */
if (zlib.z.msg == NULL) if (zlib.z.msg == NULL)
zlib.z.msg = png_constcast(char*, zlib.z.msg = PNGZ_MSG_CAST(
"invalid distance too far back"); "invalid distance too far back");
zlib_message(&zlib, 0/*stream error*/); zlib_message(&zlib, 0/*stream error*/);
zlib_end(&zlib); zlib_end(&zlib);