Imported Upstream version 1.6.37 60/223660/1 upstream/1.6.37
authorjiyong.min <jiyong.min@samsung.com>
Sun, 2 Feb 2020 23:03:37 +0000 (08:03 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Sun, 2 Feb 2020 23:04:49 +0000 (08:04 +0900)
Change-Id: I0f046799eb5da533ef493571ef967481495a26ab

47 files changed:
ANNOUNCE
CHANGES
CMakeLists.txt
LICENSE
README
arm/palette_neon_intrinsics.c
configure
configure.ac
contrib/pngminus/CHANGES.txt [new file with mode: 0644]
contrib/pngminus/CMakeLists.txt [new file with mode: 0644]
contrib/pngminus/LICENSE.txt [new file with mode: 0644]
contrib/pngminus/Makefile [new file with mode: 0644]
contrib/pngminus/README.txt [moved from contrib/pngminus/README with 62% similarity]
contrib/pngminus/makefile.std [deleted file]
contrib/pngminus/makefile.tc3 [deleted file]
contrib/pngminus/png2pnm.c
contrib/pngminus/pngminus.bat
contrib/pngminus/pngminus.sh
contrib/pngminus/pnm2png.c
libpng-manual.txt
libpng.3
libpngpf.3
png.5
png.c
png.h
pngconf.h
pngpriv.h
pngread.c
pngrtran.c
pngstruct.h
pngtest.c
pngwrite.c
scripts/libpng-config-head.in
scripts/libpng.pc.in
scripts/makefile.cegcc
scripts/makefile.clang [new file with mode: 0644]
scripts/makefile.clang-asan [new file with mode: 0644]
scripts/makefile.gcc
scripts/makefile.gcc-asan [new file with mode: 0644]
scripts/makefile.linux
scripts/makefile.linux-opt
scripts/makefile.msys
scripts/makefile.ne12bsd [deleted file]
scripts/makefile.netbsd
scripts/makefile.openbsd
scripts/pnglibconf.dfa
scripts/pnglibconf.h.prebuilt

index f1724c0..ecf9c70 100644 (file)
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
-libpng 1.6.36 - December 1, 2018
-================================
+libpng 1.6.37 - April 14, 2019
+==============================
 
 This is a public release of libpng, intended for use in production code.
 
@@ -9,13 +9,13 @@ Files available for download
 
 Source files with LF line endings (for Unix/Linux):
 
- * libpng-1.6.36.tar.xz (LZMA-compressed, recommended)
- * libpng-1.6.36.tar.gz
+ * libpng-1.6.37.tar.xz (LZMA-compressed, recommended)
+ * libpng-1.6.37.tar.gz
 
 Source files with CRLF line endings (for Windows):
 
- * lp1636.7z (LZMA-compressed, recommended)
- * lp1636.zip
+ * lp1637.7z (LZMA-compressed, recommended)
+ * lp1637.zip
 
 Other information:
 
@@ -25,50 +25,20 @@ Other information:
  * TRADEMARK.md
 
 
-IMPORTANT licensing update: libpng license v2
----------------------------------------------
-
-The new libpng license comprises the terms and conditions from the zlib
-license, and the disclaimer from the Boost license.
-
-The legacy libpng license, used until libpng-1.6.35, is appended to the
-new license, following the precedent established in the Python Software
-Foundation License version 2.
-
-From now on, the list of contributing authors shall be maintained in a
-separate AUTHORS file.  The lists of previous contributing authors,
-mentioned in the legacy libpng license and considered to be an integral
-part of that license, are kept intact, with no further updates.
-
-
-Changes since the previous public release (version 1.6.35)
+Changes since the previous public release (version 1.6.36)
 ----------------------------------------------------------
 
- * Optimized png_do_expand_palette for ARM processors.
-   Improved performance by around 10-22% on a recent ARM Chromebook.
-   (Contributed by Richard Townsend, ARM Holdings)
- * Fixed manipulation of machine-specific optimization options.
-   (Contributed by Vicki Pfau)
- * Used memcpy instead of manual pointer arithmetic on Intel SSE2.
-   (Contributed by Samuel Williams)
- * Fixed build errors with MSVC on ARM64.
-   (Contributed by Zhijie Liang)
- * Fixed detection of libm in CMakeLists.
-   (Contributed by Cameron Cawley)
- * Fixed incorrect creation of pkg-config file in CMakeLists.
-   (Contributed by Kyle Bentley)
- * Fixed the CMake build on Windows MSYS by avoiding symlinks.
- * Fixed a build warning on OpenBSD.
-   (Contributed by Theo Buehler)
- * Fixed various typos in comments.
-   (Contributed by "luz.paz")
- * Raised the minimum required CMake version from 3.0.2 to 3.1.
- * Removed yet more of the vestigial support for pre-ANSI C compilers.
- * Removed ancient makefiles for ancient systems that have been broken
-   across all previous libpng-1.6.x versions.
- * Removed the Y2K compliance statement and the export control
-   information.
- * Applied various code style and documentation fixes.
+ * Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
+ * Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
+ * Fixed a memory leak in pngtest.c.
+ * Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
+   contrib/pngminus; refactor.
+ * Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
+   (Contributed by Willem van Schaik)
+ * Fixed a typo in the libpng license v2.
+   (Contributed by Miguel Ojeda)
+ * Added makefiles for AddressSanitizer-enabled builds.
+ * Cleaned up various makefiles.
 
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
diff --git a/CHANGES b/CHANGES
index bdd4480..f0b0a93 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6066,31 +6066,44 @@ Version 1.6.35 [July 15, 2018]
 Version 1.6.36 [December 1, 2018]
   Optimized png_do_expand_palette for ARM processors.
   Improved performance by around 10-22% on a recent ARM Chromebook.
-  (Contributed by Richard Townsend, ARM Holdings)
+    (Contributed by Richard Townsend, ARM Holdings)
   Fixed manipulation of machine-specific optimization options.
-  (Contributed by Vicki Pfau)
+    (Contributed by Vicki Pfau)
   Used memcpy instead of manual pointer arithmetic on Intel SSE2.
-  (Contributed by Samuel Williams)
+    (Contributed by Samuel Williams)
   Fixed build errors with MSVC on ARM64.
-  (Contributed by Zhijie Liang)
+    (Contributed by Zhijie Liang)
   Fixed detection of libm in CMakeLists.
-  (Contributed by Cameron Cawley)
+    (Contributed by Cameron Cawley)
   Fixed incorrect creation of pkg-config file in CMakeLists.
-  (Contributed by Kyle Bentley)
+    (Contributed by Kyle Bentley)
   Fixed the CMake build on Windows MSYS by avoiding symlinks.
   Fixed a build warning on OpenBSD.
-  (Contributed by Theo Buehler)
+    (Contributed by Theo Buehler)
   Fixed various typos in comments.
-  (Contributed by "luz.paz")
+    (Contributed by "luz.paz")
   Raised the minimum required CMake version from 3.0.2 to 3.1.
   Removed yet more of the vestigial support for pre-ANSI C compilers.
   Removed ancient makefiles for ancient systems that have been broken
-  across all previous libpng-1.6.x versions.
+    across all previous libpng-1.6.x versions.
   Removed the Y2K compliance statement and the export control
-  information.
+    information.
   Applied various code style and documentation fixes.
 
-Send comments/corrections/commendations to png-mng-implement at lists.sf.net
-(subscription required; visit
+Version 1.6.37 [April 14, 2019]
+  Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
+  Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
+  Fixed a memory leak in pngtest.c.
+  Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
+    contrib/pngminus; refactor.
+  Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
+    (Contributed by Willem van Schaik)
+  Fixed a typo in the libpng license v2.
+    (Contributed by Miguel Ojeda)
+  Added makefiles for AddressSanitizer-enabled builds.
+  Cleaned up various makefiles.
+
+Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
+Subscription is required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
-to subscribe).
+to subscribe.
index 73044c9..6451fcf 100644 (file)
@@ -26,7 +26,7 @@ enable_testing()
 
 set(PNGLIB_MAJOR 1)
 set(PNGLIB_MINOR 6)
-set(PNGLIB_RELEASE 36)
+set(PNGLIB_RELEASE 37)
 set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
 set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
 
@@ -838,7 +838,7 @@ endif()
 # SET UP LINKS
 if(PNG_SHARED)
   set_target_properties(png PROPERTIES
-#   VERSION 16.${PNGLIB_RELEASE}.1.6.36
+#   VERSION 16.${PNGLIB_RELEASE}.1.6.37
     VERSION 16.${PNGLIB_RELEASE}.0
     SOVERSION 16
     CLEAN_DIRECT_OUTPUT 1)
diff --git a/LICENSE b/LICENSE
index 62ab8e4..e0c5b53 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
 PNG Reference Library License version 2
 ---------------------------------------
 
- * Copyright (c) 1995-2018 The PNG Reference Library Authors.
- * Copyright (c) 2018 Cosmin Truta.
+ * Copyright (c) 1995-2019 The PNG Reference Library Authors.
+ * Copyright (c) 2018-2019 Cosmin Truta.
  * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
  * Copyright (c) 1996-1997 Andreas Dilger.
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -13,7 +13,7 @@ PNG Reference Library License version 2
 The software is supplied "as is", without warranty of any kind,
 express or implied, including, without limitation, the warranties
 of merchantability, fitness for a particular purpose, title, and
-non-infringement.  In no even shall the Copyright owners, or
+non-infringement.  In no event shall the Copyright owners, or
 anyone distributing the software, be liable for any damages or
 other liability, whether in contract, tort or otherwise, arising
 from, out of, or in connection with the software, or the use or
@@ -39,7 +39,7 @@ subject to the following restrictions:
 PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
 -----------------------------------------------------------------------
 
-libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
+libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
 Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
 derived from libpng-1.0.6, and are distributed according to the same
 disclaimer and license as libpng-1.0.6 with the following individuals
diff --git a/README b/README
index e41e0f5..cfc1f0e 100644 (file)
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
-README for libpng version 1.6.36 - December 1, 2018
-===================================================
+README for libpng version 1.6.37 - April 14, 2019
+=================================================
 
 See the note about version numbers near the top of png.h.
 See INSTALL for instructions on how to install libpng.
index fa02d6a..b4d1fd2 100644 (file)
@@ -1,7 +1,7 @@
 
 /* palette_neon_intrinsics.c - NEON optimised palette expansion functions
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
  * Written by Richard Townsend <Richard.Townsend@arm.com>, February 2017.
  *
@@ -20,9 +20,9 @@
 #  include <arm_neon.h>
 #endif
 
-/* Build an RGBA palette from the RGB and separate alpha palettes. */
+/* Build an RGBA8 palette from the separate RGB and alpha palettes. */
 void
-png_riffle_palette_rgba(png_structrp png_ptr, png_row_infop row_info)
+png_riffle_palette_neon(png_structrp png_ptr)
 {
    png_const_colorp palette = png_ptr->palette;
    png_bytep riffled_palette = png_ptr->riffled_palette;
@@ -30,6 +30,8 @@ png_riffle_palette_rgba(png_structrp png_ptr, png_row_infop row_info)
    int num_trans = png_ptr->num_trans;
    int i;
 
+   png_debug(1, "in png_riffle_palette_neon");
+
    /* Initially black, opaque. */
    uint8x16x4_t w = {{
       vdupq_n_u8(0x00),
@@ -38,16 +40,10 @@ png_riffle_palette_rgba(png_structrp png_ptr, png_row_infop row_info)
       vdupq_n_u8(0xff),
    }};
 
-   if (row_info->bit_depth != 8)
-   {
-      png_error(png_ptr, "bit_depth must be 8 for png_riffle_palette_rgba");
-      return;
-   }
-
-   /* First, riffle the RGB colours into a RGBA palette, the A value is
-    * set to opaque for now.
+   /* First, riffle the RGB colours into an RGBA8 palette.
+    * The alpha component is set to opaque for now.
     */
-   for (i = 0; i < (1 << row_info->bit_depth); i += 16)
+   for (i = 0; i < 256; i += 16)
    {
       uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i));
       w.val[0] = v.val[0];
@@ -61,9 +57,9 @@ png_riffle_palette_rgba(png_structrp png_ptr, png_row_infop row_info)
       riffled_palette[(i << 2) + 3] = trans_alpha[i];
 }
 
-/* Expands a palettized row into RGBA. */
+/* Expands a palettized row into RGBA8. */
 int
-png_do_expand_palette_neon_rgba(png_structrp png_ptr, png_row_infop row_info,
+png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
     png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
 {
    png_uint_32 row_width = row_info->width;
@@ -72,6 +68,8 @@ png_do_expand_palette_neon_rgba(png_structrp png_ptr, png_row_infop row_info,
    const png_int_32 pixels_per_chunk = 4;
    int i;
 
+   png_debug(1, "in png_do_expand_palette_rgba8_neon");
+
    if (row_width < pixels_per_chunk)
       return 0;
 
@@ -103,9 +101,9 @@ png_do_expand_palette_neon_rgba(png_structrp png_ptr, png_row_infop row_info,
    return i;
 }
 
-/* Expands a palettized row into RGB format. */
+/* Expands a palettized row into RGB8. */
 int
-png_do_expand_palette_neon_rgb(png_structrp png_ptr, png_row_infop row_info,
+png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
     png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
 {
    png_uint_32 row_width = row_info->width;
@@ -113,6 +111,8 @@ png_do_expand_palette_neon_rgb(png_structrp png_ptr, png_row_infop row_info,
    const png_uint_32 pixels_per_chunk = 8;
    int i;
 
+   png_debug(1, "in png_do_expand_palette_rgb8_neon");
+
    if (row_width <= pixels_per_chunk)
       return 0;
 
index 4c8a35e..1b2c463 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libpng 1.6.36.
+# Generated by GNU Autoconf 2.69 for libpng 1.6.37.
 #
 # Report bugs to <png-mng-implement@lists.sourceforge.net>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='libpng'
 PACKAGE_TARNAME='libpng'
-PACKAGE_VERSION='1.6.36'
-PACKAGE_STRING='libpng 1.6.36'
+PACKAGE_VERSION='1.6.37'
+PACKAGE_STRING='libpng 1.6.37'
 PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net'
 PACKAGE_URL=''
 
@@ -1372,7 +1372,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libpng 1.6.36 to adapt to many kinds of systems.
+\`configure' configures libpng 1.6.37 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1442,7 +1442,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libpng 1.6.36:";;
+     short | recursive ) echo "Configuration of libpng 1.6.37:";;
    esac
   cat <<\_ACEOF
 
@@ -1622,7 +1622,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libpng configure 1.6.36
+libpng configure 1.6.37
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1954,7 +1954,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libpng $as_me 1.6.36, which was
+It was created by libpng $as_me 1.6.37, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2825,7 +2825,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='libpng'
- VERSION='1.6.36'
+ VERSION='1.6.37'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2946,10 +2946,10 @@ fi
 
 
 
-PNGLIB_VERSION=1.6.36
+PNGLIB_VERSION=1.6.37
 PNGLIB_MAJOR=1
 PNGLIB_MINOR=6
-PNGLIB_RELEASE=36
+PNGLIB_RELEASE=37
 
 
 
@@ -14354,7 +14354,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libpng $as_me 1.6.36, which was
+This file was extended by libpng $as_me 1.6.37, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14420,7 +14420,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libpng config.status 1.6.36
+libpng config.status 1.6.37
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
index 1ed63ea..52dba94 100644 (file)
@@ -25,7 +25,7 @@ AC_PREREQ([2.68])
 
 dnl Version number stuff here:
 
-AC_INIT([libpng],[1.6.36],[png-mng-implement@lists.sourceforge.net])
+AC_INIT([libpng],[1.6.37],[png-mng-implement@lists.sourceforge.net])
 AC_CONFIG_MACRO_DIR([scripts])
 
 # libpng does not follow GNU file name conventions (hence 'foreign')
@@ -46,10 +46,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
 dnl AM_PREREQ([1.11.2])
 dnl stop configure from automagically running automake
 
-PNGLIB_VERSION=1.6.36
+PNGLIB_VERSION=1.6.37
 PNGLIB_MAJOR=1
 PNGLIB_MINOR=6
-PNGLIB_RELEASE=36
+PNGLIB_RELEASE=37
 
 dnl End of version number stuff
 
diff --git a/contrib/pngminus/CHANGES.txt b/contrib/pngminus/CHANGES.txt
new file mode 100644 (file)
index 0000000..4e64e5e
--- /dev/null
@@ -0,0 +1,13 @@
+
+pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
+copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
+
+version 1.0 - 1999.10.15 - First version.
+        1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
+        1.2 - 2017.04.22 - Add buffer-size check
+        1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
+                           (Glenn Randers-Pehrson)
+        1.4 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
+        1.5 - 2018.08.05 - Fix buffer overflow in tokenizer (Cosmin Truta)
+        1.6 - 2018.08.05 - Improve portability and fix style (Cosmin Truta)
+        1.7 - 2019.01.22 - Change license to MIT (Willem van Schaik)
diff --git a/contrib/pngminus/CMakeLists.txt b/contrib/pngminus/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1f815a5
--- /dev/null
@@ -0,0 +1,24 @@
+cmake_minimum_required(VERSION 3.1)
+cmake_policy(VERSION 3.1)
+
+project(PNGMINUS C)
+
+option(PNGMINUS_USE_STATIC_LIBRARIES "Use the static library builds" ON)
+
+# libpng
+add_subdirectory(../.. libpng)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/libpng)
+if(PNGMINUS_USE_STATIC_LIBRARIES)
+  set(PNGMINUS_PNG_LIBRARY png_static)
+else()
+  set(PNGMINUS_PNG_LIBRARY png)
+endif()
+
+# png2pnm
+add_executable(png2pnm png2pnm.c)
+target_link_libraries(png2pnm ${PNGMINUS_PNG_LIBRARY})
+
+# pnm2png
+add_executable(pnm2png pnm2png.c)
+target_link_libraries(pnm2png ${PNGMINUS_PNG_LIBRARY})
diff --git a/contrib/pngminus/LICENSE.txt b/contrib/pngminus/LICENSE.txt
new file mode 100644 (file)
index 0000000..00878a9
--- /dev/null
@@ -0,0 +1,22 @@
+
+pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
+
+copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The software is provided "as is", without warranty of any kind, express or
+implied, including but not limited to the warranties of merchantability,
+fitness for a particular purpose and noninfringement. In no event shall the
+authors or copyight holders be liable for any claim, damages or other
+liability, whether in an action of contract, tort or otherwise, arising from,
+out of or in connection with the software or the use or other dealings in the
+software.
diff --git a/contrib/pngminus/Makefile b/contrib/pngminus/Makefile
new file mode 100644 (file)
index 0000000..4bba079
--- /dev/null
@@ -0,0 +1,62 @@
+# Makefile for PngMinus (png2pnm and pnm2png)
+# Linux / Unix
+
+#CC = cc
+CC = gcc
+LD = $(CC)
+
+RM = rm -f
+
+PNGINC = -I../..
+PNGLIB_SHARED = -L../.. -lpng
+PNGLIB_STATIC = ../../libpng.a
+
+# Uncomment the following if you have a custom zlib build at ../../../zlib
+#ZINC = -I../../../zlib
+#ZLIB_SHARED = -L../../../zlib -lz
+#ZLIB_STATIC = ../../../zlib/libz.a
+
+# Use the system zlib otherwise
+ZLIB_SHARED = -lz
+ZLIB_STATIC = -lz
+
+CPPFLAGS = $(PNGINC) $(ZINC)
+CFLAGS =
+LDFLAGS =
+LIBS_SHARED = $(PNGLIB_SHARED) $(ZLIB_SHARED)
+LIBS_STATIC = $(PNGLIB_STATIC) $(ZLIB_STATIC)
+
+EXEEXT =
+#EXEEXT = .exe
+
+# dependencies
+
+all: png2pnm$(EXEEXT) pnm2png$(EXEEXT) png2pnm-static$(EXEEXT) pnm2png-static$(EXEEXT)
+
+png2pnm.o: png2pnm.c
+       $(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm.c
+
+pnm2png.o: pnm2png.c
+       $(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png.c
+
+png2pnm$(EXEEXT): png2pnm.o
+       $(LD) $(LDFLAGS) -o png2pnm$(EXEEXT) png2pnm.o $(LIBS_SHARED) -lm
+
+pnm2png$(EXEEXT): pnm2png.o
+       $(LD) $(LDFLAGS) -o pnm2png$(EXEEXT) pnm2png.o $(LIBS_SHARED) -lm
+
+png2pnm-static$(EXEEXT): png2pnm.o
+       $(LD) $(LDFLAGS) -o png2pnm-static$(EXEEXT) png2pnm.o $(LIBS_STATIC) -lm
+
+pnm2png-static$(EXEEXT): pnm2png.o
+       $(LD) $(LDFLAGS) -o pnm2png-static$(EXEEXT) pnm2png.o $(LIBS_STATIC) -lm
+
+clean:
+       $(RM) png2pnm.o
+       $(RM) pnm2png.o
+       $(RM) png2pnm$(EXEEXT)
+       $(RM) pnm2png$(EXEEXT)
+       $(RM) png2pnm-static$(EXEEXT)
+       $(RM) pnm2png-static$(EXEEXT)
+
+# End of makefile for png2pnm / pnm2png
similarity index 62%
rename from contrib/pngminus/README
rename to contrib/pngminus/README.txt
index 23614a8..f7f6ecb 100644 (file)
@@ -1,26 +1,16 @@
 PngMinus
 --------
-(copyright Willem van Schaik, 1999)
+(copyright Willem van Schaik, 1999-2019)
 
 
-License
--------
-
-Permission to use, copy, modify, and distribute this software and
-its documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear in
-supporting documentation. This software is provided "as is" without
-express or implied warranty.
-
 
 Some history
 ------------
 Soon after the creation of PNG in 1995, the need was felt for a set of
 pnmtopng / pngtopnm utilities. Independently Alexander Lehmann and I
 (Willem van Schaik) started such a project. Luckily we discovered this
-and merged the two together into pnmtopng.tar.gz, which is available
-from a/o ftp://ftp.simplesystems.org/pub/libpng/png/.
+and merged the two, which later became part of NetPBM, available from
+SourceForge.
 
 These two utilities have many, many options and make use of most of the
 features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes
@@ -35,8 +25,8 @@ makes the whole setup a bit bulky. But that's unavoidable given the many
 features of pnmtopng.
 
 
-What now
---------
+What now (1999)
+---------------
 At this moment libpng is in a very stable state and can do much of the
 work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new
 interface of libpng. Hence, it is time for a rewrite from the ground up
@@ -49,8 +39,8 @@ a small prototype that contains only the basic functionality. It doesn't
 have any of the options to read or write special chunks and it will do
 no gamma correction. But this makes it also a simple program that is
 quite easy to understand and can serve well as a template for other
-software developments. (By now there are of course a couple of programs,
-like Greg Roelofs' rpng/wpng, that can be used just as good.)
+software developments. By now there are of course a couple of programs,
+like Greg Roelofs' rpng/wpng, that can be used just as good.
 
 
 Can and can not
@@ -60,7 +50,8 @@ PngMinus. Because I started this development in good-old Turbo-C, I
 avoided the use the netpbm library, which requires DOS extenders. Again,
 another reason to call it PngMinus (minus netpbm :-). So, part of the
 program are some elementary routines to read / write pgm- and ppm-files.
-It does not read b&w pbm-files.
+It does not handle B&W pbm-files, but instead you could do pgm with bit-
+depth 1.
 
 The downside of this approach is that you can not use them on images
 that require blocks of memory bigger than 64k (the DOS version). For
@@ -96,58 +87,34 @@ To list the options type "png2pnm -h" or "pnm2png -h".
 
 Just like Scandinavian furniture
 --------------------------------
-You have to put it together yourself. I did test the software under
-MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both
-cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK,
-however some older libpng versions have a bug in pngmem.c when using
-Turbo-C 3.0 (see below).
-
-You can build it using one of the two makefiles (make -f makefile.###)
-or use the batch/script files pngminus.bat / pngminus.sh. This assumes
-that you have built the libraries in ../libpng and ../zlib. Using Linux,
-make sure that you have built libpng with makefile.std and not
-makefile.linux (also called .lnx in earlier versions of libpng). The
-latter creates a .so shared-library, while the PngMinus makefile assumes
-a normal .a static library.
+You have to put it together yourself. I developed the software on MS-DOS
+with Turbo-C 3.0 and RedHat Linux 4.2 with gcc. In both cases I used
+libpng-1.0.4 and zlib-1.1.3. By now (2019) it is twenty years later and
+more current versions are OK.
+
+The makefile assumes that the libpng libraries can be found in ../.. and
+libz in ../../../zlib. But you can change this to for example ../libpng
+and ../zlib. The makefile creates two versions of each program, one with
+static library support and the other using shared libraries.
 
 If you create a ../pngsuite directory and then store the basn####.png
 files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can
-test in one go the proper functioning of PngMinus, see png2pnm.bat and
-pnm2png.bat (or the .sh versions).
+test the proper functioning of PngMinus by running pngminus.sh.
 
 
 Warranty
 -------
 Please, remember that this was just a small experiment to learn a few
-things. It will have many unforeseen features <vbg>. Who said bugs? Use
-it when you are in need for something simple or when you want to start
-developing your own stuff.
-
-
-The Turbo bug
--------------
-** pngmem.old
-          hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
-          hptr += 16L;
-** pngmem.c
-          hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
-          hptr = hptr + 16L;
-**
-
-** pngmem.old
-          png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
-          hptr += (png_uint_32)65536L;
-** pngmem.c
-          png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
-          hptr = hptr + 65536L;
-**
+things. It will have many unforeseen features <vbg> ... who said bugs? Use
+it when you are in need for something simple or when you want a starting
+point for developing your own stuff.
 
 
 The end
 -------
 Willem van Schaik
-mailto:willem at schaik.com
+mailto:willem at schaik dot com
 http://www.schaik.com/png/
--------
-Oct 1999
+
+Oct 1999, Jan 2019
 
diff --git a/contrib/pngminus/makefile.std b/contrib/pngminus/makefile.std
deleted file mode 100644 (file)
index 14e25cd..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-# Makefile for PngMinus (png2pnm and pnm2png)
-# Linux / Unix
-
-#CC=cc
-CC=gcc
-LD=$(CC)
-
-RM=rm -f
-
-#PNGPATH = /usr/local
-#PNGINC = -I$(PNGPATH)/include/libpng16
-#PNGLIB = -L$(PNGPATH)/lib -lpng16
-#PNGLIBS = $(PNGPATH)/lib/libpng16.a
-PNGINC = -I../..
-PNGLIB = -L../.. -lpng
-PNGLIBS = ../../libpng.a
-
-#ZPATH = /usr/local
-#ZINC = -I$(ZPATH)/include
-#ZLIB = -L$(ZPATH)/lib -lz
-#ZLIBS = $(ZPATH)/lib/libz.a
-ZINC = -I../../../zlib
-ZLIB = -L../../../zlib -lz
-ZLIBS = ../../../zlib/libz.a
-
-CPPFLAGS=$(PNGINC) $(ZINC)
-CFLAGS=
-LDLIBS=$(PNGLIB) $(ZLIB)
-LDLIBSS=$(PNGLIBS) $(ZLIBS)
-C=.c
-O=.o
-L=.a
-E=
-
-# dependencies
-
-#all: png2pnm$(E) pnm2png$(E)
-all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E)
-
-png2pnm$(O): png2pnm$(C)
-       $(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
-
-png2pnm$(E): png2pnm$(O)
-       $(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
-
-png2pnm-static$(E): png2pnm$(O)
-       $(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
-
-pnm2png$(O): pnm2png$(C)
-       $(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
-
-pnm2png$(E): pnm2png$(O)
-       $(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
-
-pnm2png-static$(E): pnm2png$(O)
-       $(LD) $(LDFLAGS) -o pnm2png-static$(E) pnm2png$(O) $(LDLIBSS) -lm
-
-clean:
-       $(RM) png2pnm$(O)
-       $(RM) pnm2png$(O)
-       $(RM) png2pnm$(E)
-       $(RM) pnm2png$(E)
-       $(RM) png2pnm-static$(E)
-       $(RM) pnm2png-static$(E)
-
-# End of makefile for png2pnm / pnm2png
diff --git a/contrib/pngminus/makefile.tc3 b/contrib/pngminus/makefile.tc3
deleted file mode 100644 (file)
index 6a2f4b9..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-# Makefile for PngMinus (png2pnm and pnm2png)
-# TurboC++ 3.0
-
-CC=tcc -Ic:\tc3\inc
-LD=tcc -Lc:\tc3\lib
-LB=tlib
-RM=del
-CP=copy
-MODEL=l
-CPPFLAGS=-I..\libpng -I..\zlib
-CFLAGS=-O -m$(MODEL)
-LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib
-C=.c
-O=.obj
-L=.lib
-E=.exe
-
-# dependencies
-
-all: png2pnm$(E) pnm2png$(E)
-
-png2pnm$(O): png2pnm$(C)
-        $(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
-
-png2pnm$(E): png2pnm$(O)
-        $(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L)
-
-pnm2png$(O): pnm2png$(C)
-        $(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
-
-pnm2png$(E): pnm2png$(O)
-        $(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L)
-
-clean:
-        $(RM) *$(O)
-        $(RM) *$(E)
-
-# End of makefile for png2pnm / pnm2png
index 1420a78..5fef7ed 100644 (file)
@@ -1,28 +1,14 @@
 /*
  *  png2pnm.c --- conversion from PNG-file to PGM/PPM-file
- *  copyright (C) 1999,2017 by Willem van Schaik <willem at schaik.com>
+ *  copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
  *
- *  version 1.0 - 1999.10.15 - First version.
- *          1.1 - 2017.04.22 - Add buffer-size check (Glenn Randers-Pehrson)
- *          1.2 - 2017.08.24 - Fix potential overflow in buffer-size check
- *                             (Glenn Randers-Pehrson)
- *          1.3 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
- *
- *  Permission to use, copy, modify, and distribute this software and
- *  its documentation for any purpose and without fee is hereby granted,
- *  provided that the above copyright notice appear in all copies and
- *  that both that copyright notice and this permission notice appear in
- *  supporting documentation. This software is provided "as is" without
- *  express or implied warranty.
+ *  This software is released under the MIT license. For conditions of
+ *  distribution and use, see the LICENSE file part of this package.
  */
 
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef __TURBOC__
-#include <mem.h>
 #include <fcntl.h>
-#endif
-#include <zlib.h>
 
 #ifndef BOOL
 #define BOOL unsigned char
 #define FALSE (BOOL) 0
 #endif
 
-#ifdef __TURBOC__
-#define STDIN  0
-#define STDOUT 1
-#define STDERR 2
-#endif
-
-/* to make png2pnm verbose so we can find problems (needs to be before png.h) */
+/* make png2pnm verbose so we can find problems (needs to be before png.h) */
 #ifndef PNG_DEBUG
 #define PNG_DEBUG 0
 #endif
 
-
 #include "png.h"
 
-/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
-#ifndef png_jmpbuf
-#  define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
-#endif
-
-#ifndef PNGMINUS_UNUSED
-/* Unused formal parameter warnings are silenced using the following macro
- * which is expected to have no bad effects on performance (optimizing
- * compilers will probably remove it entirely).
- */
-#  define PNGMINUS_UNUSED(param) (void)param
-#endif
-
 /* function prototypes */
 
-int  main (int argc, char *argv[]);
+int main (int argc, char *argv[]);
 void usage ();
-BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw,
-   BOOL alpha);
+BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
+              BOOL raw, BOOL alpha);
 
 /*
  *  main
  */
 
-int main(int argc, char *argv[])
+int main (int argc, char *argv[])
 {
   FILE *fp_rd = stdin;
   FILE *fp_wr = stdout;
@@ -99,21 +65,21 @@ int main(int argc, char *argv[])
           if ((fp_al = fopen (argv[argi], "wb")) == NULL)
           {
             fprintf (stderr, "PNM2PNG\n");
-            fprintf (stderr, "Error:  can not create alpha-channel file %s\n",
-               argv[argi]);
+            fprintf (stderr, "Error:  cannot create alpha-channel file %s\n",
+                     argv[argi]);
             exit (1);
           }
           break;
         case 'h':
         case '?':
-          usage();
-          exit(0);
+          usage ();
+          exit (0);
           break;
         default:
           fprintf (stderr, "PNG2PNM\n");
           fprintf (stderr, "Error:  unknown option %s\n", argv[argi]);
-          usage();
-          exit(1);
+          usage ();
+          exit (1);
           break;
       } /* end switch */
     }
@@ -121,9 +87,9 @@ int main(int argc, char *argv[])
     {
       if ((fp_rd = fopen (argv[argi], "rb")) == NULL)
       {
-             fprintf (stderr, "PNG2PNM\n");
-            fprintf (stderr, "Error:  file %s does not exist\n", argv[argi]);
-            exit (1);
+        fprintf (stderr, "PNG2PNM\n");
+        fprintf (stderr, "Error:  file %s does not exist\n", argv[argi]);
+        exit (1);
       }
     }
     else if (fp_wr == stdout)
@@ -131,7 +97,7 @@ int main(int argc, char *argv[])
       if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
       {
         fprintf (stderr, "PNG2PNM\n");
-        fprintf (stderr, "Error:  can not create file %s\n", argv[argi]);
+        fprintf (stderr, "Error:  cannot create file %s\n", argv[argi]);
         exit (1);
       }
     }
@@ -139,21 +105,17 @@ int main(int argc, char *argv[])
     {
       fprintf (stderr, "PNG2PNM\n");
       fprintf (stderr, "Error:  too many parameters\n");
-      usage();
-      exit(1);
+      usage ();
+      exit (1);
     }
   } /* end for */
 
-#ifdef __TURBOC__
+#if defined(O_BINARY) && (O_BINARY != 0)
   /* set stdin/stdout if required to binary */
   if (fp_rd == stdin)
-  {
-    setmode (STDIN, O_BINARY);
-  }
+    setmode (fileno (stdin), O_BINARY);
   if ((raw) && (fp_wr == stdout))
-  {
-    setmode (STDOUT, O_BINARY);
-  }
+    setmode (fileno (stdout), O_BINARY);
 #endif
 
   /* call the conversion program itself */
@@ -161,7 +123,7 @@ int main(int argc, char *argv[])
   {
     fprintf (stderr, "PNG2PNM\n");
     fprintf (stderr, "Error:  unsuccessful conversion of PNG-image\n");
-    exit(1);
+    exit (1);
   }
 
   /* close input file */
@@ -179,23 +141,18 @@ int main(int argc, char *argv[])
  *  usage
  */
 
-void usage()
+void usage ()
 {
   fprintf (stderr, "PNG2PNM\n");
   fprintf (stderr, "   by Willem van Schaik, 1999\n");
-#ifdef __TURBOC__
-  fprintf (stderr, "   for Turbo-C and Borland-C compilers\n");
-#else
-  fprintf (stderr, "   for Linux (and Unix) compilers\n");
-#endif
   fprintf (stderr, "Usage:  png2pnm [options] <file>.png [<file>.pnm]\n");
   fprintf (stderr, "   or:  ... | png2pnm [options]\n");
   fprintf (stderr, "Options:\n");
   fprintf (stderr,
-     "   -r[aw]   write pnm-file in binary format (P4/P5/P6) (default)\n");
+      "   -r[aw]   write pnm-file in binary format (P4/P5/P6) (default)\n");
   fprintf (stderr, "   -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
   fprintf (stderr,
-     "   -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
+      "   -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
   fprintf (stderr, "   -h | -?  print this help-information\n");
 }
 
@@ -204,10 +161,10 @@ void usage()
  */
 
 BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
-    volatile BOOL raw, BOOL alpha)
+              BOOL raw, BOOL alpha)
 {
   png_struct    *png_ptr = NULL;
-  png_info        *info_ptr = NULL;
+  png_info      *info_ptr = NULL;
   png_byte      buf[8];
   png_byte      *png_pixels = NULL;
   png_byte      **row_pointers = NULL;
@@ -231,24 +188,24 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
     return FALSE;
 
   ret = png_sig_cmp (buf, 0, 8);
-  if (ret)
+  if (ret != 0)
     return FALSE;
 
   /* create png and info structures */
 
   png_ptr = png_create_read_struct (png_get_libpng_ver(NULL),
-    NULL, NULL, NULL);
+                                    NULL, NULL, NULL);
   if (!png_ptr)
-    return FALSE;   /* out of memory */
+    return FALSE; /* out of memory */
 
   info_ptr = png_create_info_struct (png_ptr);
   if (!info_ptr)
   {
     png_destroy_read_struct (&png_ptr, NULL, NULL);
-    return FALSE;   /* out of memory */
+    return FALSE; /* out of memory */
   }
 
-  if (setjmp (png_jmpbuf(png_ptr)))
+  if (setjmp (png_jmpbuf (png_ptr)))
   {
     png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
     return FALSE;
@@ -256,15 +213,14 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
 
   /* set up the input control for C streams */
   png_init_io (png_ptr, png_file);
-  png_set_sig_bytes (png_ptr, 8);  /* we already read the 8 signature bytes */
+  png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */
 
   /* read the file information */
   png_read_info (png_ptr, info_ptr);
 
   /* get size and bit-depth of the PNG-image */
-  png_get_IHDR (png_ptr, info_ptr,
-    &width, &height, &bit_depth, &color_type,
-    NULL, NULL, NULL);
+  png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
+                NULL, NULL, NULL);
 
   /* set-up the transformations */
 
@@ -284,7 +240,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
     png_set_strip_16 (png_ptr);
   /* transform grayscale images into full-color */
   if (color_type == PNG_COLOR_TYPE_GRAY ||
-    color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+      color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
     png_set_gray_to_rgb (png_ptr);
   /* only if file has a file gamma, we do a correction */
   if (png_get_gAMA (png_ptr, info_ptr, &file_gamma))
@@ -298,14 +254,14 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
 
   /* get the new color-type and bit-depth (after expansion/stripping) */
   png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
-    NULL, NULL, NULL);
+                NULL, NULL, NULL);
 
   /* check for 16-bit files */
   if (bit_depth == 16)
   {
     raw = FALSE;
-#ifdef __TURBOC__
-    pnm_file->flags &= ~((unsigned) _F_BIN);
+#if defined(O_BINARY) && (O_BINARY != 0)
+    setmode (fileno (pnm_file), O_BINARY);
 #endif
   }
 
@@ -333,25 +289,25 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
   /* row_bytes is the width x number of channels x (bit-depth / 8) */
   row_bytes = png_get_rowbytes (png_ptr, info_ptr);
 
-  if ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes))
+  if ((row_bytes == 0) ||
+      ((size_t) height > (size_t) (-1) / (size_t) row_bytes))
   {
-    /* too big */ 
+    /* too big */
     png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
     return FALSE;
   }
   if ((png_pixels = (png_byte *)
-     malloc ((size_t)row_bytes * (size_t)height * sizeof (png_byte))) == NULL)
+       malloc ((size_t) row_bytes * (size_t) height)) == NULL)
   {
     png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
     return FALSE;
   }
 
   if ((row_pointers = (png_byte **)
-     malloc ((size_t)height * sizeof (png_bytep))) == NULL)
+       malloc ((size_t) height * sizeof (png_byte *))) == NULL)
   {
     png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
     free (png_pixels);
-    png_pixels = NULL;
     return FALSE;
   }
 
@@ -366,7 +322,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
   png_read_end (png_ptr, info_ptr);
 
   /* clean up after the read, and free any memory allocated - REQUIRED */
-  png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL);
+  png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
 
   /* write header of PNM file */
 
@@ -406,14 +362,21 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
       for (i = 0; i < (channels - alpha_present); i++)
       {
         if (raw)
-          fputc ((int) *pix_ptr++ , pnm_file);
+        {
+          fputc ((int) *pix_ptr++, pnm_file);
+        }
         else
-          if (bit_depth == 16){
+        {
+          if (bit_depth == 16)
+          {
             dep_16 = (long) *pix_ptr++;
             fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++));
           }
           else
+          {
             fprintf (pnm_file, "%ld ", (long) *pix_ptr++);
+          }
+        }
       }
       if (alpha_present)
       {
@@ -426,17 +389,23 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
         else /* output alpha-channel as pgm file */
         {
           if (raw)
-            fputc ((int) *pix_ptr++ , alpha_file);
+          {
+            fputc ((int) *pix_ptr++, alpha_file);
+          }
           else
+          {
             if (bit_depth == 16)
             {
               dep_16 = (long) *pix_ptr++;
               fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
             }
             else
+            {
               fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
+            }
+          }
         }
-      } /* if alpha_present */
+      } /* end if alpha_present */
 
       if (!raw)
         if (col % 4 == 3)
@@ -448,13 +417,11 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
         fprintf (pnm_file, "\n");
   } /* end for row */
 
-  if (row_pointers != (unsigned char**) NULL)
+  if (row_pointers != NULL)
     free (row_pointers);
-  if (png_pixels != (unsigned char*) NULL)
+  if (png_pixels != NULL)
     free (png_pixels);
 
-  PNGMINUS_UNUSED(raw); /* to quiet a Coverity defect */
   return TRUE;
 
 } /* end of source */
-
index 911bb8d..fa60e7d 100755 (executable)
@@ -1,4 +1,4 @@
-make -f makefile.tc3
+make
 call png2pnm.bat
 call pnm2png.bat
 
index 2a0a9d8..cc9b4a5 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-make -f makefile.std
+make
 sh png2pnm.sh
 sh pnm2png.sh
 
index 0d2caef..a2c2551 100644 (file)
@@ -1,29 +1,14 @@
 /*
  *  pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
- *  copyright (C) 1999,2015,2017 by Willem van Schaik <willem at schaik.com>
+ *  copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
  *
- *  version 1.0 - 1999.10.15 - First version.
- *  version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
- *  version 1.2 - 2017.04.22 - Add buffer-size check
- *          1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
- *                             (Glenn Randers-Pehrson)
- *          1.4 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
- *
- *  Permission to use, copy, modify, and distribute this software and
- *  its documentation for any purpose and without fee is hereby granted,
- *  provided that the above copyright notice appear in all copies and
- *  that both that copyright notice and this permission notice appear in
- *  supporting documentation. This software is provided "as is" without
- *  express or implied warranty.
+ *  This software is released under the MIT license. For conditions of
+ *  distribution and use, see the LICENSE file part of this package.
  */
 
 #include <stdio.h>
 #include <stdlib.h>
-#ifdef __TURBOC__
-#include <mem.h>
 #include <fcntl.h>
-#endif
-#include <zlib.h>
 
 #ifndef BOOL
 #define BOOL unsigned char
 #define FALSE (BOOL) 0
 #endif
 
-#define STDIN  0
-#define STDOUT 1
-#define STDERR 2
-
-/* to make pnm2png verbose so we can find problems (needs to be before png.h) */
+/* make pnm2png verbose so we can find problems (needs to be before png.h) */
 #ifndef PNG_DEBUG
 #define PNG_DEBUG 0
 #endif
 
 #include "png.h"
 
-/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
-#ifndef png_jmpbuf
-#  define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
-#endif
-
-#ifndef PNGMINUS_UNUSED
-/* Unused formal parameter warnings are silenced using the following macro
- * which is expected to have no bad effects on performance (optimizing
- * compilers will probably remove it entirely).
- */
-#  define PNGMINUS_UNUSED(param) (void)param
-#endif
-
-
 /* function prototypes */
 
-int  main (int argc, char *argv[]);
+int main (int argc, char *argv[]);
 void usage ();
-BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
-    BOOL alpha);
-void get_token(FILE *pnm_file, char *token);
+BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
+              BOOL interlace, BOOL alpha);
+void get_token (FILE *pnm_file, char *token_buf, size_t token_buf_size);
 png_uint_32 get_data (FILE *pnm_file, int depth);
 png_uint_32 get_value (FILE *pnm_file, int depth);
 
@@ -74,7 +41,7 @@ png_uint_32 get_value (FILE *pnm_file, int depth);
  *  main
  */
 
-int main(int argc, char *argv[])
+int main (int argc, char *argv[])
 {
   FILE *fp_rd = stdin;
   FILE *fp_al = NULL;
@@ -99,20 +66,20 @@ int main(int argc, char *argv[])
           {
             fprintf (stderr, "PNM2PNG\n");
             fprintf (stderr, "Error:  alpha-channel file %s does not exist\n",
-               argv[argi]);
+                     argv[argi]);
             exit (1);
           }
           break;
         case 'h':
         case '?':
-          usage();
-          exit(0);
+          usage ();
+          exit (0);
           break;
         default:
           fprintf (stderr, "PNM2PNG\n");
           fprintf (stderr, "Error:  unknown option %s\n", argv[argi]);
-          usage();
-          exit(1);
+          usage ();
+          exit (1);
           break;
       } /* end switch */
     }
@@ -130,7 +97,7 @@ int main(int argc, char *argv[])
       if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
       {
         fprintf (stderr, "PNM2PNG\n");
-        fprintf (stderr, "Error:  can not create PNG-file %s\n", argv[argi]);
+        fprintf (stderr, "Error:  cannot create PNG-file %s\n", argv[argi]);
         exit (1);
       }
     }
@@ -138,21 +105,19 @@ int main(int argc, char *argv[])
     {
       fprintf (stderr, "PNM2PNG\n");
       fprintf (stderr, "Error:  too many parameters\n");
-      usage();
+      usage ();
       exit (1);
     }
   } /* end for */
 
-#ifdef __TURBOC__
-  /* set stdin/stdout to binary, we're reading the PNM always! in binary format */
+#if defined(O_BINARY) && (O_BINARY != 0)
+  /* set stdin/stdout to binary,
+   * we're reading the PNM always! in binary format
+   */
   if (fp_rd == stdin)
-  {
-    setmode (STDIN, O_BINARY);
-  }
+    setmode (fileno (stdin), O_BINARY);
   if (fp_wr == stdout)
-  {
-    setmode (STDOUT, O_BINARY);
-  }
+    setmode (fileno (stdout), O_BINARY);
 #endif
 
   /* call the conversion program itself */
@@ -178,15 +143,10 @@ int main(int argc, char *argv[])
  *  usage
  */
 
-void usage()
+void usage ()
 {
   fprintf (stderr, "PNM2PNG\n");
   fprintf (stderr, "   by Willem van Schaik, 1999\n");
-#ifdef __TURBOC__
-  fprintf (stderr, "   for Turbo-C and Borland-C compilers\n");
-#else
-  fprintf (stderr, "   for Linux (and Unix) compilers\n");
-#endif
   fprintf (stderr, "Usage:  pnm2png [options] <file>.<pnm> [<file>.png]\n");
   fprintf (stderr, "   or:  ... | pnm2png [options]\n");
   fprintf (stderr, "Options:\n");
@@ -200,31 +160,31 @@ void usage()
  *  pnm2png
  */
 
-BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
-     BOOL alpha)
+BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
+              BOOL interlace, BOOL alpha)
 {
   png_struct    *png_ptr = NULL;
   png_info      *info_ptr = NULL;
   png_byte      *png_pixels = NULL;
   png_byte      **row_pointers = NULL;
   png_byte      *pix_ptr = NULL;
-  volatile png_uint_32   row_bytes;
+  volatile png_uint_32 row_bytes;
 
   char          type_token[16];
   char          width_token[16];
   char          height_token[16];
   char          maxval_token[16];
-  volatile int    color_type=1;
-  unsigned long   ul_width=0, ul_alpha_width=0;
-  unsigned long   ul_height=0, ul_alpha_height=0;
-  unsigned long   ul_maxval=0;
-  volatile png_uint_32   width=0, height=0;
-  volatile png_uint_32   alpha_width=0, alpha_height=0;
+  volatile int  color_type = 1;
+  unsigned long ul_width = 0, ul_alpha_width = 0;
+  unsigned long ul_height = 0, ul_alpha_height = 0;
+  unsigned long ul_maxval = 0;
+  volatile png_uint_32 width = 0, height = 0;
+  volatile png_uint_32 alpha_width = 0, alpha_height = 0;
   png_uint_32   maxval;
-  volatile int           bit_depth = 0;
-  int           channels=0;
+  volatile int  bit_depth = 0;
+  int           channels = 0;
   int           alpha_depth = 0;
-  int           alpha_present=0;
+  int           alpha_present = 0;
   int           row, col;
   BOOL          raw, alpha_raw = FALSE;
 #if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
@@ -235,7 +195,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
 
   /* read header of PNM file */
 
-  get_token(pnm_file, type_token);
+  get_token (pnm_file, type_token, sizeof (type_token));
   if (type_token[0] != 'P')
   {
     return FALSE;
@@ -245,30 +205,31 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
 #if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
     raw = (type_token[1] == '4');
     color_type = PNG_COLOR_TYPE_GRAY;
-    get_token(pnm_file, width_token);
+    get_token (pnm_file, width_token, sizeof (width_token));
     sscanf (width_token, "%lu", &ul_width);
     width = (png_uint_32) ul_width;
-    get_token(pnm_file, height_token);
+    get_token (pnm_file, height_token, sizeof (height_token));
     sscanf (height_token, "%lu", &ul_height);
     height = (png_uint_32) ul_height;
     bit_depth = 1;
     packed_bitmap = TRUE;
 #else
-    fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n");
+    fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and\n");
     fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
+    return FALSE;
 #endif
   }
   else if ((type_token[1] == '2') || (type_token[1] == '5'))
   {
     raw = (type_token[1] == '5');
     color_type = PNG_COLOR_TYPE_GRAY;
-    get_token(pnm_file, width_token);
+    get_token (pnm_file, width_token, sizeof (width_token));
     sscanf (width_token, "%lu", &ul_width);
     width = (png_uint_32) ul_width;
-    get_token(pnm_file, height_token);
+    get_token (pnm_file, height_token, sizeof (height_token));
     sscanf (height_token, "%lu", &ul_height);
     height = (png_uint_32) ul_height;
-    get_token(pnm_file, maxval_token);
+    get_token (pnm_file, maxval_token, sizeof (maxval_token));
     sscanf (maxval_token, "%lu", &ul_maxval);
     maxval = (png_uint_32) ul_maxval;
 
@@ -280,20 +241,22 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
       bit_depth = 4;
     else if (maxval <= 255)
       bit_depth = 8;
-    else /* if (maxval <= 65535) */
+    else if (maxval <= 65535U)
       bit_depth = 16;
+    else /* maxval > 65535U */
+      return FALSE;
   }
   else if ((type_token[1] == '3') || (type_token[1] == '6'))
   {
     raw = (type_token[1] == '6');
     color_type = PNG_COLOR_TYPE_RGB;
-    get_token(pnm_file, width_token);
+    get_token (pnm_file, width_token, sizeof (width_token));
     sscanf (width_token, "%lu", &ul_width);
     width = (png_uint_32) ul_width;
-    get_token(pnm_file, height_token);
+    get_token (pnm_file, height_token, sizeof (height_token));
     sscanf (height_token, "%lu", &ul_height);
     height = (png_uint_32) ul_height;
-    get_token(pnm_file, maxval_token);
+    get_token (pnm_file, maxval_token, sizeof (maxval_token));
     sscanf (maxval_token, "%lu", &ul_maxval);
     maxval = (png_uint_32) ul_maxval;
     if (maxval <= 1)
@@ -304,8 +267,10 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
       bit_depth = 4;
     else if (maxval <= 255)
       bit_depth = 8;
-    else /* if (maxval <= 65535) */
+    else if (maxval <= 65535U)
       bit_depth = 16;
+    else /* maxval > 65535U */
+      return FALSE;
   }
   else
   {
@@ -321,7 +286,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
     if (color_type == PNG_COLOR_TYPE_RGB)
       color_type = PNG_COLOR_TYPE_RGB_ALPHA;
 
-    get_token(alpha_file, type_token);
+    get_token (alpha_file, type_token, sizeof (type_token));
     if (type_token[0] != 'P')
     {
       return FALSE;
@@ -329,17 +294,17 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
     else if ((type_token[1] == '2') || (type_token[1] == '5'))
     {
       alpha_raw = (type_token[1] == '5');
-      get_token(alpha_file, width_token);
+      get_token (alpha_file, width_token, sizeof (width_token));
       sscanf (width_token, "%lu", &ul_alpha_width);
-      alpha_width=(png_uint_32) ul_alpha_width;
+      alpha_width = (png_uint_32) ul_alpha_width;
       if (alpha_width != width)
         return FALSE;
-      get_token(alpha_file, height_token);
+      get_token (alpha_file, height_token, sizeof (height_token));
       sscanf (height_token, "%lu", &ul_alpha_height);
       alpha_height = (png_uint_32) ul_alpha_height;
       if (alpha_height != height)
         return FALSE;
-      get_token(alpha_file, maxval_token);
+      get_token (alpha_file, maxval_token, sizeof (maxval_token));
       sscanf (maxval_token, "%lu", &ul_maxval);
       maxval = (png_uint_32) ul_maxval;
       if (maxval <= 1)
@@ -350,8 +315,10 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
         alpha_depth = 4;
       else if (maxval <= 255)
         alpha_depth = 8;
-      else /* if (maxval <= 65535) */
+      else if (maxval <= 65535U)
         alpha_depth = 16;
+      else /* maxval > 65535U */
+        return FALSE;
       if (alpha_depth != bit_depth)
         return FALSE;
     }
@@ -379,21 +346,29 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
 
 #if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
   if (packed_bitmap)
+  {
     /* row data is as many bytes as can fit width x channels x bit_depth */
     row_bytes = (width * channels * bit_depth + 7) / 8;
+  }
   else
 #endif
-  /* row_bytes is the width x number of channels x (bit-depth / 8) */
+  {
+    /* row_bytes is the width x number of channels x (bit-depth / 8) */
     row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
+  }
 
-  if ((row_bytes == 0 || (size_t)height > ((size_t)(-1))/(size_t)row_bytes))
+  if ((row_bytes == 0) ||
+      ((size_t) height > (size_t) (-1) / (size_t) row_bytes))
   {
-    /* too big */ 
+    /* too big */
     return FALSE;
   }
   if ((png_pixels = (png_byte *)
-     malloc ((size_t)row_bytes * (size_t)height * sizeof (png_byte))) == NULL)
+       malloc ((size_t) row_bytes * (size_t) height)) == NULL)
+  {
+    /* out of memory */
     return FALSE;
+  }
 
   /* read data from PNM file */
   pix_ptr = png_pixels;
@@ -404,9 +379,12 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
     if (packed_bitmap)
     {
       for (i = 0; i < (int) row_bytes; i++)
+      {
         /* png supports this format natively so no conversion is needed */
         *pix_ptr++ = get_data (pnm_file, 8);
-    } else
+      }
+    }
+    else
 #endif
     {
       for (col = 0; col < (int) width; col++)
@@ -414,10 +392,15 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
         for (i = 0; i < (channels - alpha_present); i++)
         {
           if (raw)
+          {
             *pix_ptr++ = get_data (pnm_file, bit_depth);
+          }
           else
+          {
             if (bit_depth <= 8)
+            {
               *pix_ptr++ = get_value (pnm_file, bit_depth);
+            }
             else
             {
               tmp16 = get_value (pnm_file, bit_depth);
@@ -426,41 +409,46 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
               *pix_ptr = (png_byte) (tmp16 & 0xFF);
               pix_ptr++;
             }
+          }
         }
 
         if (alpha) /* read alpha-channel from pgm file */
         {
           if (alpha_raw)
+          {
             *pix_ptr++ = get_data (alpha_file, alpha_depth);
+          }
           else
+          {
             if (alpha_depth <= 8)
+            {
               *pix_ptr++ = get_value (alpha_file, bit_depth);
+            }
             else
             {
               tmp16 = get_value (alpha_file, bit_depth);
               *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
               *pix_ptr++ = (png_byte) (tmp16 & 0xFF);
             }
-        } /* if alpha */
-      } /* if packed_bitmap */
+          }
+        } /* end if alpha */
+      } /* end if packed_bitmap */
     } /* end for col */
   } /* end for row */
 
   /* prepare the standard PNG structures */
-  png_ptr = png_create_write_struct (png_get_libpng_ver(NULL), NULL, NULL,
-      NULL);
+  png_ptr = png_create_write_struct (png_get_libpng_ver(NULL),
+                                     NULL, NULL, NULL);
   if (!png_ptr)
   {
     free (png_pixels);
-    png_pixels = NULL;
     return FALSE;
   }
   info_ptr = png_create_info_struct (png_ptr);
   if (!info_ptr)
   {
-    png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
+    png_destroy_write_struct (&png_ptr, NULL);
     free (png_pixels);
-    png_pixels = NULL;
     return FALSE;
   }
 
@@ -472,12 +460,10 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
   }
 #endif
 
-  /* setjmp() must be called in every function that calls a PNG-reading libpng function */
-  if (setjmp (png_jmpbuf(png_ptr)))
+  if (setjmp (png_jmpbuf (png_ptr)))
   {
     png_destroy_write_struct (&png_ptr, &info_ptr);
     free (png_pixels);
-    png_pixels = NULL;
     return FALSE;
   }
 
@@ -486,21 +472,20 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
 
   /* we're going to write more or less the same PNG as the input file */
   png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type,
-    (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,
-    PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
+                (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,
+                PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
 
   /* write the file header information */
   png_write_info (png_ptr, info_ptr);
 
   /* if needed we will allocate memory for an new array of row-pointers */
-  if (row_pointers == (unsigned char**) NULL)
+  if (row_pointers == NULL)
   {
     if ((row_pointers = (png_byte **)
-        malloc (height * sizeof (png_bytep))) == NULL)
+         malloc (height * sizeof (png_byte *))) == NULL)
     {
       png_destroy_write_struct (&png_ptr, &info_ptr);
       free (png_pixels);
-      png_pixels = NULL;
       return FALSE;
     }
   }
@@ -518,62 +503,60 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
   /* clean up after the write, and free any memory allocated */
   png_destroy_write_struct (&png_ptr, &info_ptr);
 
-  if (row_pointers != (unsigned char**) NULL)
+  if (row_pointers != NULL)
     free (row_pointers);
-  if (png_pixels != (unsigned char*) NULL)
+  if (png_pixels != NULL)
     free (png_pixels);
 
-  PNGMINUS_UNUSED(raw); /* Quiet a Coverity defect */
-
   return TRUE;
 } /* end of pnm2png */
 
 /*
- * get_token() - gets the first string after whitespace
+ * get_token - gets the first string after whitespace
  */
 
-void get_token(FILE *pnm_file, char *token)
+void get_token (FILE *pnm_file, char *token_buf, size_t token_buf_size)
 {
-  int i = 0;
+  size_t i = 0;
   int ret;
 
   /* remove white-space and comment lines */
   do
   {
-    ret = fgetc(pnm_file);
+    ret = fgetc (pnm_file);
     if (ret == '#')
     {
       /* the rest of this line is a comment */
       do
       {
-        ret = fgetc(pnm_file);
+        ret = fgetc (pnm_file);
       }
       while ((ret != '\n') && (ret != '\r') && (ret != EOF));
     }
     if (ret == EOF) break;
-    token[i] = (unsigned char) ret;
+    token_buf[i] = (char) ret;
   }
-  while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
+  while ((ret == '\n') || (ret == '\r') || (ret == ' '));
 
   /* read string */
   do
   {
-    ret = fgetc(pnm_file);
+    ret = fgetc (pnm_file);
     if (ret == EOF) break;
-    i++;
-    token[i] = (unsigned char) ret;
+    if (++i == token_buf_size - 1) break;
+    token_buf[i] = (char) ret;
   }
-  while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
+  while ((ret != '\n') && (ret != '\r') && (ret != ' '));
 
-  token[i] = '\0';
+  token_buf[i] = '\0';
 
   return;
 }
 
 /*
- * get_data() - takes first byte and converts into next pixel value,
- *        taking as much bits as defined by bit-depth and
- *        using the bit-depth to fill up a byte (0Ah -> AAh)
+ *  get_data - takes first byte and converts into next pixel value,
+ *             taking as much bits as defined by bit-depth and
+ *             using the bit-depth to fill up a byte (0Ah -> AAh)
  */
 
 png_uint_32 get_data (FILE *pnm_file, int depth)
@@ -605,14 +588,14 @@ png_uint_32 get_data (FILE *pnm_file, int depth)
 }
 
 /*
- * get_value() - takes first (numeric) string and converts into number,
- *         using the bit-depth to fill up a byte (0Ah -> AAh)
+ *  get_value - takes first (numeric) string and converts into number,
+ *              using the bit-depth to fill up a byte (0Ah -> AAh)
  */
 
 png_uint_32 get_value (FILE *pnm_file, int depth)
 {
   static png_uint_32 mask = 0;
-  png_byte token[16];
+  char token[16];
   unsigned long ul_ret_value;
   png_uint_32 ret_value;
   int i = 0;
@@ -621,8 +604,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
     for (i = 0; i < depth; i++)
       mask = (mask << 1) | 0x01;
 
-  get_token (pnm_file, (char *) token);
-  sscanf ((const char *) token, "%lu", &ul_ret_value);
+  get_token (pnm_file, token, sizeof (token));
+  sscanf (token, "%lu", &ul_ret_value);
   ret_value = (png_uint_32) ul_ret_value;
 
   ret_value &= mask;
@@ -635,4 +618,3 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
 }
 
 /* end of source */
-
index 19cfed2..5dad92f 100644 (file)
@@ -1,6 +1,6 @@
 libpng-manual.txt - A description on how to use and modify libpng
 
- Copyright (c) 2018 Cosmin Truta
+ Copyright (c) 2018-2019 Cosmin Truta
  Copyright (c) 1998-2018 Glenn Randers-Pehrson
 
  This document is released under the libpng license.
@@ -9,11 +9,11 @@ libpng-manual.txt - A description on how to use and modify libpng
 
  Based on:
 
- libpng version 1.6.36 - December 1, 2018
+ libpng version 1.6.36, December 2018, through 1.6.37 - April 2019
  Updated and distributed by Cosmin Truta
- Copyright (c) 2018 Cosmin Truta
+ Copyright (c) 2018-2019 Cosmin Truta
 
- libpng versions 0.97, January 1998, through 1.6.35 - July 15, 2018
+ libpng versions 0.97, January 1998, through 1.6.35 - July 2018
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2018 Glenn Randers-Pehrson
 
index 9757deb..f374235 100644 (file)
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "December 1, 2018"
+.TH LIBPNG 3 "April 14, 2019"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.36
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37
 
 .SH SYNOPSIS
 \fB#include <png.h>\fP
@@ -519,7 +519,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
 .SH LIBPNG.TXT
 libpng-manual.txt - A description on how to use and modify libpng
 
- Copyright (c) 2018 Cosmin Truta
+ Copyright (c) 2018-2019 Cosmin Truta
  Copyright (c) 1998-2018 Glenn Randers-Pehrson
 
  This document is released under the libpng license.
@@ -528,11 +528,11 @@ libpng-manual.txt - A description on how to use and modify libpng
 
  Based on:
 
- libpng version 1.6.36 - December 1, 2018
+ libpng version 1.6.36, December 2018, through 1.6.37 - April 2019
  Updated and distributed by Cosmin Truta
- Copyright (c) 2018 Cosmin Truta
+ Copyright (c) 2018-2019 Cosmin Truta
 
- libpng versions 0.97, January 1998, through 1.6.35 - July 15, 2018
+ libpng versions 0.97, January 1998, through 1.6.35 - July 2018
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2018 Glenn Randers-Pehrson
 
@@ -6045,8 +6045,6 @@ Maintained by Cosmin Truta.
 
 Supported by the PNG development group
 .br
-png-mng-implement at lists.sf.net
-(subscription required; visit
 png-mng-implement at lists.sourceforge.net (subscription required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement
 to subscribe).
index b736d82..6909c70 100644 (file)
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "December 1, 2018"
+.TH LIBPNGPF 3 "April 14, 2019"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.36
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37
 (private functions)
 
 .SH SYNOPSIS
diff --git a/png.5 b/png.5
index 2077d1f..c2da95c 100644 (file)
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "December 1, 2018"
+.TH PNG 5 "April 14, 2019"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 
@@ -60,7 +60,7 @@ Thomas Boutell and others (png-list).
 .LP
 This man page is
 .br
-Copyright (c) 2018 Cosmin Truta.
+Copyright (c) 2018-2019 Cosmin Truta.
 .br
 Copyright (c) 1998-2006 Glenn Randers-Pehrson.
 .br
diff --git a/png.c b/png.c
index 3dce191..757c755 100644 (file)
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
  * Copyright (c) 1996-1997 Andreas Dilger
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -14,7 +14,7 @@
 #include "pngpriv.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_36 Your_png_h_is_not_version_1_6_36;
+typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37;
 
 #ifdef __GNUC__
 /* The version tests may need to be added to, but the problem warning has
@@ -815,8 +815,8 @@ png_get_copyright(png_const_structrp png_ptr)
    return PNG_STRING_COPYRIGHT
 #else
    return PNG_STRING_NEWLINE \
-      "libpng version 1.6.36" PNG_STRING_NEWLINE \
-      "Copyright (c) 2018 Cosmin Truta" PNG_STRING_NEWLINE \
+      "libpng version 1.6.37" PNG_STRING_NEWLINE \
+      "Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \
       "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
       PNG_STRING_NEWLINE \
       "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
@@ -4588,8 +4588,7 @@ png_image_free(png_imagep image)
    if (image != NULL && image->opaque != NULL &&
       image->opaque->error_buf == NULL)
    {
-      /* Ignore errors here: */
-      (void)png_safe_execute(image, png_image_free_function, image);
+      png_image_free_function(image);
       image->opaque = NULL;
    }
 }
diff --git a/png.h b/png.h
index 8e272a0..139eb0d 100644 (file)
--- a/png.h
+++ b/png.h
@@ -1,9 +1,9 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.6.36 - December 1, 2018
+ * libpng version 1.6.37 - April 14, 2019
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
  * Copyright (c) 1996-1997 Andreas Dilger
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -14,8 +14,9 @@
  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *   libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
  *   libpng versions 0.97, January 1998, through 1.6.35, July 2018:
- *     Glenn Randers-Pehrson.
- *   libpng version 1.6.36, December 1, 2018: Cosmin Truta
+ *     Glenn Randers-Pehrson
+ *   libpng versions 1.6.36, December 2018, through 1.6.37, April 2019:
+ *     Cosmin Truta
  *   See also "Contributing Authors", below.
  */
 
@@ -26,8 +27,8 @@
  * PNG Reference Library License version 2
  * ---------------------------------------
  *
- *  * Copyright (c) 1995-2018 The PNG Reference Library Authors.
- *  * Copyright (c) 2018 Cosmin Truta.
+ *  * Copyright (c) 1995-2019 The PNG Reference Library Authors.
+ *  * Copyright (c) 2018-2019 Cosmin Truta.
  *  * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
  *  * Copyright (c) 1996-1997 Andreas Dilger.
  *  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -35,7 +36,7 @@
  * The software is supplied "as is", without warranty of any kind,
  * express or implied, including, without limitation, the warranties
  * of merchantability, fitness for a particular purpose, title, and
- * non-infringement.  In no even shall the Copyright owners, or
+ * non-infringement.  In no event shall the Copyright owners, or
  * anyone distributing the software, be liable for any damages or
  * other liability, whether in contract, tort or otherwise, arising
  * from, out of, or in connection with the software, or the use or
@@ -61,7 +62,7 @@
  * PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
  * -----------------------------------------------------------------------
  *
- * libpng versions 1.0.7, July 1, 2000 through 1.6.35, July 15, 2018 are
+ * libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
  * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
  * derived from libpng-1.0.6, and are distributed according to the same
  * disclaimer and license as libpng-1.0.6 with the following individuals
  *    ...
  *    1.5.30                  15    10530  15.so.15.30[.0]
  *    ...
- *    1.6.36                  16    10636  16.so.16.36[.0]
+ *    1.6.37                  16    10637  16.so.16.37[.0]
  *
  *    Henceforth the source version will match the shared-library major and
  *    minor numbers; the shared-library major version number will be used for
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.36"
-#define PNG_HEADER_VERSION_STRING " libpng version 1.6.36 - December 1, 2018\n"
+#define PNG_LIBPNG_VER_STRING "1.6.37"
+#define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n"
 
 #define PNG_LIBPNG_VER_SONUM   16
 #define PNG_LIBPNG_VER_DLLNUM  16
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   6
-#define PNG_LIBPNG_VER_RELEASE 36
+#define PNG_LIBPNG_VER_RELEASE 37
 
-/* This should match the numeric part of the final component of
- * PNG_LIBPNG_VER_STRING, omitting any leading zero:
+/* This should be zero for a public release, or non-zero for a
+ * development version.  [Deprecated]
  */
-
 #define PNG_LIBPNG_VER_BUILD  0
 
 /* Release Status */
  * From version 1.0.1 it is:
  * XXYYZZ, where XX=major, YY=minor, ZZ=release
  */
-#define PNG_LIBPNG_VER 10636 /* 1.6.36 */
+#define PNG_LIBPNG_VER 10637 /* 1.6.37 */
 
 /* Library configuration: these options cannot be changed after
  * the library has been built.
@@ -428,7 +428,7 @@ extern "C" {
 /* This triggers a compiler error in png.c, if png.c and png.h
  * do not agree upon the version number.
  */
-typedef char* png_libpng_version_1_6_36;
+typedef char* png_libpng_version_1_6_37;
 
 /* Basic control structions.  Read libpng-manual.txt or libpng.3 for more info.
  *
index 5e641b2..927a769 100644 (file)
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,9 +1,9 @@
 
-/* pngconf.h - machine configurable file for libpng
+/* pngconf.h - machine-configurable file for libpng
  *
- * libpng version 1.6.36
+ * libpng version 1.6.37
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
  * Copyright (c) 1996-1997 Andreas Dilger
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
index 973c3ea..583c26f 100644 (file)
--- a/pngpriv.h
+++ b/pngpriv.h
@@ -1,7 +1,7 @@
 
 /* pngpriv.h - private declarations for use inside libpng
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
  * Copyright (c) 1996-1997 Andreas Dilger
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -2119,11 +2119,11 @@ PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
 
 #if PNG_ARM_NEON_IMPLEMENTATION == 1
 PNG_INTERNAL_FUNCTION(void,
-                      png_riffle_palette_rgba,
-                      (png_structrp, png_row_infop),
+                      png_riffle_palette_neon,
+                      (png_structrp),
                       PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(int,
-                      png_do_expand_palette_neon_rgba,
+                      png_do_expand_palette_rgba8_neon,
                       (png_structrp,
                        png_row_infop,
                        png_const_bytep,
@@ -2131,7 +2131,7 @@ PNG_INTERNAL_FUNCTION(int,
                        const png_bytepp),
                       PNG_EMPTY);
 PNG_INTERNAL_FUNCTION(int,
-                      png_do_expand_palette_neon_rgb,
+                      png_do_expand_palette_rgb8_neon,
                       (png_structrp,
                        png_row_infop,
                        png_const_bytep,
index f8e7621..8fa7d9f 100644 (file)
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
  * Copyright (c) 1996-1997 Andreas Dilger
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -994,6 +994,12 @@ png_read_destroy(png_structrp png_ptr)
    png_ptr->chunk_list = NULL;
 #endif
 
+#if defined(PNG_READ_EXPAND_SUPPORTED) && \
+    defined(PNG_ARM_NEON_IMPLEMENTATION)
+   png_free(png_ptr, png_ptr->riffled_palette);
+   png_ptr->riffled_palette = NULL;
+#endif
+
    /* NOTE: the 'setjmp' buffer may still be allocated and the memory and error
     * callbacks are still set at this point.  They are required to complete the
     * destruction of the png_struct itself.
index ccc58ce..9a8fad9 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
  * Copyright (c) 1996-1997 Andreas Dilger
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -1182,20 +1182,20 @@ png_init_palette_transformations(png_structrp png_ptr)
              png_ptr->palette[png_ptr->background.index].blue;
 
 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
-        if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
-        {
-           if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
-           {
-              /* Invert the alpha channel (in tRNS) unless the pixels are
-               * going to be expanded, in which case leave it for later
-               */
-              int i, istop = png_ptr->num_trans;
-
-              for (i=0; i<istop; i++)
-                 png_ptr->trans_alpha[i] = (png_byte)(255 -
-                    png_ptr->trans_alpha[i]);
-           }
-        }
+         if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0)
+         {
+            if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0)
+            {
+               /* Invert the alpha channel (in tRNS) unless the pixels are
+                * going to be expanded, in which case leave it for later
+                */
+               int i, istop = png_ptr->num_trans;
+
+               for (i = 0; i < istop; i++)
+                  png_ptr->trans_alpha[i] =
+                      (png_byte)(255 - png_ptr->trans_alpha[i]);
+            }
+         }
 #endif /* READ_INVERT_ALPHA */
       }
    } /* background expand and (therefore) no alpha association. */
@@ -4320,9 +4320,11 @@ png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info,
                    * but sometimes row_info->bit_depth has been changed to 8.
                    * In these cases, the palette hasn't been riffled.
                    */
-                  i = png_do_expand_palette_neon_rgba(png_ptr, row_info, row,
+                  i = png_do_expand_palette_rgba8_neon(png_ptr, row_info, row,
                       &sp, &dp);
                }
+#else
+               PNG_UNUSED(png_ptr)
 #endif
 
                for (; i < row_width; i++)
@@ -4349,8 +4351,10 @@ png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info,
                dp = row + (size_t)(row_width * 3) - 1;
                i = 0;
 #ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
-               i = png_do_expand_palette_neon_rgb(png_ptr, row_info, row,
+               i = png_do_expand_palette_rgb8_neon(png_ptr, row_info, row,
                    &sp, &dp);
+#else
+               PNG_UNUSED(png_ptr)
 #endif
 
                for (; i < row_width; i++)
@@ -4770,19 +4774,17 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
 #ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
          if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8))
          {
-            /* Allocate space for the decompressed full palette. */
             if (png_ptr->riffled_palette == NULL)
             {
-               png_ptr->riffled_palette = png_malloc(png_ptr, 256*4);
-               if (png_ptr->riffled_palette == NULL)
-                  png_error(png_ptr, "NULL row buffer");
-               /* Build the RGBA palette. */
-               png_riffle_palette_rgba(png_ptr, row_info);
+               /* Initialize the accelerated palette expansion. */
+               png_ptr->riffled_palette =
+                   (png_bytep)png_malloc(png_ptr, 256 * 4);
+               png_riffle_palette_neon(png_ptr);
             }
          }
 #endif
          png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1,
-            png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
+             png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
       }
 
       else
index 94a6d04..8bdc7ce 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngstruct.h - header file for PNG reference library
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
  * Copyright (c) 1996-1997 Andreas Dilger
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -228,10 +228,6 @@ struct png_struct_def
                                * big_row_buf; while writing it is separately
                                * allocated.
                                */
-#ifdef PNG_READ_EXPAND_SUPPORTED
-   /* Buffer to accelerate palette transformations. */
-   png_bytep riffled_palette;
-#endif
 #ifdef PNG_WRITE_FILTER_SUPPORTED
    png_bytep try_row;    /* buffer to save trial row when filtering */
    png_bytep tst_row;    /* buffer to save best trial row when filtering */
@@ -396,6 +392,12 @@ struct png_struct_def
    /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
 #endif
 
+/* New member added in libpng-1.6.36 */
+#if defined(PNG_READ_EXPAND_SUPPORTED) && \
+    defined(PNG_ARM_NEON_IMPLEMENTATION)
+   png_bytep riffled_palette; /* buffer for accelerated palette expansion */
+#endif
+
 /* New member added in libpng-1.0.4 (renamed in 1.0.9) */
 #if defined(PNG_MNG_FEATURES_SUPPORTED)
 /* Changed from png_byte to png_uint_32 at version 1.2.0 */
index f27e91e..a715ae1 100644 (file)
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
  * Copyright (c) 1996-1997 Andreas Dilger
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -957,6 +957,8 @@ test_one_file(const char *inname, const char *outname)
    if (setjmp(png_jmpbuf(write_ptr)))
    {
       fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname);
+      png_free(read_ptr, row_buf);
+      row_buf = NULL;
       if (verbose != 0)
         fprintf(STDERR, "   destroying read structs\n");
       png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
@@ -1436,7 +1438,7 @@ test_one_file(const char *inname, const char *outname)
    row_buf = (png_bytep)png_malloc(read_ptr,
        png_get_rowbytes(read_ptr, read_info_ptr));
 
-   pngtest_debug1("\t0x%08lx", (unsigned long)row_buf);
+   pngtest_debug1("\t%p", row_buf);
 #endif /* SINGLE_ROWBUF_ALLOC */
    pngtest_debug("Writing row data");
 
@@ -1490,7 +1492,7 @@ test_one_file(const char *inname, const char *outname)
          row_buf = (png_bytep)png_malloc(read_ptr,
              png_get_rowbytes(read_ptr, read_info_ptr));
 
-         pngtest_debug2("\t0x%08lx (%lu bytes)", (unsigned long)row_buf,
+         pngtest_debug2("\t%p (%lu bytes)", row_buf,
              (unsigned long)png_get_rowbytes(read_ptr, read_info_ptr));
 
 #endif /* !SINGLE_ROWBUF_ALLOC */
@@ -2153,4 +2155,4 @@ main(void)
 #endif
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_36 Your_png_h_is_not_version_1_6_36;
+typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37;
index 160c877..59377a4 100644 (file)
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2019 Cosmin Truta
  * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
  * Copyright (c) 1996-1997 Andreas Dilger
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -948,10 +948,6 @@ png_write_destroy(png_structrp png_ptr)
    png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list);
    png_free(png_ptr, png_ptr->row_buf);
    png_ptr->row_buf = NULL;
-#ifdef PNG_READ_EXPANDED_SUPPORTED
-   png_free(png_ptr, png_ptr->riffled_palette);
-   png_ptr->riffled_palette = NULL;
-#endif
 #ifdef PNG_WRITE_FILTER_SUPPORTED
    png_free(png_ptr, png_ptr->prev_row);
    png_free(png_ptr, png_ptr->try_row);
index 985271a..2a5afb4 100644 (file)
@@ -11,7 +11,7 @@
 
 # Modeled after libxml-config.
 
-version=1.6.36
+version=1.6.37
 prefix=""
 libdir=""
 libs=""
index 2f74923..416fefe 100644 (file)
@@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
 
 Name: libpng
 Description: Loads and saves PNG files
-Version: 1.6.36
+Version: 1.6.37
 Libs: -L${libdir} -lpng16
 Cflags: -I${includedir}
index 60fb113..6f915c2 100644 (file)
@@ -23,7 +23,7 @@
 
 VERMAJ = 1
 VERMIN = 6
-VERMIC = 36
+VERMIC = 37
 VER = $(VERMAJ).$(VERMIN).$(VERMIC)
 NAME = libpng
 PACKAGE = $(NAME)-$(VER)
diff --git a/scripts/makefile.clang b/scripts/makefile.clang
new file mode 100644 (file)
index 0000000..fcaefae
--- /dev/null
@@ -0,0 +1,87 @@
+# makefile for libpng using clang (generic, static library)
+# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
+# Copyright (C) 2000, 2014, 2019 Cosmin Truta
+# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
+#
+# This code is released under the libpng license.
+# For conditions of distribution and use, see the disclaimer
+# and license in png.h
+
+# Location of the zlib library and include files
+ZLIBINC = ../zlib
+ZLIBLIB = ../zlib
+
+# Compiler, linker, lib and other tools
+CC = clang
+LD = $(CC)
+AR_RC = ar rcs
+RANLIB = ranlib
+CP = cp
+RM_F = rm -f
+
+WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
+       -Wmissing-declarations -Wtraditional -Wcast-align \
+       -Wstrict-prototypes -Wmissing-prototypes # -Wconversion
+CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
+CFLAGS = -W -Wall -O2 # $(WARNMORE) -g
+LDFLAGS = -L$(ZLIBLIB)
+LIBS = -lz -lm
+
+# File extensions
+EXEEXT =
+
+# Pre-built configuration
+# See scripts/pnglibconf.mak for more options
+PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
+
+# Variables
+OBJS =  png.o pngerror.o pngget.o pngmem.o pngpread.o \
+       pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
+       pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
+
+# Targets
+all: static
+
+pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
+       $(CP) $(PNGLIBCONF_H_PREBUILT) $@
+
+.c.o:
+       $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+
+static: libpng.a pngtest$(EXEEXT)
+
+shared:
+       @echo This is a generic makefile that cannot create shared libraries.
+       @echo Please use a configuration that is specific to your platform.
+       @false
+
+libpng.a: $(OBJS)
+       $(AR_RC) $@ $(OBJS)
+       $(RANLIB) $@
+
+test: pngtest$(EXEEXT)
+       ./pngtest$(EXEEXT)
+
+pngtest$(EXEEXT): pngtest.o libpng.a
+       $(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
+
+clean:
+       $(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h
+
+png.o:      png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngget.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngmem.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngread.o:  png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngrio.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngset.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwio.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+
+pngtest.o:  png.h pngconf.h pnglibconf.h
diff --git a/scripts/makefile.clang-asan b/scripts/makefile.clang-asan
new file mode 100644 (file)
index 0000000..0cab52f
--- /dev/null
@@ -0,0 +1,87 @@
+# makefile for libpng using clang + address sanitizer (generic, static library)
+# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
+# Copyright (C) 2000, 2014, 2019 Cosmin Truta
+# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
+#
+# This code is released under the libpng license.
+# For conditions of distribution and use, see the disclaimer
+# and license in png.h
+
+# Location of the zlib library and include files
+ZLIBINC = ../zlib
+ZLIBLIB = ../zlib
+
+# Compiler, linker, lib and other tools
+CC = clang
+LD = $(CC)
+AR_RC = ar rcs
+RANLIB = ranlib
+CP = cp
+RM_F = rm -f
+
+WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
+       -Wmissing-declarations -Wtraditional -Wcast-align \
+       -Wstrict-prototypes -Wmissing-prototypes # -Wconversion
+CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
+CFLAGS = -W -Wall -O0 -g -fsanitize=address
+LDFLAGS = -L$(ZLIBLIB) -g -fsanitize=address
+LIBS = -lz -lm
+
+# File extensions
+EXEEXT =
+
+# Pre-built configuration
+# See scripts/pnglibconf.mak for more options
+PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
+
+# Variables
+OBJS =  png.o pngerror.o pngget.o pngmem.o pngpread.o \
+       pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
+       pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
+
+# Targets
+all: static
+
+pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
+       $(CP) $(PNGLIBCONF_H_PREBUILT) $@
+
+.c.o:
+       $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+
+static: libpng.a pngtest$(EXEEXT)
+
+shared:
+       @echo This is a generic makefile that cannot create shared libraries.
+       @echo Please use a configuration that is specific to your platform.
+       @false
+
+libpng.a: $(OBJS)
+       $(AR_RC) $@ $(OBJS)
+       $(RANLIB) $@
+
+test: pngtest$(EXEEXT)
+       ./pngtest$(EXEEXT)
+
+pngtest$(EXEEXT): pngtest.o libpng.a
+       $(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
+
+clean:
+       $(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h
+
+png.o:      png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngget.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngmem.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngread.o:  png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngrio.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngset.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwio.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+
+pngtest.o:  png.h pngconf.h pnglibconf.h
index ba92d15..a977313 100644 (file)
@@ -1,6 +1,6 @@
 # makefile for libpng using gcc (generic, static library)
 # Copyright (C) 2008, 2014 Glenn Randers-Pehrson
-# Copyright (C) 2000 Cosmin Truta
+# Copyright (C) 2000, 2014, 2019 Cosmin Truta
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 #
 # This code is released under the libpng license.
@@ -24,7 +24,7 @@ WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
        -Wstrict-prototypes -Wmissing-prototypes # -Wconversion
 CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
 CFLAGS = -W -Wall -O2 # $(WARNMORE) -g
-LDFLAGS =
+LDFLAGS = -L$(ZLIBLIB)
 LIBS = -lz -lm
 
 # File extensions
@@ -63,7 +63,7 @@ test: pngtest$(EXEEXT)
        ./pngtest$(EXEEXT)
 
 pngtest$(EXEEXT): pngtest.o libpng.a
-       $(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest.o libpng.a $(LIBS)
+       $(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
 
 clean:
        $(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h
diff --git a/scripts/makefile.gcc-asan b/scripts/makefile.gcc-asan
new file mode 100644 (file)
index 0000000..aae55d6
--- /dev/null
@@ -0,0 +1,87 @@
+# makefile for libpng using gcc + address sanitizer (generic, static library)
+# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
+# Copyright (C) 2000, 2014, 2019 Cosmin Truta
+# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
+#
+# This code is released under the libpng license.
+# For conditions of distribution and use, see the disclaimer
+# and license in png.h
+
+# Location of the zlib library and include files
+ZLIBINC = ../zlib
+ZLIBLIB = ../zlib
+
+# Compiler, linker, lib and other tools
+CC = gcc
+LD = $(CC)
+AR_RC = ar rcs
+RANLIB = ranlib
+CP = cp
+RM_F = rm -f
+
+WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
+       -Wmissing-declarations -Wtraditional -Wcast-align \
+       -Wstrict-prototypes -Wmissing-prototypes # -Wconversion
+CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
+CFLAGS = -W -Wall -O0 -g -fsanitize=address
+LDFLAGS = -L$(ZLIBLIB) -g -fsanitize=address
+LIBS = -lz -lm
+
+# File extensions
+EXEEXT =
+
+# Pre-built configuration
+# See scripts/pnglibconf.mak for more options
+PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
+
+# Variables
+OBJS =  png.o pngerror.o pngget.o pngmem.o pngpread.o \
+       pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
+       pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
+
+# Targets
+all: static
+
+pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
+       $(CP) $(PNGLIBCONF_H_PREBUILT) $@
+
+.c.o:
+       $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+
+static: libpng.a pngtest$(EXEEXT)
+
+shared:
+       @echo This is a generic makefile that cannot create shared libraries.
+       @echo Please use a configuration that is specific to your platform.
+       @false
+
+libpng.a: $(OBJS)
+       $(AR_RC) $@ $(OBJS)
+       $(RANLIB) $@
+
+test: pngtest$(EXEEXT)
+       ./pngtest$(EXEEXT)
+
+pngtest$(EXEEXT): pngtest.o libpng.a
+       $(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
+
+clean:
+       $(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h
+
+png.o:      png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngget.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngmem.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngread.o:  png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngrio.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngset.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwio.o:   png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
+
+pngtest.o:  png.h pngconf.h pnglibconf.h
index 32eb859..f2d8bea 100644 (file)
@@ -10,7 +10,7 @@
 # Library name:
 LIBNAME = libpng16
 PNGMAJ = 16
-RELEASE = 36
+RELEASE = 37
 
 # Shared library names:
 LIBSO=$(LIBNAME).so
index 76f6d1a..327151f 100644 (file)
@@ -10,7 +10,7 @@
 # Library name:
 LIBNAME = libpng16
 PNGMAJ = 16
-RELEASE = 36
+RELEASE = 37
 
 # Shared library names:
 LIBSO=$(LIBNAME).so
index 2af7a6a..6b9daf8 100644 (file)
@@ -1,10 +1,11 @@
 # makefile for libpng using MSYS/gcc (shared, static library)
+# Copyright (C) 2019 Cosmin Truta
 # Copyright (C) 2012 Glenn Randers-Pehrson and Christopher M. Wheeler
 #
-# Portions taken from makefile.linux:
+# Portions taken from makefile.linux and makefile.gcc:
+# Copyright (C) 2000 Cosmin Truta
 # Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2014 Greg Roelofs and
 # Glenn Randers-Pehrson
-# Copyright (C) 2000 Cosmin Truta
 # Copyright (C) 1996, 1997 Andreas Dilger
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 #
@@ -18,7 +19,7 @@ exec_prefix=$(prefix)
 # Library name:
 LIBNAME = libpng16
 PNGMAJ = 16
-RELEASE = 36
+RELEASE = 37
 
 # Shared library names:
 LIBSO=$(LIBNAME).dll
@@ -176,7 +177,7 @@ test: pngtest$(EXEEXT)
        ./pngtest$(EXEEXT)
 
 pngtest$(EXEEXT): pngtest.o libpng.a
-       $(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest.o libpng.a $(LIBS)
+       $(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
 
 clean:
        $(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h $(LIBSO) \
diff --git a/scripts/makefile.ne12bsd b/scripts/makefile.ne12bsd
deleted file mode 100644 (file)
index d0a6a37..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-# makefile for libpng for NetBSD for the standard
-# make obj && make depend && make && make test
-# make includes && make install
-# Copyright (C) 2002 Patrick R.L. Welche
-# Copyright (C) 2007, 2009, 2014 Glenn Randers-Pehrson
-#
-# This code is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h
-
-# You should also run makefile.netbsd
-
-LOCALBASE?=/usr/local
-LIBDIR=        ${LOCALBASE}/lib
-MANDIR= ${LOCALBASE}/man
-INCSDIR=${LOCALBASE}/include/libpng16
-
-LIB=   png16
-SHLIB_MAJOR=   0
-SHLIB_MINOR=   1.6.36
-SRCS=  png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
-       pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
-       pngwtran.c pngmem.c pngerror.c pngpread.c
-INCS=  png.h pngconf.h pnglibconf.h
-MAN=   libpng.3 libpngpf.3 png.5
-
-CPPFLAGS+=-I${.CURDIR}
-
-# Pre-built configuration
-# See scripts/pnglibconf.mak for more options
-PNGLIBCONF_H_PREBUILT= scripts/pnglibconf.h.prebuilt
-
-# We should be able to do something like this instead of the manual
-# uncommenting, but it core dumps for me at the moment:
-# .if ${MACHINE_ARCH} == "i386"
-#   MKLINT= no
-# .endif
-
-CLEANFILES+=pngtest.o pngtest pnglibconf.h
-
-.c.o:
-       $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
-
-pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
-       cp $(PNGLIBCONF_H_PREBUILT) $@
-
-pngtest.o:     pngtest.c
-       ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET}
-
-pngtest:       pngtest.o libpng.a
-       ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm
-
-test:  pngtest
-       cd ${.CURDIR} && ${.OBJDIR}/pngtest
-
-.include <bsd.lib.mk>
index 589c1f8..9a6b046 100644 (file)
@@ -8,19 +8,18 @@
 # For conditions of distribution and use, see the disclaimer
 # and license in png.h
 
-# You should also run makefile.ne16bsd
-
 LOCALBASE?=/usr/local
 LIBDIR=        ${LOCALBASE}/lib
 MANDIR= ${LOCALBASE}/man
 INCSDIR=${LOCALBASE}/include
 
-LIB=   png
 SHLIB_MAJOR=   16
-SHLIB_MINOR=   1.6.36
-SRCS=  png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
-       pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
-       pngwtran.c pngmem.c pngerror.c pngpread.c
+SHLIB_MINOR=   1.6.37
+
+LIB=   png
+SRCS=  png.c pngerror.c pngget.c pngmem.c pngpread.c \
+       pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c \
+       pngwio.c pngwrite.c pngwtran.c pngwutil.c
 INCS=  png.h pngconf.h pnglibconf.h
 MAN=   libpng.3 libpngpf.3 png.5
 
@@ -39,16 +38,16 @@ PNGLIBCONF_H_PREBUILT= scripts/pnglibconf.h.prebuilt
 CLEANFILES+=pngtest.o pngtest pnglibconf.h
 
 .c.o:
-       $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+       ${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $<
 
-pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
-       cp $(PNGLIBCONF_H_PREBUILT) $@
+pnglibconf.h: ${PNGLIBCONF_H_PREBUILT}
+       cp ${PNGLIBCONF_H_PREBUILT} $@
 
 pngtest.o:     pngtest.c
        ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET}
 
 pngtest:       pngtest.o libpng.a
-       ${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm
+       ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} -lz -lm
 
 test:  pngtest
        cd ${.CURDIR} && ${.OBJDIR}/pngtest
index 4057b2e..ad5ffb3 100644 (file)
@@ -11,14 +11,16 @@ LIBDIR=     ${PREFIX}/lib
 MANDIR= ${PREFIX}/man/cat
 
 SHLIB_MAJOR=   16
-SHLIB_MINOR=   1.6.36
+SHLIB_MINOR=   1.6.37
 
 LIB=   png
 SRCS=  png.c pngerror.c pngget.c pngmem.c pngpread.c \
        pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c \
        pngwio.c pngwrite.c pngwtran.c pngwutil.c
-
 HDRS=  png.h pngconf.h pnglibconf.h
+MAN=   libpng.3 libpngpf.3 png.5
+DOCS=  ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO \
+       libpng-manual.txt
 
 CFLAGS+= -W -Wall
 CPPFLAGS+= -I${.CURDIR}
@@ -27,22 +29,18 @@ NOPROFILE= Yes
 
 CLEANFILES+= pngtest.o pngtest pnglibconf.h
 
-MAN=   libpng.3 libpngpf.3 png.5
-DOCS=  ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO \
-       libpng-manual.txt
-
 # Pre-built configuration
 # See scripts/pnglibconf.mak for more options
 PNGLIBCONF_H_PREBUILT= scripts/pnglibconf.h.prebuilt
 
 .c.o:
-       $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
+       ${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $<
 
-pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
-       cp $(PNGLIBCONF_H_PREBUILT) $@
+pnglibconf.h: ${PNGLIBCONF_H_PREBUILT}
+       cp ${PNGLIBCONF_H_PREBUILT} $@
 
 pngtest.o:     pngtest.c
-       ${CC} ${CPPFLAGS} ${CFLAGS} -c ${.ALLSRC} -o ${.TARGET}
+       ${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET}
 
 pngtest:       pngtest.o
        ${CC} ${LDFLAGS} ${.ALLSRC} -o ${.TARGET} -L${.OBJDIR} -lpng -lz -lm
index 15bd08e..4dcaf7c 100644 (file)
@@ -8,7 +8,7 @@ com pnglibconf.h - library build configuration
 com
 version
 com
-com Copyright (c) 2018 Cosmin Truta
+com Copyright (c) 2018-2019 Cosmin Truta
 com Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
 com
 com This code is released under the libpng license.
index 00340c6..e1e27e9 100644 (file)
@@ -1,8 +1,8 @@
 /* pnglibconf.h - library build configuration */
 
-/* libpng version 1.6.36 */
+/* libpng version 1.6.37 */
 
-/* Copyright (c) 2018 Cosmin Truta */
+/* Copyright (c) 2018-2019 Cosmin Truta */
 /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
 
 /* This code is released under the libpng license. */