Imported from libpng-1.0.5d.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index b5f1085..a3acc58 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.0.5c - November 27, 1999
+Libpng 1.0.5d - November 29, 1999
 
 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.
@@ -21,7 +21,7 @@
   Fixed some typecasting in contrib/gregbook/*.c
   Updated scripts/makevms.com and added makevms.com to contrib/gregbook
     and contrib/pngminus (Martin Zinser)
-version 1.0.5c [November 27, 1999]
+version libpng-1.0.5c November 26, 1999
   Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr.
   Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to
     accomodate making DLL's: Moved usr_png_ver from global variable to function
@@ -34,6 +34,13 @@
   Removed some extraneous "-I" from contrib/pngminus/makefile.std
   Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
   Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 
+version 1.0.5d [November 29, 1999]
+  Add type cast (png_const_charp) two places in png.c
+  Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
+  Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
+    to applications a macro "PNG_USE_LOCAL_ARRAYS".
+  #ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
+  Added PNG_EXPORT_VAR macro to accommodate making DLL's.
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/CHANGES b/CHANGES
index 49567ab..cb04434 100644
--- a/CHANGES
+++ b/CHANGES
@@ -491,7 +491,7 @@
   Fixed some typecasting in contrib/gregbook/*.c
   Updated scripts/makevms.com and added makevms.com to contrib/gregbook
     and contrib/pngminus (Martin Zinser)
-version 1.0.5c [November 27, 1999]
+version 1.0.5c [November 26, 1999]
   Moved png_get_header_version from png.h to png.c, to accomodate ansi2knr.
   Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to
     accomodate making DLL's: Moved usr_png_ver from global variable to function
@@ -504,3 +504,10 @@
   Removed some extraneous "-I" from contrib/pngminus/makefile.std
   Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2.
   Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 
+version 1.0.5d [November 29, 1999]
+  Add type cast (png_const_charp) two places in png.c
+  Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays.
+  Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available
+    to applications a macro "PNG_USE_LOCAL_ARRAYS".
+  #ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined.
+  Added PNG_EXPORT_VAR macro to accommodate making DLL's.
diff --git a/INSTALL b/INSTALL
index f53bbde..b11bfe1 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.0.5c - November 27, 1999
+Installing libpng version 1.0.5d - November 29, 1999
 
 Before installing libpng, you must first install zlib.  zlib
 can usually be found wherever you got libpng.  zlib can be
@@ -10,7 +10,7 @@
 version of zlib that's installed.
 
 You can rename the directories that you downloaded (they
-might be called "libpng-1.0.5c" or "lpng103" and "zlib-1.1.3"
+might be called "libpng-1.0.5d" or "lpng103" and "zlib-1.1.3"
 or "zlib113") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
@@ -51,8 +51,8 @@
  makefile.hpux     =>  HPUX (10.20 and 11.00) makefile
  makefile.sgi      =>  Silicon Graphics IRIX makefile
  makefile.sunos    =>  Sun makefile
- makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5c)
- makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5c)
+ makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.2.1.0.5d)
+ makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng.so.2.1.0.5d)
  makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
  makefile.mips     =>  MIPS makefile
  makefile.acorn    =>  Acorn makefile
diff --git a/LICENSE b/LICENSE
index d6ca4e6..e966032 100644
--- a/LICENSE
+++ b/LICENSE
@@ -5,7 +5,7 @@
 Copyright (c) 1996, 1997 Andreas Dilger
 (libpng versions 0.90, December 1996, through 0.96, May 1997)
 Copyright (c) 1998, 1999 Glenn Randers-Pehrson
-(libpng versions 0.97, January 1998, through 1.0.5c, November 27, 1999)
+(libpng versions 0.97, January 1998, through 1.0.5d, November 29, 1999)
 
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
@@ -67,4 +67,4 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-November 27, 1999
+November 29, 1999
diff --git a/README b/README
index 1d07f8f..c38cece 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng 1.0.5c - November 27, 1999 (shared library 2.1)
+README for libpng 1.0.5d - November 29, 1999 (shared library 2.1)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -171,9 +171,9 @@
        makefile.sgi     =>  Silicon Graphics IRIX makefile
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng.so.2.1.0.5c)
+                            (gcc, creates libpng.so.2.1.0.5d)
        makefile.linux   =>  Linux/ELF makefile
-                            (gcc, creates libpng.so.2.1.0.5c)
+                            (gcc, creates libpng.so.2.1.0.5d)
        makefile.sco     =>  For SCO OSr5  ELF and Unixware 7 with Native cc
        makefile.mips    =>  MIPS makefile
        makefile.acorn   =>  Acorn makefile
diff --git a/Y2KINFO b/Y2KINFO
index ade7056..200ae08 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
       
-      November 27, 1999
+      November 29, 1999
       
       Since the PNG Development group is an ad-hoc body, we can't make
       an official declaration.
       
       This is your unofficial assurance that libpng from version 0.71 and
-      upward through 1.0.5c are Y2K compliant.  It is my belief that earlier
+      upward through 1.0.5d are Y2K compliant.  It is my belief that earlier
       versions were also Y2K compliant.
       
       Libpng only has three year fields.  One is a 2-byte unsigned integer
diff --git a/libpng.3 b/libpng.3
index 3ebe446..019252e 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "November 27, 1999"
+.TH LIBPNG 3 "November 29, 1999"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5c - November 27, 1999
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29, 1999
 .SH SYNOPSIS
 \fI\fB
 
@@ -629,7 +629,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.5c - November 27, 1999
+ libpng version 1.0.5d - November 29, 1999
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -2434,7 +2434,7 @@
 to the sections that describe chunk names, and look at how other chunks
 were designed, so you can do things similarly.  Second, check out the
 sections of libpng that read and write chunks.  Try to find a chunk that
-is similar to yours and copy off of it.  More details can be found in the
+is similar to yours and use it as a template.  More details can be found in the
 comments inside the code.  A way of handling unknown chunks in a generic
 method, potentially via callback functions, would be best.
 
@@ -2695,13 +2695,13 @@
 
 .SH VII. Y2K Compliance in libpng
 
-November 27, 1999
+November 29, 1999
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.0.5c are Y2K compliant.  It is my belief that earlier
+upward through 1.0.5d are Y2K compliant.  It is my belief that earlier
 versions were also Y2K compliant.
 
 Libpng only has three year fields.  One is a 2-byte unsigned integer that
@@ -2827,7 +2827,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
   
-Libpng version 1.0.5c - November 27, 1999:
+Libpng version 1.0.5d - November 29, 1999:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
 
@@ -2842,7 +2842,7 @@
 Copyright (c) 1996, 1997 Andreas Dilger
 (libpng versions 0.90, December 1996, through 0.96, May 1997)
 Copyright (c) 1998, 1999 Glenn Randers-Pehrson
-(libpng versions 0.97, January 1998, through 1.0.5c, November 27, 1999)
+(libpng versions 0.97, January 1998, through 1.0.5d, November 29, 1999)
 
 For the purposes of this copyright and license, "Contributing Authors"
 is defined as the following set of individuals:
diff --git a/libpng.txt b/libpng.txt
index db313b6..3a567f7 100644
--- a/libpng.txt
+++ b/libpng.txt
@@ -1,6 +1,6 @@
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.5c - November 27, 1999
+ libpng version 1.0.5d - November 29, 1999
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -1805,7 +1805,7 @@
 to the sections that describe chunk names, and look at how other chunks
 were designed, so you can do things similarly.  Second, check out the
 sections of libpng that read and write chunks.  Try to find a chunk that
-is similar to yours and copy off of it.  More details can be found in the
+is similar to yours and use it as a template.  More details can be found in the
 comments inside the code.  A way of handling unknown chunks in a generic
 method, potentially via callback functions, would be best.
 
@@ -2066,13 +2066,13 @@
 
 VII. Y2K Compliance in libpng
 
-November 27, 1999
+November 29, 1999
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.0.5c are Y2K compliant.  It is my belief that earlier
+upward through 1.0.5d are Y2K compliant.  It is my belief that earlier
 versions were also Y2K compliant.
 
 Libpng only has three year fields.  One is a 2-byte unsigned integer that
diff --git a/libpngpf.3 b/libpngpf.3
index a42e998..55f9e90 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 November 27, 1999
+.TH LIBPNGPF 3 November 29, 1999
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5c - November 27, 1999
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.5d - November 29, 1999
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
diff --git a/png.5 b/png.5
index ce33275..e9e80f9 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "November 27, 1999"
+.TH PNG 5 "November 29, 1999"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index c5d19aa..4c9050b 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.0.5c - November 27, 1999
+ * libpng version 1.0.5d - November 29, 1999
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
  * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -16,39 +16,32 @@
  * string defined in png.h.
  */
 
-#ifdef PNG_GLOBAL_ARRAYS
+#ifdef PNG_USE_GLOBAL_ARRAYS
 /* png_libpng_ver was changed to a function in version 1.0.5c */
-char png_libpng_ver[12] = "1.0.5c";
+char png_libpng_ver[12] = "1.0.5d";
 
 /* png_sig was changed to a function in version 1.0.5c */
 /* Place to hold the signature string for a PNG file. */
 png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
  
-/* This was moved to pngtypes.h and other places in version 1.0.5c.
- * It was nicer having them all in one place, but it interfered with
- * people building DLL's. */
-
-/* Constant strings for known chunk types.  If you need to add a chunk,
- * add a string holding the name here.  If you want to make the code
- * portable to EBCDIC machines, use ASCII numbers, not characters.
- */
-png_byte FARDATA png_IHDR[5] = { 73,  72,  68,  82, '\0'};
-png_byte FARDATA png_IDAT[5] = { 73,  68,  65,  84, '\0'};
-png_byte FARDATA png_IEND[5] = { 73,  69,  78,  68, '\0'};
-png_byte FARDATA png_PLTE[5] = { 80,  76,  84,  69, '\0'};
-png_byte FARDATA png_bKGD[5] = { 98,  75,  71,  68, '\0'};
-png_byte FARDATA png_cHRM[5] = { 99,  72,  82,  77, '\0'};
-png_byte FARDATA png_gAMA[5] = {103,  65,  77,  65, '\0'};
-png_byte FARDATA png_hIST[5] = {104,  73,  83,  84, '\0'};
-png_byte FARDATA png_oFFs[5] = {111,  70,  70, 115, '\0'};
-png_byte FARDATA png_pCAL[5] = {112,  67,  65,  76, '\0'};
-png_byte FARDATA png_pHYs[5] = {112,  72,  89, 115, '\0'};
-png_byte FARDATA png_sBIT[5] = {115,  66,  73,  84, '\0'};
-png_byte FARDATA png_sRGB[5] = {115,  82,  71,  66, '\0'};
-png_byte FARDATA png_tEXt[5] = {116,  69,  88, 116, '\0'};
-png_byte FARDATA png_tIME[5] = {116,  73,  77,  69, '\0'};
-png_byte FARDATA png_tRNS[5] = {116,  82,  78,  83, '\0'};
-png_byte FARDATA png_zTXt[5] = {122,  84,  88, 116, '\0'};
+/* Invoke global declarations for constant strings for known chunk types */
+PNG_IHDR;
+PNG_IDAT;
+PNG_IEND;
+PNG_PLTE;
+PNG_bKGD;
+PNG_cHRM;
+PNG_gAMA;
+PNG_hIST;
+PNG_oFFs;
+PNG_pCAL;
+PNG_pHYs;
+PNG_sBIT;
+PNG_sRGB;
+PNG_tEXt;
+PNG_tIME;
+PNG_tRNS;
+PNG_zTXt;
 
 /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
 
@@ -370,15 +363,15 @@
 {
    const png_byte png_sig_numbers[9] = {137, 80, 78, 71, 13, 10, 26, 10, 0};
    if (png_ptr == NULL) /* silence compiler warning */
-     return ((png_bytep) strdup(png_sig_numbers));
-   return ((png_bytep) strdup(png_sig_numbers));
+     return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
+   return ((png_bytep) strdup((png_const_charp)png_sig_numbers));
 }
 
 png_charp
 png_get_copyright(png_structp png_ptr)
 {
    if (png_ptr != NULL || png_ptr == NULL)  /* silence compiler warning */
-   return ("\n libpng version 1.0.5c - November 27, 1999\n\
+   return ("\n libpng version 1.0.5d - November 29, 1999\n\
    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n\
    Copyright (c) 1996, 1997 Andreas Dilger\n\
    Copyright (c) 1998, 1999 Glenn Randers-Pehrson\n");
@@ -396,8 +389,8 @@
 {
    /* Version of *.c files used when building libpng */
    if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
-      return("1.0.5c");
-   return("1.0.5c");
+      return("1.0.5d");
+   return("1.0.5d");
 }
 
 png_charp
@@ -421,8 +414,8 @@
 /* Generate a compiler error if there is an old png.h in the search path. */
 void
 png_check_version
-   (version_1_0_5c png_h_is_not_version_1_0_5c)
+   (version_1_0_5d png_h_is_not_version_1_0_5d)
 {
-   if(png_h_is_not_version_1_0_5c == NULL)
+   if(png_h_is_not_version_1_0_5d == NULL)
      return;
 }
diff --git a/png.h b/png.h
index 3b67afa..9d1bc58 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.0.5c - November 27, 1999
+ * libpng version 1.0.5d - November 29, 1999
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
  * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -9,19 +9,19 @@
  * Authors and maintainers:
  *  libpng versions 0.71, May 1995, through 0.89c, May 1996: Guy Schalnat
  *  libpng versions 0.90, December 1996, through 0.96, May 1997: Andreas Dilger
- *  libpng versions 0.97, January 1998, through 1.0.5c - November 27, 1999: Glenn
+ *  libpng versions 0.97, January 1998, through 1.0.5d - November 29, 1999: Glenn
  *  See also "Contributing Authors", below.
  *
  * Y2K compliance in libpng:
  * =========================
  *    
- *    November 27, 1999
+ *    November 29, 1999
  *    
  *    Since the PNG Development group is an ad-hoc body, we can't make
  *    an official declaration.
  *    
  *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.0.5c are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.0.5d are Y2K compliant.  It is my belief that earlier
  *    versions were also Y2K compliant.
  *    
  *    Libpng only has three year fields.  One is a 2-byte unsigned integer
@@ -122,7 +122,7 @@
  * Copyright (c) 1996, 1997 Andreas Dilger
  * (libpng versions 0.90, December 1996, through 0.96, May 1997)
  * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
- * (libpng versions 0.97, January 1998, through 1.0.5c, November 27, 1999)
+ * (libpng versions 0.97, January 1998, through 1.0.5d, November 29, 1999)
  *
  * For the purposes of this copyright and license, "Contributing Authors"
  * is defined as the following set of individuals:
@@ -222,7 +222,7 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.0.5c"
+#define PNG_LIBPNG_VER_STRING "1.0.5d"
 
 /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
  * We must not include leading zeros.
@@ -238,24 +238,24 @@
 /* Version information for C files, stored in png.c.  This had better match
  * the version above.
  */
-#ifdef PNG_GLOBAL_ARRAYS
-extern char png_libpng_ver[12];   /* need room for 99.99.99aa */
+#ifdef PNG_USE_GLOBAL_ARRAYS
+PNG_EXPORT_VAR (char) png_libpng_ver[12];   /* need room for 99.99.99aa */
 #else
 #define png_libpng_ver png_get_header_ver(NULL)
 #endif
 
-#ifdef PNG_GLOBAL_ARRAYS
+#ifdef PNG_USE_GLOBAL_ARRAYS
 /* This was removed in version 1.0.5c */
 /* Structures to facilitate easy interlacing.  See png.c for more details */
-extern int FARDATA png_pass_start[7];
-extern int FARDATA png_pass_inc[7];
-extern int FARDATA png_pass_ystart[7];
-extern int FARDATA png_pass_yinc[7];
-extern int FARDATA png_pass_mask[7];
-extern int FARDATA png_pass_dsp_mask[7];
+PNG_EXPORT_VAR (int FARDATA) png_pass_start[7];
+PNG_EXPORT_VAR (int FARDATA) png_pass_inc[7];
+PNG_EXPORT_VAR (int FARDATA) png_pass_ystart[7];
+PNG_EXPORT_VAR (int FARDATA) png_pass_yinc[7];
+PNG_EXPORT_VAR (int FARDATA) png_pass_mask[7];
+PNG_EXPORT_VAR (int FARDATA) png_pass_dsp_mask[7];
 /* These aren't currently used.  If you need them, see png.c for more details
-extern int FARDATA png_pass_width[7];
-extern int FARDATA png_pass_height[7];
+PNG_EXPORT_VAR (int FARDATA) png_pass_width[7];
+PNG_EXPORT_VAR (int FARDATA) png_pass_height[7];
 */
 #endif
 
@@ -827,9 +827,9 @@
 };
 
 /* This prevents a compiler error in png_get_copyright() in png.c if png.c
-and png.h are both at * version 1.0.5c
+and png.h are both at * version 1.0.5d
  */
-typedef png_structp version_1_0_5c;
+typedef png_structp version_1_0_5d;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -1649,7 +1649,7 @@
 extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
 extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
 
-#define PNG_HEADER_VERSION_STRING " libpng version 1.0.5c - November 27, 1999 (header)\n"
+#define PNG_HEADER_VERSION_STRING " libpng version 1.0.5d - November 29, 1999 (header)\n"
 
 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
 /* With these routines we avoid an integer divide, which will be slower on
@@ -1798,36 +1798,53 @@
 /* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
 #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
 /* place to hold the signature string for a PNG file. */
-#ifdef PNG_GLOBAL_ARRAYS
-   extern png_byte FARDATA png_sig[8];
+#ifdef PNG_USE_GLOBAL_ARRAYS
+   PNG_EXPORT_VAR (png_byte FARDATA) png_sig[8];
 #else
 #define png_sig png_sig_bytes(NULL)
 #endif
 
-#ifdef PNG_GLOBAL_ARRAYS
 /* Constant strings for known chunk types.  If you need to add a chunk,
- * add a string holding the name here.  See png.c for more details.  We
- * can't selectively include these, since we still check for chunk in the
- * wrong locations with these labels.
+ * define the name here, and add an invocation of the macro in png.c and
+ * wherever it's needed.
  */
-extern png_byte FARDATA png_IHDR[5];
-extern png_byte FARDATA png_IDAT[5];
-extern png_byte FARDATA png_IEND[5];
-extern png_byte FARDATA png_PLTE[5];
-extern png_byte FARDATA png_bKGD[5];
-extern png_byte FARDATA png_cHRM[5];
-extern png_byte FARDATA png_gAMA[5];
-extern png_byte FARDATA png_hIST[5];
-extern png_byte FARDATA png_oFFs[5];
-extern png_byte FARDATA png_pCAL[5];
-extern png_byte FARDATA png_pHYs[5];
-extern png_byte FARDATA png_sBIT[5];
-extern png_byte FARDATA png_sRGB[5];
-extern png_byte FARDATA png_tEXt[5];
-extern png_byte FARDATA png_tIME[5];
-extern png_byte FARDATA png_tRNS[5];
-extern png_byte FARDATA png_zTXt[5];
-#endif /* PNG_GLOBAL_ARRAYS */
+#define PNG_IHDR const png_byte png_IHDR[5] = { 73,  72,  68,  82, '\0'}
+#define PNG_IDAT const png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'}
+#define PNG_IEND const png_byte png_IEND[5] = { 73,  69,  78,  68, '\0'}
+#define PNG_PLTE const png_byte png_PLTE[5] = { 80,  76,  84,  69, '\0'}
+#define PNG_bKGD const png_byte png_bKGD[5] = { 98,  75,  71,  68, '\0'}
+#define PNG_cHRM const png_byte png_cHRM[5] = { 99,  72,  82,  77, '\0'}
+#define PNG_gAMA const png_byte png_gAMA[5] = {103,  65,  77,  65, '\0'}
+#define PNG_hIST const png_byte png_hIST[5] = {104,  73,  83,  84, '\0'}
+#define PNG_oFFs const png_byte png_oFFs[5] = {111,  70,  70, 115, '\0'}
+#define PNG_pCAL const png_byte png_pCAL[5] = {112,  67,  65,  76, '\0'}
+#define PNG_pHYs const png_byte png_pHYs[5] = {112,  72,  89, 115, '\0'}
+#define PNG_sBIT const png_byte png_sBIT[5] = {115,  66,  73,  84, '\0'}
+#define PNG_sRGB const png_byte png_sRGB[5] = {115,  82,  71,  66, '\0'}
+#define PNG_tEXt const png_byte png_tEXt[5] = {116,  69,  88, 116, '\0'}
+#define PNG_tIME const png_byte png_tIME[5] = {116,  73,  77,  69, '\0'}
+#define PNG_tRNS const png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'}
+#define PNG_zTXt const png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'}
+
+#ifdef PNG_USE_GLOBAL_ARRAYS
+PNG_EXPORT_VAR (const png_byte FARDATA) png_IHDR[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_IDAT[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_IEND[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_PLTE[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_bKGD[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_cHRM[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_gAMA[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_hIST[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_oFFs[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_pCAL[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_pHYs[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_sBIT[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_sRGB[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_tEXt[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_tIME[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_tRNS[5];
+PNG_EXPORT_VAR (const png_byte FARDATA) png_zTXt[5];
+#endif /* PNG_USE_GLOBAL_ARRAYS */
 
 #endif /* PNG_NO_EXTERN */
 
diff --git a/pngasmrd.h b/pngasmrd.h
index 50b3472..1525c29 100644
--- a/pngasmrd.h
+++ b/pngasmrd.h
@@ -1,6 +1,6 @@
 /* pngasmrd.h - assembler version of utilities to read a PNG file
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1999 Glenn Randers-Pehrson
  *
@@ -21,7 +21,7 @@
 /* Set this in the makefile for gcc on Pentium, not in pngconf.h */
 #ifdef PNG_USE_PNGGCCRD
 /* Platform must be Pentium.  Makefile must assemble and load pnggccrd.c
- * (not available in libpng 1.0.5c).
+ * (not available in libpng 1.0.5d).
  * MMX will be detected at run time and used if present.
  */
 #define PNG_HAVE_ASSEMBLER_COMBINE_ROW
diff --git a/pngconf.h b/pngconf.h
index 089b15f..85cb792 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -422,8 +422,10 @@
  * They are no longer used in libpng itself, since version 1.0.5c,
  * but might be required for some pre-1.0.5c applications.
  */
-#ifndef PNG_NO_GLOBAL_ARRAYS
-#define PNG_GLOBAL_ARRAYS
+#ifdef PNG_NO_GLOBAL_ARRAYS
+#define PNG_USE_LOCAL_ARRAYS
+#else
+#define PNG_USE_GLOBAL_ARRAYS
 #endif
 
 /* These are currently experimental features, define them if you want */
@@ -692,6 +694,28 @@
 #  define PNG_EXPORT(type,symbol) type symbol
 #endif
 
+#if defined(__MINGW32__) || defined(__CYGWIN32__)
+#  define PNG_ATTR_DLLIMP
+#endif
+
+#ifndef PNG_EXPORT_VAR
+#  ifdef PNG_DECL_DLLEXP
+#    define PNG_EXPORT_VAR(type) extern __declspec(dllexport) type
+#  endif
+#  ifdef PNG_ATTR_DLLEXP
+#    define PNG_EXPORT_VAR(type) extern type __attribute__((dllexport)) 
+#  endif
+#  ifdef PNG_DECL_DLLIMP
+#    define PNG_EXPORT_VAR(type) extern __declspec(dllimport) type
+#  endif
+#  ifdef PNG_ATTR_DLLIMP
+#    define PNG_EXPORT_VAR(type) extern type __attribute__((dllimport))
+#  endif
+#endif
+
+#ifndef PNG_EXPORT_VAR
+#    define PNG_EXPORT_VAR(type) extern type
+#endif
 
 /* User may want to use these so not in PNG_INTERNAL. Any library functions
  * that are passed far data must be model independent.
diff --git a/pngerror.c b/pngerror.c
index 6278b29..1bf444e 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngget.c b/pngget.c
index 62486af..48cf9ea 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngmem.c b/pngmem.c
index 15d5344..3e731fa 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngpread.c b/pngpread.c
index b6fff68..e5526ef 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -116,7 +116,51 @@
 void
 png_push_read_chunk(png_structp png_ptr, png_infop info_ptr)
 {
-#include "pngtypes.h"
+#ifdef PNG_USE_LOCAL_ARRAYS
+      PNG_IHDR;
+      PNG_IDAT;
+      PNG_IEND;
+      PNG_PLTE;
+#if defined(PNG_READ_bKGD_SUPPORTED)
+      PNG_bKGD;
+#endif
+#if defined(PNG_READ_cHRM_SUPPORTED)
+      PNG_cHRM;
+#endif
+#if defined(PNG_READ_gAMA_SUPPORTED)
+      PNG_gAMA;
+#endif
+#if defined(PNG_READ_hIST_SUPPORTED)
+      PNG_hIST;
+#endif
+#if defined(PNG_READ_oFFs_SUPPORTED)
+      PNG_oFFs;
+#endif
+#if defined(PNG_READ_pCAL_SUPPORTED)
+      PNG_pCAL;
+#endif
+#if defined(PNG_READ_pHYs_SUPPORTED)
+      PNG_pHYs;
+#endif
+#if defined(PNG_READ_sBIT_SUPPORTED)
+      PNG_sBIT;
+#endif
+#if defined(PNG_READ_sRGB_SUPPORTED)
+      PNG_sRGB;
+#endif
+#if defined(PNG_READ_tEXt_SUPPORTED)
+      PNG_tEXt;
+#endif
+#if defined(PNG_READ_tIME_SUPPORTED)
+      PNG_tIME;
+#endif
+#if defined(PNG_READ_tRNS_SUPPORTED)
+      PNG_tRNS;
+#endif
+#if defined(PNG_READ_zTXt_SUPPORTED)
+      PNG_zTXt;
+#endif
+#endif /* PNG_USE_LOCAL_ARRAYS */
    /* First we make sure we have enough data for the 4 byte chunk name
     * and the 4 byte chunk length before proceeding with decoding the
     * chunk data.  To fully decode each of these chunks, we also make
@@ -497,7 +541,9 @@
 void
 png_push_read_IDAT(png_structp png_ptr)
 {
-   const png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_IDAT;
+#endif
    if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
    {
       png_byte chunk_length[4];
@@ -769,6 +815,7 @@
 void
 png_read_push_finish_row(png_structp png_ptr)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    
    /* start of interlace block */
@@ -792,6 +839,7 @@
     * it, uncomment it here and in png.h
    const int png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
    */
+#endif
    
    png_ptr->row_number++;
    if (png_ptr->row_number < png_ptr->num_rows)
@@ -1141,7 +1189,9 @@
 png_progressive_combine_row (png_structp png_ptr,
    png_bytep old_row, png_bytep new_row)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
+#endif
    if (new_row != NULL)    /* new_row must == png_ptr->row_buf here. */
       png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]);
 }
diff --git a/pngread.c b/pngread.c
index 45fc216..9b8e324 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -156,7 +156,6 @@
 void
 png_read_info(png_structp png_ptr, png_infop info_ptr)
 {
-#include "pngtypes.h"
    png_debug(1, "in png_read_info\n");
    /* save jump buffer and error functions */
    /* If we haven't checked all of the PNG signature bytes, do so now. */
@@ -180,6 +179,51 @@
 
    for(;;)
    {
+#ifdef PNG_USE_LOCAL_ARRAYS
+      PNG_IHDR;
+      PNG_IDAT;
+      PNG_IEND;
+      PNG_PLTE;
+#if defined(PNG_READ_bKGD_SUPPORTED)
+      PNG_bKGD;
+#endif
+#if defined(PNG_READ_cHRM_SUPPORTED)
+      PNG_cHRM;
+#endif
+#if defined(PNG_READ_gAMA_SUPPORTED)
+      PNG_gAMA;
+#endif
+#if defined(PNG_READ_hIST_SUPPORTED)
+      PNG_hIST;
+#endif
+#if defined(PNG_READ_oFFs_SUPPORTED)
+      PNG_oFFs;
+#endif
+#if defined(PNG_READ_pCAL_SUPPORTED)
+      PNG_pCAL;
+#endif
+#if defined(PNG_READ_pHYs_SUPPORTED)
+      PNG_pHYs;
+#endif
+#if defined(PNG_READ_sBIT_SUPPORTED)
+      PNG_sBIT;
+#endif
+#if defined(PNG_READ_sRGB_SUPPORTED)
+      PNG_sRGB;
+#endif
+#if defined(PNG_READ_tEXt_SUPPORTED)
+      PNG_tEXt;
+#endif
+#if defined(PNG_READ_tIME_SUPPORTED)
+      PNG_tIME;
+#endif
+#if defined(PNG_READ_tRNS_SUPPORTED)
+      PNG_tRNS;
+#endif
+#if defined(PNG_READ_zTXt_SUPPORTED)
+      PNG_zTXt;
+#endif
+#endif /* PNG_GLOBAL_ARRAYS */
       png_byte chunk_length[4];
       png_uint_32 length;
 
@@ -298,9 +342,11 @@
 void
 png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
 {
-   const png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_IDAT;
    const int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
    const int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
+#endif
    int ret;
    png_debug2(1, "in png_read_row (row %d, pass %d)\n",
       png_ptr->row_number, png_ptr->pass);
@@ -533,7 +579,7 @@
  * not called png_set_interlace_handling(), the display_row buffer will
  * be ignored, so pass NULL to it.
  *
- * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5c.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5d.
  */
 
 void
@@ -582,7 +628,7 @@
  * only call this function once.  If you desire to have an image for
  * each pass of a interlaced image, use png_read_rows() instead.
  *
- * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5c.
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.5d.
  */
 void
 png_read_image(png_structp png_ptr, png_bytepp image)
@@ -625,7 +671,6 @@
 void
 png_read_end(png_structp png_ptr, png_infop info_ptr)
 {
-#include "pngtypes.h"
    png_byte chunk_length[4];
    png_uint_32 length;
 
@@ -635,6 +680,52 @@
 
    do
    {
+#ifdef PNG_USE_LOCAL_ARRAYS
+      PNG_IHDR;
+      PNG_IDAT;
+      PNG_IEND;
+      PNG_PLTE;
+#if defined(PNG_READ_bKGD_SUPPORTED)
+      PNG_bKGD;
+#endif
+#if defined(PNG_READ_cHRM_SUPPORTED)
+      PNG_cHRM;
+#endif
+#if defined(PNG_READ_gAMA_SUPPORTED)
+      PNG_gAMA;
+#endif
+#if defined(PNG_READ_hIST_SUPPORTED)
+      PNG_hIST;
+#endif
+#if defined(PNG_READ_oFFs_SUPPORTED)
+      PNG_oFFs;
+#endif
+#if defined(PNG_READ_pCAL_SUPPORTED)
+      PNG_pCAL;
+#endif
+#if defined(PNG_READ_pHYs_SUPPORTED)
+      PNG_pHYs;
+#endif
+#if defined(PNG_READ_sBIT_SUPPORTED)
+      PNG_sBIT;
+#endif
+#if defined(PNG_READ_sRGB_SUPPORTED)
+      PNG_sRGB;
+#endif
+#if defined(PNG_READ_tEXt_SUPPORTED)
+      PNG_tEXt;
+#endif
+#if defined(PNG_READ_tIME_SUPPORTED)
+      PNG_tIME;
+#endif
+#if defined(PNG_READ_tRNS_SUPPORTED)
+      PNG_tRNS;
+#endif
+#if defined(PNG_READ_zTXt_SUPPORTED)
+      PNG_zTXt;
+#endif
+#endif /* PNG_GLOBAL_ARRAYS */
+
       png_read_data(png_ptr, chunk_length, 4);
       length = png_get_uint_32(chunk_length);
 
diff --git a/pngrio.c b/pngrio.c
index 7aba196..cf7ed17 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngrtran.c b/pngrtran.c
index edaa020..8942c20 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngrutil.c b/pngrutil.c
index 270a72b..3a51f27 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -1713,10 +1713,12 @@
    (png_row_infop row_info, png_bytep row, int pass,
    png_uint_32 transformations)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    
    /* offset to next interlace block */
    const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+#endif
    
    png_debug(1,"in png_do_read_interlace\n");
    if (row != NULL && row_info != NULL)
@@ -2056,6 +2058,7 @@
 void
 png_read_finish_row(png_structp png_ptr)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    
    /* start of interlace block */
@@ -2069,6 +2072,7 @@
    
    /* offset to next interlace block in the y direction */
    const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+#endif
    
    png_debug(1, "in png_read_finish_row\n");
    png_ptr->row_number++;
@@ -2110,7 +2114,9 @@
 
    if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
    {
-      const png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+      PNG_IDAT;
+#endif
       char extra;
       int ret;
 
@@ -2174,6 +2180,7 @@
 void
 png_read_start_row(png_structp png_ptr)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    
    /* start of interlace block */
@@ -2187,6 +2194,7 @@
    
    /* offset to next interlace block in the y direction */
    const int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+#endif
    
    int max_pixel_depth;
    png_uint_32 row_bytes;
diff --git a/pngset.c b/pngset.c
index 8afe6d6..d31f443 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngtest.c b/pngtest.c
index f29b325..1dc2276 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -1223,7 +1223,7 @@
 /* Generate a compiler error if there is an old png.h in the search path. */
 void
 png_check_pngtest_version
-   (version_1_0_5c png_h_is_not_version_1_0_5c)
+   (version_1_0_5d png_h_is_not_version_1_0_5d)
 {
-   if(png_h_is_not_version_1_0_5c == NULL) return;
+   if(png_h_is_not_version_1_0_5d == NULL) return;
 }
diff --git a/pngtrans.c b/pngtrans.c
index 92d2c36..f6458d5 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,7 +1,7 @@
 
 /* pngtrans.c - transforms the data in a row (used by both readers and writers)
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngtypes.h b/pngtypes.h
index 6be6862..8b78f87 100644
--- a/pngtypes.h
+++ b/pngtypes.h
@@ -1,6 +1,6 @@
 /* pngtypes.h - array of chunk-types for libpng
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -8,28 +8,24 @@
  */
 
 /* Constant strings for known chunk types.  If you need to add a chunk,
- * add a string holding the name here.
- *
- * We can't selectively include these, since we still check for chunk in
- * the wrong locations with these labels. (I'm not exactly sure what
- * this comment means.  I inherited it from libpng-0.96 -- glennrp)
+ * define the string in png.h and invoke it here.
  */
 
-const png_byte png_IHDR[5] = { 73,  72,  68,  82, '\0'};
-const png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'};
-const png_byte png_IEND[5] = { 73,  69,  78,  68, '\0'};
-const png_byte png_PLTE[5] = { 80,  76,  84,  69, '\0'};
-const png_byte png_bKGD[5] = { 98,  75,  71,  68, '\0'};
-const png_byte png_cHRM[5] = { 99,  72,  82,  77, '\0'};
-const png_byte png_gAMA[5] = {103,  65,  77,  65, '\0'};
-const png_byte png_hIST[5] = {104,  73,  83,  84, '\0'};
-const png_byte png_oFFs[5] = {111,  70,  70, 115, '\0'};
-const png_byte png_pCAL[5] = {112,  67,  65,  76, '\0'};
-const png_byte png_pHYs[5] = {112,  72,  89, 115, '\0'};
-const png_byte png_sBIT[5] = {115,  66,  73,  84, '\0'};
-const png_byte png_sRGB[5] = {115,  82,  71,  66, '\0'};
-const png_byte png_tEXt[5] = {116,  69,  88, 116, '\0'};
-const png_byte png_tIME[5] = {116,  73,  77,  69, '\0'};
-const png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'};
-const png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'};
+PNG_IHDR;
+PNG_IDAT;
+PNG_IEND;
+PNG_PLTE;
+PNG_bKGD;
+PNG_cHRM;
+PNG_gAMA;
+PNG_hIST;
+PNG_oFFs;
+PNG_pCAL;
+PNG_pHYs;
+PNG_sBIT;
+PNG_sRGB;
+PNG_tEXt;
+PNG_tIME;
+PNG_tRNS;
+PNG_zTXt;
 
diff --git a/pngvcrd.c b/pngvcrd.c
index ae48a78..a20a783 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998, Intel Corporation
  * Copyright (c) 1998, 1999 Glenn Randers-Pehrson
@@ -96,7 +96,9 @@
 void
 png_combine_row(png_structp png_ptr, png_bytep row, int mask)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+#endif
 #ifdef DISABLE_PNGVCRD_COMBINE
    int save_mmx_supported = mmx_supported;
 #endif
@@ -967,7 +969,9 @@
 png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
    png_uint_32 transformations)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    const int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+#endif
 #ifdef DISABLE_PNGVCRD_INTERLACE
    int save_mmx_supported = mmx_supported;
 #endif
diff --git a/pngwio.c b/pngwio.c
index 0631a1d..c55fff3 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwrite.c b/pngwrite.c
index f7e8535..bd7c7c3 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwtran.c b/pngwtran.c
index 2098534..f891471 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,7 +1,7 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
diff --git a/pngwutil.c b/pngwutil.c
index a34201e..2b08369 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng 1.0.5c - November 27, 1999
+ * libpng 1.0.5d - November 29, 1999
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  * Copyright (c) 1996, 1997 Andreas Dilger
@@ -142,7 +142,9 @@
    int bit_depth, int color_type, int compression_type, int filter_type,
    int interlace_type)
 {
-   const png_byte png_IHDR[5] = { 73,  72,  68,  82, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_IHDR;
+#endif
    png_byte buf[13]; /* buffer to store the IHDR info */
 
    png_debug(1, "in png_write_IHDR\n");
@@ -281,7 +283,9 @@
 void
 png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal)
 {
-   const png_byte png_PLTE[5] = { 80,  76,  84,  69, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_PLTE;
+#endif
    png_uint_32 i;
    png_colorp pal_ptr;
    png_byte buf[3];
@@ -323,7 +327,9 @@
 void
 png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
 {
-   const png_byte png_IDAT[5] = { 73,  68,  65,  84, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_IDAT;
+#endif
    png_debug(1, "in png_write_IDAT\n");
    png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length);
    png_ptr->mode |= PNG_HAVE_IDAT;
@@ -333,7 +339,9 @@
 void
 png_write_IEND(png_structp png_ptr)
 {
-   const png_byte png_IEND[5] = { 73,  69,  78,  68, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_IEND;
+#endif
    png_debug(1, "in png_write_IEND\n");
    png_write_chunk(png_ptr, (png_bytep)png_IEND, NULL, (png_size_t)0);
    png_ptr->mode |= PNG_HAVE_IEND;
@@ -344,7 +352,9 @@
 void
 png_write_gAMA(png_structp png_ptr, double file_gamma)
 {
-   const png_byte png_gAMA[5] = {103,  65,  77,  65, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_gAMA;
+#endif
    png_uint_32 igamma;
    png_byte buf[4];
 
@@ -361,7 +371,9 @@
 void
 png_write_sRGB(png_structp png_ptr, int srgb_intent)
 {
-   const png_byte png_sRGB[5] = {115,  82,  71,  66, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_sRGB;
+#endif
    png_byte buf[1];
 
    png_debug(1, "in png_write_sRGB\n");
@@ -378,7 +390,9 @@
 void
 png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type)
 {
-   const png_byte png_sBIT[5] = {115,  66,  73,  84, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_sBIT;
+#endif
    png_byte buf[4];
    png_size_t size;
 
@@ -434,7 +448,9 @@
    double red_x, double red_y, double green_x, double green_y,
    double blue_x, double blue_y)
 {
-   const png_byte png_cHRM[5] = { 99,  72,  82,  77, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_cHRM;
+#endif
    png_uint_32 itemp;
    png_byte buf[32];
 
@@ -494,7 +510,9 @@
 png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran,
    int num_trans, int color_type)
 {
-   const png_byte png_tRNS[5] = {116,  82,  78,  83, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_tRNS;
+#endif
    png_byte buf[6];
 
    png_debug(1, "in png_write_tRNS\n");
@@ -534,7 +552,9 @@
 void
 png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type)
 {
-   const png_byte png_bKGD[5] = { 98,  75,  71,  68, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_bKGD;
+#endif
    png_byte buf[6];
 
    png_debug(1, "in png_write_bKGD\n");
@@ -573,7 +593,9 @@
 void
 png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist)
 {
-   const png_byte png_hIST[5] = {104,  73,  83,  84, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_hIST;
+#endif
    int i;
    png_byte buf[3];
 
@@ -722,7 +744,9 @@
 png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text,
    png_size_t text_len)
 {
-   const png_byte png_tEXt[5] = {116,  69,  88, 116, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_tEXt;
+#endif
    png_size_t key_len;
    png_charp new_key;
 
@@ -758,7 +782,9 @@
 png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
    png_size_t text_len, int compression)
 {
-   const png_byte png_zTXt[5] = {122,  84,  88, 116, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_zTXt;
+#endif
    png_size_t key_len;
    char buf[1];
    png_charp new_key;
@@ -963,7 +989,9 @@
    png_uint_32 y_offset,
    int unit_type)
 {
-   const png_byte png_oFFs[5] = {111,  70,  70, 115, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_oFFs;
+#endif
    png_byte buf[9];
 
    png_debug(1, "in png_write_oFFs\n");
@@ -984,7 +1012,9 @@
 png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0,
    png_int_32 X1, int type, int nparams, png_charp units, png_charpp params)
 {
-   const png_byte png_pCAL[5] = {112,  67,  65,  76, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_pCAL;
+#endif
    png_size_t purpose_len, units_len, total_len;
    png_uint_32p params_len;
    png_byte buf[10];
@@ -1043,7 +1073,9 @@
    png_uint_32 y_pixels_per_unit,
    int unit_type)
 {
-   const png_byte png_pHYs[5] = {112,  72,  89, 115, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_pHYs;
+#endif
    png_byte buf[9];
 
    png_debug(1, "in png_write_pHYs\n");
@@ -1065,7 +1097,9 @@
 void
 png_write_tIME(png_structp png_ptr, png_timep mod_time)
 {
-   const png_byte png_tIME[5] = {116,  73,  77,  69, '\0'};
+#ifdef PNG_USE_LOCAL_ARRAYS
+   PNG_tIME;
+#endif
    png_byte buf[7];
 
    png_debug(1, "in png_write_tIME\n");
@@ -1092,6 +1126,7 @@
 void
 png_write_start_row(png_structp png_ptr)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    
    /* start of interlace block */
@@ -1105,6 +1140,7 @@
    
    /* offset to next interlace block in the y direction */
    int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+#endif
    
    png_size_t buf_size;
 
@@ -1184,6 +1220,7 @@
 void
 png_write_finish_row(png_structp png_ptr)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    
    /* start of interlace block */
@@ -1197,6 +1234,7 @@
    
    /* offset to next interlace block in the y direction */
    int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+#endif
    
    int ret;
 
@@ -1296,6 +1334,7 @@
 void
 png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
 {
+#ifdef PNG_USE_LOCAL_ARRAYS
    /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
    
    /* start of interlace block */
@@ -1303,6 +1342,7 @@
    
    /* offset to next interlace block */
    int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+#endif
    
    png_debug(1, "in png_do_write_interlace\n");
    /* we don't have to do anything on the last pass (6) */
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index 2c0bba2..b4d035e 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -31,7 +31,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.5c
+PNGMIN = 1.0.5d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 # where make install puts libpng.a, libpng.so*, and png.h
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index c0ef1d1..5baafde 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -14,7 +14,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.5c
+PNGMIN = 1.0.5d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=cc
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 2ecbfc0..c85d01e 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -34,7 +34,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.5c
+PNGMIN = 1.0.5d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index 795a8a8..fc572af 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -25,7 +25,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.5c
+PNGMIN = 1.0.5d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index d941e64..054cd55 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -37,7 +37,7 @@
 # read libpng.txt or png.h to see why PNGMAJ is 2.  You should not
 # have to change it.
 PNGMAJ = 2
-PNGMIN = 1.0.5c
+PNGMIN = 1.0.5d
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
index e208349..984137d 100644
--- a/scripts/pngdef.pas
+++ b/scripts/pngdef.pas
@@ -3,7 +3,7 @@
 interface
 
 const
-  PNG_LIBPNG_VER_STRING = '1.0.5c';
+  PNG_LIBPNG_VER_STRING = '1.0.5d';
   PNG_LIBPNG_VER        =  10006;
 
 type