[libpng16] Imported from libpng-1.6.13beta01.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index f543c9e..4cc86e8 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.6.13beta01 - June 25, 2014
+Libpng 1.6.13beta01 - July 4, 2014
 
 This is not intended to be a public release.  It will be replaced
 within a few weeks by a public version or by another test version.
@@ -26,7 +26,7 @@
 
 Changes since the last public release (1.6.13):
 
-Version 1.6.13beta01 [June 25, 2014]
+Version 1.6.13beta01 [July 4, 2014]
   Quieted -Wsign-compare and -Wclobber compiler warnings in
     contrib/pngminus/*.c
   Added "(void) png_ptr;" where needed in contrib/gregbook to quiet
diff --git a/CHANGES b/CHANGES
index ae4e4f3..b47be20 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4940,7 +4940,7 @@
 Version 1.6.12 [June 12, 2014]
   No changes.
 
-Version 1.6.13beta01 [June 25, 2014]
+Version 1.6.13beta01 [July 4, 2014]
   Quieted -Wsign-compare and -Wclobber compiler warnings in
     contrib/pngminus/*.c
   Added "(void) png_ptr;" where needed in contrib/gregbook to quiet
diff --git a/INSTALL b/INSTALL
index 49e9329..c333584 100644
--- a/INSTALL
+++ b/INSTALL
@@ -28,7 +28,9 @@
     make check
     make install
 
-and ignore the rest of this document.
+and ignore the rest of this document.  "/path" is the path to the directory
+where you want to install the libpng "lib", "include", and "bin"
+subdirectories.
 
 II. Rebuilding the configure scripts
 
@@ -64,8 +66,8 @@
 
 Before installing libpng, you must first install zlib, if it
 is not already on your system.  zlib can usually be found
-wherever you got libpng.  zlib can be placed in another directory,
-at the same level as libpng.
+wherever you got libpng; otherwise go to http://zlib.net.  You can place
+placed zlib in in the same directory as libpng or in another directory.
 
 If your system already has a preinstalled zlib you will still need
 to have access to the zlib.h and zconf.h include files that
@@ -93,6 +95,10 @@
    make
    make install
 
+As when using the simple configure method described above, "/path" points to
+the installation directory where you want to put the libpng "lib", "include",
+and "bin" subdirectories.
+
 V. Directory structure
 
 You can rename the directories that you downloaded (they
@@ -322,9 +328,10 @@
 These mechanisms still work in the configure build and in any makefile
 build that builds pnglibconf.h, although the feature selection macros
 have changed somewhat as described above.  In 1.5.0, however, pngusr.h is
-processed only once, when the exported header file pnglibconf.h is built.
-pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the
-build of pnglibconf.h and it is never included in an application build.
+processed only once, at the time the exported header file pnglibconf.h is
+built.  pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
+after the build of pnglibconf.h and it is never included in an application
+build.
 
 The rarely used alternative of adding a list of feature macros to the
 CPPFLAGS setting in the build also still works; however, the macros will be
@@ -347,7 +354,7 @@
 pngusr.h a system builder may also define equivalent options in pngusr.dfa
 (or, indeed, any file) and add that to the configuration by setting
 DFA_XTRA to the file name.  The makefiles in contrib/pngminim illustrate
-how to do this, and a case where pngusr.h is still required.
+how to do this, and illustrate a case where pngusr.h is still required.
 
 XV. Configuring libpng for multiprocessing
 
diff --git a/LICENSE b/LICENSE
index caf19b5..135c22d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -10,7 +10,7 @@
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.6.13beta01, June 12, 2014, are
+libpng versions 1.2.6, August 15, 2004, through 1.6.13beta01, July 4, 2014, are
 Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
@@ -108,4 +108,4 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-June 12, 2014
+July 4, 2014
diff --git a/README b/README
index a826b99..e30e2aa 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng version 1.6.13beta01 - June 12, 2014 (shared library 16.0)
+README for libpng version 1.6.13beta01 - July 4, 2014 (shared library 16.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
diff --git a/contrib/gregbook/Makefile.unx b/contrib/gregbook/Makefile.unx
index c8cadf8..1a73e03 100644
--- a/contrib/gregbook/Makefile.unx
+++ b/contrib/gregbook/Makefile.unx
@@ -59,15 +59,16 @@
 RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
 RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
 WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
-WLIBSs = $(PNGLIBs) $(ZLIBs)
+WLIBSs = $(PNGLIBs) $(ZLIBs) -lm
 
 CC = gcc
 LD = gcc
 RM = rm -f
 CPPFLAGS = $(INCS) -DFEATURE_LOOP
 CFLAGS = -O -Wall
+#CFLAGS = -O -W -Wall -Wextra -pedantic -ansi
 # [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
-# [-ansi, -pedantic and -W can also be used]
+# [-ansi, -pedantic, -Wextra, and -W can also be used]
 LDFLAGS =
 O = .o
 E =
diff --git a/contrib/gregbook/readppm.c b/contrib/gregbook/readppm.c
index be9a56d..7fefc39 100644
--- a/contrib/gregbook/readppm.c
+++ b/contrib/gregbook/readppm.c
@@ -163,8 +163,12 @@
 
     /* now we can go ahead and just read the whole image */
 
-    fread(image_data, 1L, rowbytes*height, saved_infile);
-
+    if (fread(image_data, 1L, rowbytes*height, saved_infile) <
+       rowbytes*height) {
+        free (image_data);
+        image_data = NULL;
+        return NULL;
+    }
 
     return image_data;
 }
diff --git a/contrib/gregbook/rpng-x.c b/contrib/gregbook/rpng-x.c
index 6d10e1b..ddd7c58 100644
--- a/contrib/gregbook/rpng-x.c
+++ b/contrib/gregbook/rpng-x.c
@@ -26,6 +26,8 @@
     - 1.14:  added support for X resources (thanks to Gerhard Niklasch)
     - 2.00:  dual-licensed (added GNU GPL)
     - 2.01:  fixed improper display of usage screen on PNG error(s)
+    - 2.02:  Added "void(argc);" statement to quiet pedantic compiler warnings
+             about unused variable (GR-P)
 
   ---------------------------------------------------------------------------
 
@@ -80,7 +82,7 @@
 
 #define PROGNAME  "rpng-x"
 #define LONGNAME  "Simple PNG Viewer for X"
-#define VERSION   "2.01 of 16 March 2008"
+#define VERSION   "2.02 of 15 June 2014"
 #define RESNAME   "rpng"        /* our X resource application name */
 #define RESCLASS  "Rpng"        /* our X resource class name */
 
@@ -279,15 +281,17 @@
           "Usage:  %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
           "    xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
           "    exp \ttransfer-function exponent (``gamma'') of the display\n"
-          "\t\t  system in floating-point format (e.g., ``%.1f''); equal\n"
+          "\t\t  system in floating-point format (e.g., ``%.1f''); equal\n",
+          PROGNAME, default_display_exponent);
+
+        fprintf(stderr, "\n"
           "\t\t  to the product of the lookup-table exponent (varies)\n"
           "\t\t  and the CRT exponent (usually 2.2); must be positive\n"
           "    bg  \tdesired background color in 7-character hex RGB format\n"
           "\t\t  (e.g., ``#ff7700'' for orange:  same as HTML colors);\n"
           "\t\t  used with transparent images\n"
           "\nPress Q, Esc or mouse button 1 (within image window, after image\n"
-          "is displayed) to quit.\n"
-          "\n", PROGNAME, default_display_exponent);
+          "is displayed) to quit.\n");
         exit(1);
     }
 
@@ -419,6 +423,8 @@
 
     rpng_x_cleanup();
 
+    (void)argc; /* Unused */
+
     return 0;
 }
 
diff --git a/contrib/gregbook/rpng2-win.c b/contrib/gregbook/rpng2-win.c
index 223e737..eda176e 100644
--- a/contrib/gregbook/rpng2-win.c
+++ b/contrib/gregbook/rpng2-win.c
@@ -33,6 +33,8 @@
     - 2.02:  fixed improper display of usage screen on PNG error(s); fixed
               unexpected-EOF and file-read-error cases
     - 2.03:  removed runtime MMX-enabling/disabling and obsolete -mmx* options
+    - 2.04:  
+             (GR-P)
 
   ---------------------------------------------------------------------------
 
diff --git a/contrib/gregbook/rpng2-x.c b/contrib/gregbook/rpng2-x.c
index cd70c7a..a146ef4 100644
--- a/contrib/gregbook/rpng2-x.c
+++ b/contrib/gregbook/rpng2-x.c
@@ -750,6 +750,7 @@
     rpng2_x_cleanup();
 
     (void)argc; /* Unused */
+
     return 0;
 }
 
diff --git a/libpng-manual.txt b/libpng-manual.txt
index a61eaed..b874c12 100644
--- a/libpng-manual.txt
+++ b/libpng-manual.txt
@@ -1,6 +1,6 @@
 libpng-manual.txt - A description on how to use and modify libpng
 
- libpng version 1.6.13beta01 - June 12, 2014
+ libpng version 1.6.13beta01 - July 4, 2014
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -11,7 +11,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.6.13beta01 - June 12, 2014
+ libpng versions 0.97, January 1998, through 1.6.13beta01 - July 4, 2014
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2014 Glenn Randers-Pehrson
 
@@ -5042,7 +5042,8 @@
 libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by
 means of
 
-    #ifdef PNG_SKIP_sRGB_CHECK_PROFILE
+    #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \
+        defined(PNG_SET_OPTION_SUPPORTED)
        png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE,
            PNG_OPTION_ON);
     #endif
@@ -5055,8 +5056,8 @@
 with color type 0 or 4 and that even if the image only contains gray pixels,
 only RGB profiles may appear in images with color type 2, 3, or 6, is now
 enforced.  The sRGB chunk is allowed to appear in images with any color type
-and is interpreted by libpng to convey a one-tracer-curve profile or a
-three-tracer-curve profile as appropriate.
+and is interpreted by libpng to convey a one-tracer-curve gray profile or a
+three-tracer-curve RGB profile as appropriate.
 
 Prior to libpng-1.6.0 a warning would be issued if the iTXt chunk contained
 an empty language field or an empty translated keyword.  Both of these
@@ -5275,7 +5276,7 @@
 
 XVI. Y2K Compliance in libpng
 
-June 12, 2014
+July 4, 2014
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
diff --git a/libpng.3 b/libpng.3
index 8c0a1c5..e643398 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,4 +1,4 @@
-.TH LIBPNG 3 "June 12, 2014"
+.TH LIBPNG 3 "July 4, 2014"
 .SH NAME
 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.13beta01
 .SH SYNOPSIS
@@ -504,7 +504,7 @@
 .SH LIBPNG.TXT
 libpng-manual.txt - A description on how to use and modify libpng
 
- libpng version 1.6.13beta01 - June 12, 2014
+ libpng version 1.6.13beta01 - July 4, 2014
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2014 Glenn Randers-Pehrson
@@ -515,7 +515,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.6.13beta01 - June 12, 2014
+ libpng versions 0.97, January 1998, through 1.6.13beta01 - July 4, 2014
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2014 Glenn Randers-Pehrson
 
@@ -5546,7 +5546,8 @@
 libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by
 means of
 
-    #ifdef PNG_SKIP_sRGB_CHECK_PROFILE
+    #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \
+        defined(PNG_SET_OPTION_SUPPORTED)
        png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE,
            PNG_OPTION_ON);
     #endif
@@ -5559,8 +5560,8 @@
 with color type 0 or 4 and that even if the image only contains gray pixels,
 only RGB profiles may appear in images with color type 2, 3, or 6, is now
 enforced.  The sRGB chunk is allowed to appear in images with any color type
-and is interpreted by libpng to convey a one-tracer-curve profile or a
-three-tracer-curve profile as appropriate.
+and is interpreted by libpng to convey a one-tracer-curve gray profile or a
+three-tracer-curve RGB profile as appropriate.
 
 Prior to libpng-1.6.0 a warning would be issued if the iTXt chunk contained
 an empty language field or an empty translated keyword.  Both of these
@@ -5779,7 +5780,7 @@
 
 .SH XVI. Y2K Compliance in libpng
 
-June 12, 2014
+July 4, 2014
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
@@ -6081,7 +6082,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.6.13beta01 - June 12, 2014:
+Libpng version 1.6.13beta01 - July 4, 2014:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
 
@@ -6104,7 +6105,7 @@
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.6.13beta01, June 12, 2014, are
+libpng versions 1.2.6, August 15, 2004, through 1.6.13beta01, July 4, 2014, are
 Copyright (c) 2004,2006-2014 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
@@ -6203,7 +6204,7 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-June 12, 2014
+July 4, 2014
 
 .\" end of man page
 
diff --git a/libpngpf.3 b/libpngpf.3
index 3ccad5d..66f0ce8 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,4 +1,4 @@
-.TH LIBPNGPF 3 "June 12, 2014"
+.TH LIBPNGPF 3 "July 4, 2014"
 .SH NAME
 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.13beta01
 (private functions)
diff --git a/png.5 b/png.5
index 8f329fd..d8c9c2a 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "June 12, 2014"
+.TH PNG 5 "July 4, 2014"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index dad15f2..9608d78 100644
--- a/png.c
+++ b/png.c
@@ -773,13 +773,13 @@
 #else
 #  ifdef __STDC__
    return PNG_STRING_NEWLINE \
-     "libpng version 1.6.13beta01 - June 12, 2014" PNG_STRING_NEWLINE \
+     "libpng version 1.6.13beta01 - July 4, 2014" PNG_STRING_NEWLINE \
      "Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
      "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
      "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
      PNG_STRING_NEWLINE;
 #  else
-      return "libpng version 1.6.13beta01 - June 12, 2014\
+      return "libpng version 1.6.13beta01 - July 4, 2014\
       Copyright (c) 1998-2014 Glenn Randers-Pehrson\
       Copyright (c) 1996-1997 Andreas Dilger\
       Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
diff --git a/png.h b/png.h
index c2e537f..cf33017 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.6.13beta01 - June 12, 2014
+ * libpng version 1.6.13beta01 - July 4, 2014
  * Copyright (c) 1998-2014 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -11,7 +11,7 @@
  * Authors and maintainers:
  *   libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *   libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- *   libpng versions 0.97, January 1998, through 1.6.13beta01 - June 12, 2014: Glenn
+ *   libpng versions 0.97, January 1998, through 1.6.13beta01 - July 4, 2014: Glenn
  *   See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -232,7 +232,7 @@
  *
  * This code is released under the libpng license.
  *
- * libpng versions 1.2.6, August 15, 2004, through 1.6.13beta01, June 12, 2014, are
+ * libpng versions 1.2.6, August 15, 2004, through 1.6.13beta01, July 4, 2014, are
  * Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
  * distributed according to the same disclaimer and license as libpng-1.2.5
  * with the following individual added to the list of Contributing Authors:
@@ -344,7 +344,7 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    June 12, 2014
+ *    July 4, 2014
  *
  *    Since the PNG Development group is an ad-hoc body, we can't make
  *    an official declaration.
@@ -414,7 +414,7 @@
 /* Version information for png.h - this should match the version in png.c */
 #define PNG_LIBPNG_VER_STRING "1.6.13beta01"
 #define PNG_HEADER_VERSION_STRING \
-     " libpng version 1.6.13beta01 - June 12, 2014\n"
+     " libpng version 1.6.13beta01 - July 4, 2014\n"
 
 #define PNG_LIBPNG_VER_SONUM   16
 #define PNG_LIBPNG_VER_DLLNUM  16
diff --git a/pngconf.h b/pngconf.h
index afef309..6bd20eb 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng version 1.6.13beta01 - June 12, 2014
+ * libpng version 1.6.13beta01 - July 4, 2014
  *
  * Copyright (c) 1998-2014 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngerror.c b/pngerror.c
index fdf4965..ef84ffb 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * Last changed in libpng 1.6.11 [June 5, 2014]
+ * Last changed in libpng 1.6.13 [(PENDING RELEASE)]
  * Copyright (c) 1998-2014 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
diff --git a/projects/vstudio/readme.txt b/projects/vstudio/readme.txt
index 68ee3ac..7544215 100644
--- a/projects/vstudio/readme.txt
+++ b/projects/vstudio/readme.txt
@@ -1,7 +1,7 @@
 
 VisualStudio instructions
 
-libpng version 1.6.13beta01 - June 12, 2014
+libpng version 1.6.13beta01 - July 4, 2014
 
 Copyright (c) 1998-2010 Glenn Randers-Pehrson
 
diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props
index c0c5de0..62a0b16 100644
--- a/projects/vstudio/zlib.props
+++ b/projects/vstudio/zlib.props
@@ -2,7 +2,7 @@
 <!--
  * zlib.props - location of zlib source
  *
- * libpng version 1.6.13beta01 - June 12, 2014
+ * libpng version 1.6.13beta01 - July 4, 2014
  *
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  *
diff --git a/scripts/README.txt b/scripts/README.txt
index 7eb8482..8eb6e52 100644
--- a/scripts/README.txt
+++ b/scripts/README.txt
@@ -1,5 +1,5 @@
 
-Makefiles for  libpng version 1.6.13beta01 - June 12, 2014
+Makefiles for  libpng version 1.6.13beta01 - July 4, 2014
 
 pnglibconf.h.prebuilt       =>  Stores configuration settings
  makefile.linux    =>  Linux/ELF makefile
diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt
index f5f6434..bc093e1 100644
--- a/scripts/pnglibconf.h.prebuilt
+++ b/scripts/pnglibconf.h.prebuilt
@@ -2,7 +2,7 @@
 
 /* pnglibconf.h - library build configuration */
 
-/* Libpng version 1.6.13beta01 - June 12, 2014 */
+/* Libpng version 1.6.13beta01 - July 4, 2014 */
 
 /* Copyright (c) 1998-2014 Glenn Randers-Pehrson */