summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Bowler <jbowler@acm.org>2013-10-04 20:13:17 -0500
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2013-10-04 20:13:17 -0500
commit5b1df53a826f149c77e0c5930a5ed18a39f534bd (patch)
tree354df42869ecc2699fcd76b89f45be8dd8cbd960
parent940b37b197835b60241571a3b0544849af98cd45 (diff)
downloadlibpng-5b1df53a826f149c77e0c5930a5ed18a39f534bd.tar.gz
[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
-rw-r--r--ANNOUNCE3
-rw-r--r--CHANGES3
-rw-r--r--contrib/tools/pngfix.c27
3 files changed, 31 insertions, 2 deletions
diff --git a/ANNOUNCE b/ANNOUNCE
index 634c9eadb..d860a9b50 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -62,6 +62,9 @@ Version 1.6.7beta02 [October 5, 2013]
way of handling the dependencies of sources that are machine generated;
unfortunately it only works if the user does 'make all' or 'make check',
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
(subscription required; visit
diff --git a/CHANGES b/CHANGES
index d4b88c984..1d371c9b1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4676,6 +4676,9 @@ Version 1.6.7beta02 [October 5, 2013]
way of handling the dependencies of sources that are machine generated;
unfortunately it only works if the user does 'make all' or 'make check',
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
(subscription required; visit
diff --git a/contrib/tools/pngfix.c b/contrib/tools/pngfix.c
index 63d701169..dd74b83fc 100644
--- a/contrib/tools/pngfix.c
+++ b/contrib/tools/pngfix.c
@@ -50,7 +50,30 @@
#endif
#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>
+#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
# error "pngfix not supported in this libpng version"
@@ -2636,7 +2659,7 @@ zlib_check(struct file *file, png_uint_32 offset)
case ZLIB_OK:
/* 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*/);
/* FALL THROUGH */
@@ -2675,7 +2698,7 @@ zlib_check(struct file *file, png_uint_32 offset)
/* Output the error that wasn't output before: */
if (zlib.z.msg == NULL)
- zlib.z.msg = png_constcast(char*,
+ zlib.z.msg = PNGZ_MSG_CAST(
"invalid distance too far back");
zlib_message(&zlib, 0/*stream error*/);
zlib_end(&zlib);