summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2016-10-30 08:09:54 -0500
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2016-10-30 08:39:00 -0500
commit5a945f3393014649c23a189ea688adbeb2d2f6d4 (patch)
treeda614f615bd4325eba3bd47b43147746e914b110
parentb555c55c6d1567fc0af04d3dd90ba426dd78e70a (diff)
downloadlibpng-5a945f3393014649c23a189ea688adbeb2d2f6d4.tar.gz
[libpng15] Merge with libpng16/pngtest.c, pngvalid.c, gregbook, pngminim
-rw-r--r--ANNOUNCE6
-rw-r--r--CHANGES4
-rw-r--r--contrib/gregbook/Makefile.unx5
-rw-r--r--contrib/gregbook/README2
-rw-r--r--contrib/gregbook/readpng.c3
-rw-r--r--contrib/gregbook/readpng2.c111
-rw-r--r--contrib/gregbook/readppm.c8
-rw-r--r--contrib/gregbook/rpng-win.c2
-rw-r--r--contrib/gregbook/rpng-x.c14
-rw-r--r--contrib/gregbook/rpng2-win.c4
-rw-r--r--contrib/gregbook/writepng.c2
-rw-r--r--contrib/libtests/pngvalid.c46
-rw-r--r--contrib/pngminim/README1
-rw-r--r--contrib/pngminim/decoder/pngusr.dfa3
-rw-r--r--contrib/pngminim/decoder/pngusr.h3
-rw-r--r--contrib/pngminim/encoder/pngusr.dfa3
-rw-r--r--contrib/pngminim/encoder/pngusr.h3
-rw-r--r--contrib/pngminim/preader/pngusr.dfa2
-rw-r--r--contrib/pngminim/preader/pngusr.h3
-rw-r--r--pngtest.c393
20 files changed, 333 insertions, 285 deletions
diff --git a/ANNOUNCE b/ANNOUNCE
index de1d14fae..ec9290122 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
-Libpng 1.5.28beta01 - August 18, 2016
+Libpng 1.5.28beta01 - October 30, 2016
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
@@ -26,8 +26,8 @@ Other information:
Changes since the last public release (1.5.27):
-version 1.5.28beta01 [August 18, 2016]
- Merge with current libpng16 pngvalid.c
+version 1.5.28beta01 [October 30, 2016]
+ Merge with current libpng16 gregbook, pngvalid.c, pngtest.c
Fixed undefined behavior in png_push_save_buffer(). Do not call
memcpy() with a null source, even if count is zero (Leon Scroggins III).
Added "Common linking failures" section to INSTALL.
diff --git a/CHANGES b/CHANGES
index d3dec228c..758872674 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4496,8 +4496,8 @@ version 1.5.27rc01 [May 14, 2016]
version 1.5.27 [May 26, 2016]
No changes.
-version 1.5.28beta01 [August 18, 2016]
- Merge with current libpng16 pngvalid.c
+version 1.5.28beta01 [October 30, 2016]
+ Merge with current libpng16 gregbook, pngvalid.c, pngtest.c
Fixed undefined behavior in png_push_save_buffer(). Do not call
memcpy() with a null source, even if count is zero (Leon Scroggins III).
Added "Common linking failures" section to INSTALL.
diff --git a/contrib/gregbook/Makefile.unx b/contrib/gregbook/Makefile.unx
index abd8abbaf..b33aae8fc 100644
--- a/contrib/gregbook/Makefile.unx
+++ b/contrib/gregbook/Makefile.unx
@@ -59,15 +59,16 @@ INCS = $(PNGINC) $(ZINC) $(XINC)
RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
-WLIBSs = $(PNGLIBs) $(ZLIBs)
+WLIBSs = $(PNGLIBs) $(ZLIBs) -lm
CC = gcc
LD = gcc
RM = rm -f
CPPFLAGS = $(INCS) -DFEATURE_LOOP
CFLAGS = -O -Wall
+#CFLAGS = -O -W -Wall -Wextra -pedantic -ansi
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
-# [-ansi, -pedantic and -W can also be used]
+# [-ansi, -pedantic, -Wextra, and -W can also be used]
LDFLAGS =
O = .o
E =
diff --git a/contrib/gregbook/README b/contrib/gregbook/README
index 7b1f6a3ea..fd30f0581 100644
--- a/contrib/gregbook/README
+++ b/contrib/gregbook/README
@@ -15,7 +15,7 @@ of PBMPLUS/NetPBM) and converts them to PNG.
The source code for all three demo programs currently compiles under
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
-zinser@decus.de, for making the necessary changes for OpenVMS and for
+zinser at decus.de, for making the necessary changes for OpenVMS and for
providing an appropriate build script.) Build instructions can be found
below.
diff --git a/contrib/gregbook/readpng.c b/contrib/gregbook/readpng.c
index f5e1fb1a4..9167403e5 100644
--- a/contrib/gregbook/readpng.c
+++ b/contrib/gregbook/readpng.c
@@ -100,7 +100,8 @@ int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
/* could pass pointers to user-defined error handlers instead of NULLs: */
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), NULL, NULL,
+ NULL);
if (!png_ptr)
return 4; /* out of memory */
diff --git a/contrib/gregbook/readpng2.c b/contrib/gregbook/readpng2.c
index b9746b756..4d5e38fe2 100644
--- a/contrib/gregbook/readpng2.c
+++ b/contrib/gregbook/readpng2.c
@@ -4,7 +4,7 @@
---------------------------------------------------------------------------
- Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
+ Copyright (c) 1998-2015 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
@@ -51,6 +51,11 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ---------------------------------------------------------------------------
+
+ Changelog:
+ 2015-11-12 - Check return value of png_get_bKGD() (Glenn R-P)
+
---------------------------------------------------------------------------*/
@@ -69,6 +74,7 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass);
static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr);
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
+static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg);
@@ -103,8 +109,8 @@ int readpng2_init(mainprog_info *mainprog_ptr)
/* could also replace libpng warning-handler (final NULL), but no need: */
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
- readpng2_error_handler, NULL);
+ png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), mainprog_ptr,
+ readpng2_error_handler, readpng2_warning_handler);
if (!png_ptr)
return 4; /* out of memory */
@@ -136,29 +142,23 @@ int readpng2_init(mainprog_info *mainprog_ptr)
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
{
- /* These byte strings were copied from png.h. If a future libpng
- * version recognizes more chunks, add them to this list. If a
- * future version of readpng2.c recognizes more chunks, delete them
- * from this list. */
- static /* const */ png_byte chunks_to_ignore[] = {
- 99, 72, 82, 77, '\0', /* cHRM */
- 104, 73, 83, 84, '\0', /* hIST */
- 105, 67, 67, 80, '\0', /* iCCP */
- 105, 84, 88, 116, '\0', /* iTXt */
- 111, 70, 70, 115, '\0', /* oFFs */
- 112, 67, 65, 76, '\0', /* pCAL */
- 112, 72, 89, 115, '\0', /* pHYs */
- 115, 66, 73, 84, '\0', /* sBIT */
- 115, 67, 65, 76, '\0', /* sCAL */
- 115, 80, 76, 84, '\0', /* sPLT */
- 115, 84, 69, 82, '\0', /* sTER */
- 116, 69, 88, 116, '\0', /* tEXt */
- 116, 73, 77, 69, '\0', /* tIME */
- 122, 84, 88, 116, '\0' /* zTXt */
- };
-
- png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
- chunks_to_ignore, sizeof(chunks_to_ignore)/5);
+ /* These byte strings were copied from png.h. If a future version
+ * of readpng2.c recognizes more chunks, add them to this list.
+ */
+ static PNG_CONST png_byte chunks_to_process[] = {
+ 98, 75, 71, 68, '\0', /* bKGD */
+ 103, 65, 77, 65, '\0', /* gAMA */
+ 115, 82, 71, 66, '\0', /* sRGB */
+ };
+
+ /* Ignore all chunks except for IHDR, PLTE, tRNS, IDAT, and IEND */
+ png_set_keep_unknown_chunks(png_ptr, -1 /* PNG_HANDLE_CHUNK_NEVER */,
+ NULL, -1);
+
+ /* But do not ignore chunks in the "chunks_to_process" list */
+ png_set_keep_unknown_chunks(png_ptr,
+ 0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */, chunks_to_process,
+ sizeof(chunks_to_process)/5);
}
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
@@ -266,36 +266,38 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
/* since we know we've read all of the PNG file's "header" (i.e., up
* to IDAT), we can check for a background color here */
- if (mainprog_ptr->need_bgcolor &&
- png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD))
+ if (mainprog_ptr->need_bgcolor)
{
png_color_16p pBackground;
/* it is not obvious from the libpng documentation, but this function
* takes a pointer to a pointer, and it always returns valid red,
* green and blue values, regardless of color_type: */
- png_get_bKGD(png_ptr, info_ptr, &pBackground);
-
- /* however, it always returns the raw bKGD data, regardless of any
- * bit-depth transformations, so check depth and adjust if necessary */
- if (bit_depth == 16) {
- mainprog_ptr->bg_red = pBackground->red >> 8;
- mainprog_ptr->bg_green = pBackground->green >> 8;
- mainprog_ptr->bg_blue = pBackground->blue >> 8;
- } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
- if (bit_depth == 1)
- mainprog_ptr->bg_red = mainprog_ptr->bg_green =
- mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
- else if (bit_depth == 2)
- mainprog_ptr->bg_red = mainprog_ptr->bg_green =
- mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
- else /* bit_depth == 4 */
- mainprog_ptr->bg_red = mainprog_ptr->bg_green =
- mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
- } else {
- mainprog_ptr->bg_red = (uch)pBackground->red;
- mainprog_ptr->bg_green = (uch)pBackground->green;
- mainprog_ptr->bg_blue = (uch)pBackground->blue;
+ if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
+ {
+
+ /* however, it always returns the raw bKGD data, regardless of any
+ * bit-depth transformations, so check depth and adjust if necessary
+ */
+ if (bit_depth == 16) {
+ mainprog_ptr->bg_red = pBackground->red >> 8;
+ mainprog_ptr->bg_green = pBackground->green >> 8;
+ mainprog_ptr->bg_blue = pBackground->blue >> 8;
+ } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
+ if (bit_depth == 1)
+ mainprog_ptr->bg_red = mainprog_ptr->bg_green =
+ mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
+ else if (bit_depth == 2)
+ mainprog_ptr->bg_red = mainprog_ptr->bg_green =
+ mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
+ else /* bit_depth == 4 */
+ mainprog_ptr->bg_red = mainprog_ptr->bg_green =
+ mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
+ } else {
+ mainprog_ptr->bg_red = (uch)pBackground->red;
+ mainprog_ptr->bg_green = (uch)pBackground->green;
+ mainprog_ptr->bg_blue = (uch)pBackground->blue;
+ }
}
}
@@ -453,6 +455,8 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr)
/* all done */
+ (void)info_ptr; /* Unused */
+
return;
}
@@ -473,7 +477,12 @@ void readpng2_cleanup(mainprog_info *mainprog_ptr)
}
-
+static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg)
+{
+ fprintf(stderr, "readpng2 libpng warning: %s\n", msg);
+ fflush(stderr);
+ (void)png_ptr; /* Unused */
+}
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
diff --git a/contrib/gregbook/readppm.c b/contrib/gregbook/readppm.c
index be9a56d95..7fefc3943 100644
--- a/contrib/gregbook/readppm.c
+++ b/contrib/gregbook/readppm.c
@@ -163,8 +163,12 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
/* now we can go ahead and just read the whole image */
- fread(image_data, 1L, rowbytes*height, saved_infile);
-
+ if (fread(image_data, 1L, rowbytes*height, saved_infile) <
+ rowbytes*height) {
+ free (image_data);
+ image_data = NULL;
+ return NULL;
+ }
return image_data;
}
diff --git a/contrib/gregbook/rpng-win.c b/contrib/gregbook/rpng-win.c
index f53ddc8ec..cd5543937 100644
--- a/contrib/gregbook/rpng-win.c
+++ b/contrib/gregbook/rpng-win.c
@@ -182,7 +182,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
#ifndef __CYGWIN__
/* First reenable console output, which normally goes to the bit bucket
* for windowed apps. Closing the console window will terminate the
- * app. Thanks to David.Geldreich@realviz.com for supplying the magical
+ * app. Thanks to David.Geldreich at realviz.com for supplying the magical
* incantation. */
AllocConsole();
diff --git a/contrib/gregbook/rpng-x.c b/contrib/gregbook/rpng-x.c
index 6d10e1b84..ddd7c58d6 100644
--- a/contrib/gregbook/rpng-x.c
+++ b/contrib/gregbook/rpng-x.c
@@ -26,6 +26,8 @@
- 1.14: added support for X resources (thanks to Gerhard Niklasch)
- 2.00: dual-licensed (added GNU GPL)
- 2.01: fixed improper display of usage screen on PNG error(s)
+ - 2.02: Added "void(argc);" statement to quiet pedantic compiler warnings
+ about unused variable (GR-P)
---------------------------------------------------------------------------
@@ -80,7 +82,7 @@
#define PROGNAME "rpng-x"
#define LONGNAME "Simple PNG Viewer for X"
-#define VERSION "2.01 of 16 March 2008"
+#define VERSION "2.02 of 15 June 2014"
#define RESNAME "rpng" /* our X resource application name */
#define RESCLASS "Rpng" /* our X resource class name */
@@ -279,15 +281,17 @@ int main(int argc, char **argv)
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
" exp \ttransfer-function exponent (``gamma'') of the display\n"
- "\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
+ "\t\t system in floating-point format (e.g., ``%.1f''); equal\n",
+ PROGNAME, default_display_exponent);
+
+ fprintf(stderr, "\n"
"\t\t to the product of the lookup-table exponent (varies)\n"
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
" bg \tdesired background color in 7-character hex RGB format\n"
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
"\t\t used with transparent images\n"
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
- "is displayed) to quit.\n"
- "\n", PROGNAME, default_display_exponent);
+ "is displayed) to quit.\n");
exit(1);
}
@@ -419,6 +423,8 @@ int main(int argc, char **argv)
rpng_x_cleanup();
+ (void)argc; /* Unused */
+
return 0;
}
diff --git a/contrib/gregbook/rpng2-win.c b/contrib/gregbook/rpng2-win.c
index 223e73740..c924c1c6c 100644
--- a/contrib/gregbook/rpng2-win.c
+++ b/contrib/gregbook/rpng2-win.c
@@ -33,6 +33,8 @@
- 2.02: fixed improper display of usage screen on PNG error(s); fixed
unexpected-EOF and file-read-error cases
- 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options
+ - 2.04:
+ (GR-P)
---------------------------------------------------------------------------
@@ -299,7 +301,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
#ifndef __CYGWIN__
/* Next reenable console output, which normally goes to the bit bucket
* for windowed apps. Closing the console window will terminate the
- * app. Thanks to David.Geldreich@realviz.com for supplying the magical
+ * app. Thanks to David.Geldreich at realviz.com for supplying the magical
* incantation. */
AllocConsole();
diff --git a/contrib/gregbook/writepng.c b/contrib/gregbook/writepng.c
index 0dda62ea8..c5c953479 100644
--- a/contrib/gregbook/writepng.c
+++ b/contrib/gregbook/writepng.c
@@ -90,7 +90,7 @@ int writepng_init(mainprog_info *mainprog_ptr)
/* could also replace libpng warning-handler (final NULL), but no need: */
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
+ png_ptr = png_create_write_struct(png_get_libpng_ver(NULL), mainprog_ptr,
writepng_error_handler, NULL);
if (!png_ptr)
return 4; /* out of memory */
diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c
index 13b0b8df2..9b85c3ef3 100644
--- a/contrib/libtests/pngvalid.c
+++ b/contrib/libtests/pngvalid.c
@@ -1,9 +1,8 @@
/* pngvalid.c - validate libpng by constructing then reading png files.
*
- * Last changed in libpng 1.6.24 [(PENDING RELEASE)]
- * Copyright (c) 2014-2016 Glenn Randers-Pehrson
- * Written by John Cunningham Bowler
+ * Last changed in libpng 1.6.26 [October 20, 2016]
+ * Copyright (c) 2014-2016 John Cunningham Bowler
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -1115,7 +1114,7 @@ store_warning(png_structp ppIn, png_const_charp message)
if (!ps->expect_warning)
store_log(ps, pp, message, 0 /* warning */);
else
- ps->saw_warning = 1;
+ ps->saw_warning = 1;
}
/* These somewhat odd functions are used when reading an image to ensure that
@@ -1242,7 +1241,7 @@ store_image_check(const png_store* ps, png_const_structp pp, int iImage)
image += 2; /* skip image first row markers */
- while (rows-- > 0)
+ for (; rows > 0; --rows)
{
if (image[-2] != 190 || image[-1] != 239)
png_error(pp, "row start overwritten");
@@ -11427,23 +11426,36 @@ perform_interlace_macro_validation(void)
*/
for (v=0;;)
{
+ /* The first two tests overflow if the pass row or column is outside
+ * the possible range for a 32-bit result. In fact the values should
+ * never be outside the range for a 31-bit result, but checking for 32
+ * bits here ensures that if an app uses a bogus pass row or column
+ * (just so long as it fits in a 32 bit integer) it won't get a
+ * possibly dangerous overflow.
+ */
/* First the base 0 stuff: */
- m = PNG_ROW_FROM_PASS_ROW(v, pass);
- f = png_row_from_pass_row(v, pass);
- if (m != f)
+ if (v < png_pass_rows(0xFFFFFFFFU, pass))
{
- fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n",
- v, pass, m, f);
- exit(99);
+ m = PNG_ROW_FROM_PASS_ROW(v, pass);
+ f = png_row_from_pass_row(v, pass);
+ if (m != f)
+ {
+ fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n",
+ v, pass, m, f);
+ exit(99);
+ }
}
- m = PNG_COL_FROM_PASS_COL(v, pass);
- f = png_col_from_pass_col(v, pass);
- if (m != f)
+ if (v < png_pass_cols(0xFFFFFFFFU, pass))
{
- fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n",
- v, pass, m, f);
- exit(99);
+ m = PNG_COL_FROM_PASS_COL(v, pass);
+ f = png_col_from_pass_col(v, pass);
+ if (m != f)
+ {
+ fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n",
+ v, pass, m, f);
+ exit(99);
+ }
}
m = PNG_ROW_IN_INTERLACE_PASS(v, pass);
diff --git a/contrib/pngminim/README b/contrib/pngminim/README
index 51d5a3c23..e17fe35b6 100644
--- a/contrib/pngminim/README
+++ b/contrib/pngminim/README
@@ -1,3 +1,4 @@
+
This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa
to build minimal decoder, encoder, and progressive reader applications.
diff --git a/contrib/pngminim/decoder/pngusr.dfa b/contrib/pngminim/decoder/pngusr.dfa
index 70d528bc9..4f402721a 100644
--- a/contrib/pngminim/decoder/pngusr.dfa
+++ b/contrib/pngminim/decoder/pngusr.dfa
@@ -1,6 +1,6 @@
# pngminim/decoder/pngusr.dfa
#
-# Copyright (c) 2010-2011 Glenn Randers-Pehrson
+# Copyright (c) 2010-2013 Glenn Randers-Pehrson
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
@@ -37,3 +37,4 @@ option SETJMP on
option STDIO on
option READ_EXPAND on
option READ_STRIP_16_TO_8 on
+option USER_LIMITS on
diff --git a/contrib/pngminim/decoder/pngusr.h b/contrib/pngminim/decoder/pngusr.h
index 9d9c50c40..cbd7890c7 100644
--- a/contrib/pngminim/decoder/pngusr.h
+++ b/contrib/pngminim/decoder/pngusr.h
@@ -1,6 +1,6 @@
/* minrdpngconf.h: headers to make a minimal png-read-only library
*
- * Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
+ * Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -18,7 +18,6 @@
* affect the API (so are not recorded in pnglibconf.h)
*/
-#define PNG_NO_WARNINGS
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
#endif /* MINRDPNGCONF_H */
diff --git a/contrib/pngminim/encoder/pngusr.dfa b/contrib/pngminim/encoder/pngusr.dfa
index b6cf53daa..1fc24f3f2 100644
--- a/contrib/pngminim/encoder/pngusr.dfa
+++ b/contrib/pngminim/encoder/pngusr.dfa
@@ -13,7 +13,8 @@ everything = off
# Switch on the write code - this makes a minimalist encoder
option WRITE on
-# These 2 options are required if you need to read PGM (P1 or P4) PGM files.
+
+# These 2 options are required if you need to read PBM (P1 or P4) files.
option WRITE_INVERT on
option WRITE_PACK on
diff --git a/contrib/pngminim/encoder/pngusr.h b/contrib/pngminim/encoder/pngusr.h
index 2033aadb2..997d44fe9 100644
--- a/contrib/pngminim/encoder/pngusr.h
+++ b/contrib/pngminim/encoder/pngusr.h
@@ -1,6 +1,6 @@
/* minwrpngconf.h: headers to make a minimal png-write-only library
*
- * Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
+ * Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -18,7 +18,6 @@
* affect the API (so are not recorded in pnglibconf.h)
*/
-#define PNG_NO_WARNINGS
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
#endif /* MINWRPNGCONF_H */
diff --git a/contrib/pngminim/preader/pngusr.dfa b/contrib/pngminim/preader/pngusr.dfa
index 216c421ca..ac297f41b 100644
--- a/contrib/pngminim/preader/pngusr.dfa
+++ b/contrib/pngminim/preader/pngusr.dfa
@@ -1,6 +1,6 @@
# pngminim/preader/pngusr.dfa
#
-# Copyright (c) 2010-2011 Glenn Randers-Pehrson
+# Copyright (c) 2010-2013 Glenn Randers-Pehrson
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
diff --git a/contrib/pngminim/preader/pngusr.h b/contrib/pngminim/preader/pngusr.h
index 73cfecfbf..80db3bb17 100644
--- a/contrib/pngminim/preader/pngusr.h
+++ b/contrib/pngminim/preader/pngusr.h
@@ -1,6 +1,6 @@
/* minrdpngconf.h: headers to make a minimal png-read-only library
*
- * Copyright (c) 2009, 2010-2011 Glenn Randers-Pehrson
+ * Copyright (c) 2009, 2010-2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -18,7 +18,6 @@
* affect the API (so are not recorded in pnglibconf.h)
*/
-#define PNG_NO_WARNINGS
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
#endif /* MINPRDPNGCONF_H */
diff --git a/pngtest.c b/pngtest.c
index 4ee374688..57f141e9e 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,8 +1,8 @@
/* pngtest.c - a simple test program to test libpng
*
- * Last changed in libpng 1.5.25 [December 3, 2015]
- * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.26 [October 20, 2016]
+ * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -130,13 +130,13 @@ static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
static int
tIME_to_str(png_structp png_ptr, png_charp ts, png_const_timep t)
{
- png_const_charp str = png_convert_to_rfc1123(png_ptr, t);
+ png_const_charp str = png_convert_to_rfc1123(png_ptr, t);
- if (str == NULL)
- return 0;
+ if (str == NULL)
+ return 0;
- strcpy(ts, str);
- return 1;
+ strcpy(ts, str);
+ return 1;
}
#endif /* older libpng */
#endif
@@ -240,95 +240,95 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
* png_byte pixel_depth bits per pixel (depth*channels)
*/
- /* Counts the number of zero samples (or zero pixels if color_type is 3 */
+ /* Counts the number of zero samples (or zero pixels if color_type is 3 */
- if (row_info->color_type == 0 || row_info->color_type == 3)
- {
- int pos = 0;
- png_uint_32 n, nstop;
+ if (row_info->color_type == 0 || row_info->color_type == 3)
+ {
+ int pos = 0;
+ png_uint_32 n, nstop;
- for (n = 0, nstop=row_info->width; n<nstop; n++)
- {
- if (row_info->bit_depth == 1)
- {
- if (((*dp << pos++ ) & 0x80) == 0)
- zero_samples++;
+ for (n = 0, nstop=row_info->width; n<nstop; n++)
+ {
+ if (row_info->bit_depth == 1)
+ {
+ if (((*dp << pos++ ) & 0x80) == 0)
+ zero_samples++;
- if (pos == 8)
- {
- pos = 0;
- dp++;
- }
- }
+ if (pos == 8)
+ {
+ pos = 0;
+ dp++;
+ }
+ }
- if (row_info->bit_depth == 2)
- {
- if (((*dp << (pos+=2)) & 0xc0) == 0)
- zero_samples++;
+ if (row_info->bit_depth == 2)
+ {
+ if (((*dp << (pos+=2)) & 0xc0) == 0)
+ zero_samples++;
- if (pos == 8)
- {
- pos = 0;
- dp++;
- }
- }
+ if (pos == 8)
+ {
+ pos = 0;
+ dp++;
+ }
+ }
- if (row_info->bit_depth == 4)
- {
- if (((*dp << (pos+=4)) & 0xf0) == 0)
- zero_samples++;
+ if (row_info->bit_depth == 4)
+ {
+ if (((*dp << (pos+=4)) & 0xf0) == 0)
+ zero_samples++;
- if (pos == 8)
- {
- pos = 0;
- dp++;
- }
- }
+ if (pos == 8)
+ {
+ pos = 0;
+ dp++;
+ }
+ }
- if (row_info->bit_depth == 8)
- if (*dp++ == 0)
- zero_samples++;
+ if (row_info->bit_depth == 8)
+ if (*dp++ == 0)
+ zero_samples++;
- if (row_info->bit_depth == 16)
- {
- if ((*dp | *(dp+1)) == 0)
- zero_samples++;
- dp+=2;
- }
- }
- }
- else /* Other color types */
- {
- png_uint_32 n, nstop;
- int channel;
- int color_channels = row_info->channels;
- if (row_info->color_type > 3)
- color_channels--;
-
- for (n = 0, nstop=row_info->width; n<nstop; n++)
- {
- for (channel = 0; channel < color_channels; channel++)
- {
- if (row_info->bit_depth == 8)
- if (*dp++ == 0)
- zero_samples++;
+ if (row_info->bit_depth == 16)
+ {
+ if ((*dp | *(dp+1)) == 0)
+ zero_samples++;
+ dp+=2;
+ }
+ }
+ }
+ else /* Other color types */
+ {
+ png_uint_32 n, nstop;
+ int channel;
+ int color_channels = row_info->channels;
+ if (row_info->color_type > 3)
+ color_channels--;
- if (row_info->bit_depth == 16)
- {
- if ((*dp | *(dp+1)) == 0)
- zero_samples++;
+ for (n = 0, nstop=row_info->width; n<nstop; n++)
+ {
+ for (channel = 0; channel < color_channels; channel++)
+ {
+ if (row_info->bit_depth == 8)
+ if (*dp++ == 0)
+ zero_samples++;
- dp+=2;
- }
- }
- if (row_info->color_type > 3)
- {
- dp++;
- if (row_info->bit_depth == 16)
- dp++;
- }
- }
- }
+ if (row_info->bit_depth == 16)
+ {
+ if ((*dp | *(dp+1)) == 0)
+ zero_samples++;
+
+ dp+=2;
+ }
+ }
+ if (row_info->color_type > 3)
+ {
+ dp++;
+ if (row_info->bit_depth == 16)
+ dp++;
+ }
+ }
+ }
}
#endif /* WRITE_USER_TRANSFORM */
@@ -345,10 +345,10 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
#ifdef PNG_IO_STATE_SUPPORTED
void
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
- png_uint_32 io_op);
+ png_uint_32 io_op);
void
pngtest_check_io_state(png_structp png_ptr, png_size_t data_length,
- png_uint_32 io_op)
+ png_uint_32 io_op)
{
png_uint_32 io_state = png_get_io_state(png_ptr);
int err = 0;
@@ -532,7 +532,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
memory_infop pinfo;
png_set_mem_fn(png_ptr, NULL, NULL, NULL);
pinfo = (memory_infop)png_malloc(png_ptr,
- (sizeof *pinfo));
+ (sizeof *pinfo));
pinfo->size = size;
current_allocation += size;
total_allocation += size;
@@ -562,7 +562,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
if (verbose != 0)
printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
- pinfo->pointer);
+ pinfo->pointer);
return (png_voidp)(pinfo->pointer);
}
@@ -769,9 +769,9 @@ write_vpAg_chunk(png_structp write_ptr)
if (verbose != 0)
fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
- (unsigned long)user_chunk_data.vpAg_width,
- (unsigned long)user_chunk_data.vpAg_height,
- user_chunk_data.vpAg_units);
+ (unsigned long)user_chunk_data.vpAg_width,
+ (unsigned long)user_chunk_data.vpAg_height,
+ user_chunk_data.vpAg_units);
png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);
@@ -812,7 +812,7 @@ write_chunks(png_structp write_ptr, int location)
#ifdef PNG_TEXT_SUPPORTED
static void
pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
- int num_text)
+ int num_text)
{
while (num_text > 0)
{
@@ -894,26 +894,26 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
pngtest_debug("Allocating read and write structures");
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
read_ptr =
- png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
- NULL, NULL, NULL, png_debug_malloc, png_debug_free);
+ png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL,
+ NULL, NULL, NULL, png_debug_malloc, png_debug_free);
#else
read_ptr =
- png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
png_set_error_fn(read_ptr, &error_parameters, pngtest_error,
- pngtest_warning);
+ pngtest_warning);
#ifdef PNG_WRITE_SUPPORTED
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
write_ptr =
- png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,
- NULL, NULL, NULL, png_debug_malloc, png_debug_free);
+ png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL,
+ NULL, NULL, NULL, png_debug_malloc, png_debug_free);
#else
write_ptr =
- png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
png_set_error_fn(write_ptr, &error_parameters, pngtest_error,
- pngtest_warning);
+ pngtest_warning);
#endif
pngtest_debug("Allocating read_info, write_info and end_info structures");
read_info_ptr = png_create_info_struct(read_ptr);
@@ -926,7 +926,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
init_callback_info(read_info_ptr);
png_set_read_user_chunk_fn(read_ptr, &user_chunk_data,
- read_user_chunk_callback);
+ read_user_chunk_callback);
#endif
#ifdef PNG_SETJMP_SUPPORTED
@@ -964,15 +964,16 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif
#endif
+#ifdef PNG_BENIGN_ERRORS_SUPPORTED
if (strict != 0)
{
/* Treat png_benign_error() as errors on read */
png_set_benign_errors(read_ptr, 0);
-#ifdef PNG_WRITE_SUPPORTED
+# ifdef PNG_WRITE_SUPPORTED
/* Treat them as errors on write */
png_set_benign_errors(write_ptr, 0);
-#endif
+# endif
/* if strict is not set, then app warnings and errors are treated as
* warnings in release builds, but not in unstable builds; this can be
@@ -985,10 +986,15 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
/* Allow application (pngtest) errors and warnings to pass */
png_set_benign_errors(read_ptr, 1);
-#ifdef PNG_WRITE_SUPPORTED
+ /* Turn off CRC and ADLER32 checking while reading */
+ png_set_crc_action(read_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE);
+
+# ifdef PNG_WRITE_SUPPORTED
png_set_benign_errors(write_ptr, 1);
-#endif
+# endif
+
}
+#endif /* BENIGN_ERRORS */
pngtest_debug("Initializing input and output streams");
#ifdef PNG_STDIO_SUPPORTED
@@ -1001,9 +1007,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
# ifdef PNG_WRITE_SUPPORTED
png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data,
# ifdef PNG_WRITE_FLUSH_SUPPORTED
- pngtest_flush);
+ pngtest_flush);
# else
- NULL);
+ NULL);
# endif
# endif
#endif
@@ -1043,11 +1049,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
*/
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,
- NULL, 0);
+ NULL, 0);
#endif
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS,
- NULL, 0);
+ NULL, 0);
#endif
#endif
@@ -1071,7 +1077,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
&color_type, &interlace_type, &compression_type, &filter_type) != 0)
{
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
- color_type, interlace_type, compression_type, filter_type);
+ color_type, interlace_type, compression_type, filter_type);
/* num_passes may not be available below if interlace support is not
* provided by libpng for both read and write.
*/
@@ -1098,13 +1104,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_cHRM_SUPPORTED
{
png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
- blue_y;
+ blue_y;
if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y,
- &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
+ &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
{
png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x,
- red_y, green_x, green_y, blue_x, blue_y);
+ red_y, green_x, green_y, blue_x, blue_y);
}
}
#endif
@@ -1121,13 +1127,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_cHRM_SUPPORTED
{
double white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
- blue_y;
+ blue_y;
if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x,
- &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
+ &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0)
{
png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x,
- red_y, green_x, green_y, blue_x, blue_y);
+ red_y, green_x, green_y, blue_x, blue_y);
}
}
#endif
@@ -1149,10 +1155,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int compression_type;
if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type,
- &profile, &proflen) != 0)
+ &profile, &proflen) != 0)
{
png_set_iCCP(write_ptr, write_info_ptr, name, compression_type,
- profile, proflen);
+ profile, proflen);
}
}
#endif
@@ -1209,10 +1215,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int type, nparams;
if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
- &nparams, &units, &params) != 0)
+ &nparams, &units, &params) != 0)
{
png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
- nparams, units, params);
+ nparams, units, params);
}
}
#endif
@@ -1242,7 +1248,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
double scal_width, scal_height;
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
- &scal_height) != 0)
+ &scal_height) != 0)
{
png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
}
@@ -1254,7 +1260,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_charp scal_width, scal_height;
if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width,
- &scal_height) != 0)
+ &scal_height) != 0)
{
png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width,
scal_height);
@@ -1295,7 +1301,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
for (i=0; i<num_text; i++)
{
printf(" Text compression[%d]=%d\n",
- i, text_ptr[i].compression);
+ i, text_ptr[i].compression);
}
}
@@ -1332,7 +1338,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_color_16p trans_color;
if (png_get_tRNS(read_ptr, read_info_ptr, &trans_alpha, &num_trans,
- &trans_color) != 0)
+ &trans_color) != 0)
{
int sample_max = (1 << bit_depth);
/* libpng doesn't reject a tRNS chunk with out-of-range samples */
@@ -1351,12 +1357,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{
png_unknown_chunkp unknowns;
int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr,
- &unknowns);
+ &unknowns);
if (num_unknowns != 0)
{
png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns,
- num_unknowns);
+ num_unknowns);
#if PNG_LIBPNG_VER < 10600
/* Copy the locations from the read_info_ptr. The automatically
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
@@ -1366,7 +1372,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int i;
for (i = 0; i < num_unknowns; i++)
png_set_unknown_chunk_location(write_ptr, write_info_ptr, i,
- unknowns[i].location);
+ unknowns[i].location);
}
#endif
}
@@ -1386,12 +1392,17 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_write_info(write_ptr, write_info_ptr);
write_chunks(write_ptr, before_IDAT); /* after PLTE */
+
+#ifdef PNG_COMPRESSION_COMPAT
+ /* Test the 'compatibility' setting here, if it is available. */
+ png_set_compression(write_ptr, PNG_COMPRESSION_COMPAT);
+#endif
#endif
#ifdef SINGLE_ROWBUF_ALLOC
pngtest_debug("Allocating row buffer...");
row_buf = (png_bytep)png_malloc(read_ptr,
- png_get_rowbytes(read_ptr, read_info_ptr));
+ png_get_rowbytes(read_ptr, read_info_ptr));
pngtest_debug1("\t0x%08lx", (unsigned long)row_buf);
#endif /* SINGLE_ROWBUF_ALLOC */
@@ -1405,10 +1416,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
*/
if (png_set_interlace_handling(read_ptr) != num_passes)
png_error(write_ptr,
- "png_set_interlace_handling(read): wrong pass count ");
+ "png_set_interlace_handling(read): wrong pass count ");
if (png_set_interlace_handling(write_ptr) != num_passes)
png_error(write_ptr,
- "png_set_interlace_handling(write): wrong pass count ");
+ "png_set_interlace_handling(write): wrong pass count ");
#else /* png_set_interlace_handling not called on either read or write */
# define calc_pass_height
#endif /* not using libpng interlace handling */
@@ -1445,10 +1456,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y);
row_buf = (png_bytep)png_malloc(read_ptr,
- png_get_rowbytes(read_ptr, read_info_ptr));
+ png_get_rowbytes(read_ptr, read_info_ptr));
pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
- (unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
+ (unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
#endif /* !SINGLE_ROWBUF_ALLOC */
png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1);
@@ -1506,7 +1517,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
for (i=0; i<num_text; i++)
{
printf(" Text compression[%d]=%d\n",
- i, text_ptr[i].compression);
+ i, text_ptr[i].compression);
}
}
@@ -1540,12 +1551,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
{
png_unknown_chunkp unknowns;
int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr,
- &unknowns);
+ &unknowns);
if (num_unknowns != 0)
{
png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns,
- num_unknowns);
+ num_unknowns);
#if PNG_LIBPNG_VER < 10600
/* Copy the locations from the read_info_ptr. The automatically
* generated locations in write_end_info_ptr are wrong prior to 1.6.0
@@ -1555,7 +1566,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
int i;
for (i = 0; i < num_unknowns; i++)
png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i,
- unknowns[i].location);
+ unknowns[i].location);
}
#endif
}
@@ -1589,7 +1600,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
iwidth = png_get_image_width(write_ptr, write_info_ptr);
iheight = png_get_image_height(write_ptr, write_info_ptr);
fprintf(STDERR, "\n Image width = %lu, height = %lu\n",
- (unsigned long)iwidth, (unsigned long)iheight);
+ (unsigned long)iwidth, (unsigned long)iheight);
}
#endif
@@ -1622,7 +1633,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
* above, but this is safe.
*/
fprintf(STDERR, "\n %s: %d libpng errors found (%d warnings)",
- inname, error_count, warning_count);
+ inname, error_count, warning_count);
if (strict != 0)
return (1);
@@ -1633,14 +1644,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
else if (unsupported_chunks > 0)
{
fprintf(STDERR, "\n %s: unsupported chunks (%d)%s",
- inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
+ inname, unsupported_chunks, strict ? ": IGNORED --strict!" : "");
}
# endif
else if (warning_count > 0)
{
fprintf(STDERR, "\n %s: %d libpng warnings found",
- inname, warning_count);
+ inname, warning_count);
if (strict != 0)
return (1);
@@ -1676,18 +1687,19 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (num_in != num_out)
{
fprintf(STDERR, "\nFiles %s and %s are of a different size\n",
- inname, outname);
+ inname, outname);
if (wrote_question == 0 && unsupported_chunks == 0)
{
fprintf(STDERR,
- " Was %s written with the same maximum IDAT chunk size (%d bytes),",
- inname, PNG_ZBUF_SIZE);
+ " Was %s written with the same maximum IDAT"
+ " chunk size (%d bytes),",
+ inname, PNG_ZBUF_SIZE);
fprintf(STDERR,
- "\n filtering heuristic (libpng default), compression");
+ "\n filtering heuristic (libpng default), compression");
fprintf(STDERR,
- " level (zlib default),\n and zlib version (%s)?\n\n",
- ZLIB_VERSION);
+ " level (zlib default),\n and zlib version (%s)?\n\n",
+ ZLIB_VERSION);
wrote_question = 1;
}
@@ -1707,17 +1719,18 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
if (memcmp(inbuf, outbuf, num_in))
{
fprintf(STDERR, "\nFiles %s and %s are different\n", inname,
- outname);
+ outname);
if (wrote_question == 0 && unsupported_chunks == 0)
{
fprintf(STDERR,
- " Was %s written with the same maximum IDAT chunk size (%d bytes),",
+ " Was %s written with the same maximum"
+ " IDAT chunk size (%d bytes),",
inname, PNG_ZBUF_SIZE);
fprintf(STDERR,
- "\n filtering heuristic (libpng default), compression");
+ "\n filtering heuristic (libpng default), compression");
fprintf(STDERR,
- " level (zlib default),\n and zlib version (%s)?\n\n",
+ " level (zlib default),\n and zlib version (%s)?\n\n",
ZLIB_VERSION);
wrote_question = 1;
}
@@ -1768,12 +1781,12 @@ main(int argc, char *argv[])
fprintf(STDERR, "%s", png_get_copyright(NULL));
/* Show the version of libpng used in building the library */
fprintf(STDERR, " library (%lu):%s",
- (unsigned long)png_access_version_number(),
- png_get_header_version(NULL));
+ (unsigned long)png_access_version_number(),
+ png_get_header_version(NULL));
/* Show the version of libpng used in building the application */
fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER,
- PNG_HEADER_VERSION_STRING);
+ PNG_HEADER_VERSION_STRING);
/* Do some consistency checking on the memory allocation settings, I'm
* not sure this matters, but it is nice to know, the first of these
@@ -1791,7 +1804,7 @@ main(int argc, char *argv[])
if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
{
fprintf(STDERR,
- "Warning: versions are different between png.h and png.c\n");
+ "Warning: versions are different between png.h and png.c\n");
fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING);
fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver);
++ierror;
@@ -1846,19 +1859,19 @@ main(int argc, char *argv[])
}
if (multiple == 0 && argc == 3 + verbose)
- outname = argv[2 + verbose];
+ outname = argv[2 + verbose];
if ((multiple == 0 && argc > 3 + verbose) ||
(multiple != 0 && argc < 2))
{
- fprintf(STDERR,
- "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
- argv[0], argv[0]);
- fprintf(STDERR,
- " reads/writes one PNG file (without -m) or multiple files (-m)\n");
- fprintf(STDERR,
- " with -m %s is used as a temporary file\n", outname);
- exit(1);
+ fprintf(STDERR,
+ "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n",
+ argv[0], argv[0]);
+ fprintf(STDERR,
+ " reads/writes one PNG file (without -m) or multiple files (-m)\n");
+ fprintf(STDERR,
+ " with -m %s is used as a temporary file\n", outname);
+ exit(1);
}
if (multiple != 0)
@@ -1879,7 +1892,7 @@ main(int argc, char *argv[])
{
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
- (unsigned long)zero_samples);
+ (unsigned long)zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
@@ -1899,20 +1912,20 @@ main(int argc, char *argv[])
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
if (allocation_now != current_allocation)
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
- current_allocation - allocation_now);
+ current_allocation - allocation_now);
if (current_allocation != 0)
{
memory_infop pinfo = pinformation;
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
- current_allocation);
+ current_allocation);
while (pinfo != NULL)
{
fprintf(STDERR, " %lu bytes at %p\n",
- (unsigned long)pinfo->size,
- pinfo->pointer);
+ (unsigned long)pinfo->size,
+ pinfo->pointer);
pinfo = pinfo->next;
}
}
@@ -1920,13 +1933,13 @@ main(int argc, char *argv[])
}
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
fprintf(STDERR, " Current memory allocation: %10d bytes\n",
- current_allocation);
+ current_allocation);
fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
- maximum_allocation);
+ maximum_allocation);
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
- total_allocation);
+ total_allocation);
fprintf(STDERR, " Number of allocations: %10d\n",
- num_allocations);
+ num_allocations);
#endif
}
@@ -1961,7 +1974,7 @@ main(int argc, char *argv[])
{
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
fprintf(STDERR, "\n PASS (%lu zero samples)\n",
- (unsigned long)zero_samples);
+ (unsigned long)zero_samples);
#else
fprintf(STDERR, " PASS\n");
#endif
@@ -1988,19 +2001,19 @@ main(int argc, char *argv[])
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
if (allocation_now != current_allocation)
fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n",
- current_allocation - allocation_now);
+ current_allocation - allocation_now);
if (current_allocation != 0)
{
memory_infop pinfo = pinformation;
fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n",
- current_allocation);
+ current_allocation);
while (pinfo != NULL)
{
fprintf(STDERR, " %lu bytes at %p\n",
- (unsigned long)pinfo->size, pinfo->pointer);
+ (unsigned long)pinfo->size, pinfo->pointer);
pinfo = pinfo->next;
}
}
@@ -2008,13 +2021,13 @@ main(int argc, char *argv[])
}
#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG
fprintf(STDERR, " Current memory allocation: %10d bytes\n",
- current_allocation);
+ current_allocation);
fprintf(STDERR, " Maximum memory allocation: %10d bytes\n",
- maximum_allocation);
+ maximum_allocation);
fprintf(STDERR, " Total memory allocation: %10d bytes\n",
- total_allocation);
+ total_allocation);
fprintf(STDERR, " Number of allocations: %10d\n",
- num_allocations);
+ num_allocations);
#endif
}
@@ -2023,13 +2036,13 @@ main(int argc, char *argv[])
t_misc += (t_stop - t_start);
t_start = t_stop;
fprintf(STDERR, " CPU time used = %.3f seconds",
- (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
+ (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC);
fprintf(STDERR, " (decoding %.3f,\n",
- t_decode/(float)CLOCKS_PER_SEC);
+ t_decode/(float)CLOCKS_PER_SEC);
fprintf(STDERR, " encoding %.3f ,",
- t_encode/(float)CLOCKS_PER_SEC);
+ t_encode/(float)CLOCKS_PER_SEC);
fprintf(STDERR, " other %.3f seconds)\n\n",
- t_misc/(float)CLOCKS_PER_SEC);
+ t_misc/(float)CLOCKS_PER_SEC);
#endif
if (ierror == 0)
@@ -2041,19 +2054,19 @@ main(int argc, char *argv[])
dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
fprintf(STDERR, " Default limits:\n");
fprintf(STDERR, " width_max = %lu\n",
- (unsigned long) png_get_user_width_max(dummy_ptr));
+ (unsigned long) png_get_user_width_max(dummy_ptr));
fprintf(STDERR, " height_max = %lu\n",
- (unsigned long) png_get_user_height_max(dummy_ptr));
+ (unsigned long) png_get_user_height_max(dummy_ptr));
if (png_get_chunk_cache_max(dummy_ptr) == 0)
fprintf(STDERR, " cache_max = unlimited\n");
else
fprintf(STDERR, " cache_max = %lu\n",
- (unsigned long) png_get_chunk_cache_max(dummy_ptr));
+ (unsigned long) png_get_chunk_cache_max(dummy_ptr));
if (png_get_chunk_malloc_max(dummy_ptr) == 0)
fprintf(STDERR, " malloc_max = unlimited\n");
else
fprintf(STDERR, " malloc_max = %lu\n",
- (unsigned long) png_get_chunk_malloc_max(dummy_ptr));
+ (unsigned long) png_get_chunk_malloc_max(dummy_ptr));
png_destroy_read_struct(&dummy_ptr, NULL, NULL);
return (int)(ierror != 0);
@@ -2063,7 +2076,7 @@ int
main(void)
{
fprintf(STDERR,
- " test ignored because libpng was not built with read support\n");
+ " test ignored because libpng was not built with read support\n");
/* And skip this test */
return PNG_LIBPNG_VER < 10600 ? 0 : 77;
}