Imported from libpng-0.99k.tar
diff --git a/CHANGES b/CHANGES
index 100e02b..721144b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -262,3 +262,8 @@
 version 1.00 [March 7, 1998]
    Changed several typedefs in pngrutil.c
    Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik)
+   replaced "while(1)" with "for(;;)"
+   added PNGARG() to prototypes in pngtest.c and removed some prototypes
+   updated some of the makefiles (Tom Lane)
+   changed some typedefs (s_start, etc.) in pngrutil.c
+   fixed dimensions of "short_months" array in pngwrite.c
diff --git a/TODO b/TODO
index 245e602..21f963a 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,6 @@
 TODO - list of things to do for libpng
 
+fix problem with C++ and EXTERN "C"
 add "grayscale->palette" transformation and "palette->grayscale" detection
 improved dithering
 multi-lingual error and warning message support
diff --git a/pngmem.c b/pngmem.c
index a1b7677..5099920 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -19,11 +19,11 @@
 /* The following "hides" PNG_MALLOC and PNG_FREE thus allowing the pngtest
    application to put a wrapper on top of them. */
 #ifdef PNGTEST_MEMORY_DEBUG
-   #define PNG_MALLOC png_debug_malloc
-   #define PNG_FREE   png_debug_free
+#define PNG_MALLOC png_debug_malloc
+#define PNG_FREE   png_debug_free
 #else
-   #define PNG_MALLOC png_malloc
-   #define PNG_FREE   png_free
+#define PNG_MALLOC png_malloc
+#define PNG_FREE   png_free
 #endif
 
 /* Borland DOS special memory handler */
diff --git a/pngpread.c b/pngpread.c
index 1b9fcf4..1723fd1 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -591,7 +591,7 @@
 
    png_ptr->zstream.next_in = buffer;
    png_ptr->zstream.avail_in = (uInt)buffer_length;
-   while(1)
+   for(;;)
    {
       ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
       if (ret == Z_STREAM_END)
diff --git a/pngread.c b/pngread.c
index 616ec98..b1a1f8e 100644
--- a/pngread.c
+++ b/pngread.c
@@ -154,7 +154,7 @@
       }
    }
 
-   while (1)
+   for(;;)
    {
       png_byte chunk_length[4];
       png_uint_32 length;
diff --git a/pngrutil.c b/pngrutil.c
index b275e7e..a21a03f 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -2059,7 +2059,7 @@
 
       png_ptr->zstream.next_out = (Byte *)&extra;
       png_ptr->zstream.avail_out = (uInt)1;
-      do
+      for(;;)
       {
          if (!(png_ptr->zstream.avail_in))
          {
@@ -2102,7 +2102,7 @@
          if (!(png_ptr->zstream.avail_out))
             png_error(png_ptr, "Extra compressed data");
 
-      } while (1);
+      }
       png_ptr->zstream.avail_out = 0;
    }
 
diff --git a/pngtest.c b/pngtest.c
index 9481427..700ad74 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -32,12 +32,12 @@
 
 /* Makes pngtest verbose so we can find problems (needs to be before png.h) */
 #ifndef PNG_DEBUG
-#endif
 #define PNG_DEBUG 0
+#endif
 
 #include "png.h"
 
-int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname);
+int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname));
 
 #ifdef __TURBOC__
 #include <mem.h>
@@ -51,7 +51,7 @@
 static int status_pass=1;
 static int status_dots_requested=0;
 static int status_dots=1;
-void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
+
 void read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
 {
     if(png_ptr == NULL || row_number > 0x3fffffffL) return;
@@ -69,7 +69,7 @@
     }
     fprintf(stdout, "r");
 }
-void write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
+
 void write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
 {
     if(png_ptr == NULL || row_number > 0x3fffffffL || pass > 7) return;
@@ -83,10 +83,9 @@
    but merely count the black pixels) */
 
 static png_uint_32 black_pixels;
+
 void count_black_pixels(png_structp png_ptr, png_row_infop row_info,
-   png_bytep data);
-void count_black_pixels(png_structp png_ptr, png_row_infop row_info,
-   png_bytep data)
+		   png_bytep data)
 {
    png_bytep dp = data;
    if(png_ptr == NULL)return; 
@@ -180,8 +179,6 @@
    than changing the library. */
 #ifndef USE_FAR_KEYWORD
 static void
-png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
-static void
 png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
 {
    png_size_t check;
@@ -206,10 +203,8 @@
 #define NEAR_BUF_SIZE 1024
 #define MIN(a,b) (a <= b ? a : b)
  
-static void
-png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length);
-static void
-png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
+static void png_default_read_data(png_structp png_ptr, png_bytep data,
+   png_size_t length)
 {
    int check;
    png_byte *n_data;
@@ -250,10 +245,7 @@
 #endif /* USE_FAR_KEYWORD */
 
 #if defined(PNG_WRITE_FLUSH_SUPPORTED)
-static void
-png_default_flush(png_structp png_ptr);
-static void
-png_default_flush(png_structp png_ptr)
+static void png_default_flush(png_structp png_ptr)
 {
    FILE *io_ptr;
    io_ptr = (FILE *)CVT_PTR((png_ptr->io_ptr));
@@ -268,8 +260,6 @@
    than changing the library. */
 #ifndef USE_FAR_KEYWORD
 static void
-png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length);
-static void
 png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
 {
    png_uint_32 check;
@@ -290,8 +280,6 @@
 #define MIN(a,b) (a <= b ? a : b)
 
 static void
-png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length);
-static void
 png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
 {
    png_uint_32 check;
@@ -808,7 +796,7 @@
       return (1);
    }
 
-   while (1)
+   for(;;)
    {
       png_size_t num_in, num_out;
 
@@ -886,13 +874,13 @@
       not sure this matters, but it is nice to know, the first of these
       tests should be impossible because of the way the macros are set
       in pngconf.h */
-   #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
+#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
       fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n");
-   #endif
+#endif
    /* I think the following can happen. */
-   #if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K)
+#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K)
       fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n");
-   #endif
+#endif
 
    if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING))
    {
diff --git a/pngwrite.c b/pngwrite.c
index e7e1fb3..77bb90d 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -225,8 +225,9 @@
 png_charp
 png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
 {
-   const char *short_months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
-                                   "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
+   static const char *short_months[12][4] =
+	{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+	 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
 
    if (png_ptr->time_buffer == NULL)
    {
diff --git a/pngwutil.c b/pngwutil.c
index 6b971c8..04fb1de 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1383,10 +1383,10 @@
  * been specified by the application, and then writes the row out with the
  * chosen filter.
  */
-#define PNG_MAXSUM (png_uint_32)(~0x0UL >> 1)
+#define PNG_MAXSUM (~((png_uint_32)0) >> 1)
 #define PNG_HISHIFT 10
-#define PNG_LOMASK (png_uint_32)0xffffL
-#define PNG_HIMASK (png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT)
+#define PNG_LOMASK ((png_uint_32)0xffffL)
+#define PNG_HIMASK ((png_uint_32)(~PNG_LOMASK >> PNG_HISHIFT))
 void
 png_write_find_filter(png_structp png_ptr, png_row_infop row_info)
 {
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index 83260a7..328799a 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -29,7 +29,7 @@
 	$(RANLIB) $@
 
 pngtest: pngtest.o libpng.a
-	$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
+	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
diff --git a/scripts/makefile.dj2 b/scripts/makefile.dj2
index 8ad042e..e80f5cc 100644
--- a/scripts/makefile.dj2
+++ b/scripts/makefile.dj2
@@ -23,7 +23,7 @@
 	$(RANLIB) $@
 
 pngtest: pngtest.o libpng.a
-	$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
+	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 	coff2exe pngtest
 
 test: pngtest
diff --git a/scripts/makefile.knr b/scripts/makefile.knr
index 13f83db..81129ae 100644
--- a/scripts/makefile.knr
+++ b/scripts/makefile.knr
@@ -34,8 +34,8 @@
 	ar rc $@  $(OBJS)
 	$(RANLIB) $@
 
-pngtest: pngtest.o libpng.a ansi2knr
-	cc -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
+pngtest: pngtest.o libpng.a
+	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
diff --git a/scripts/makefile.lnx b/scripts/makefile.lnx
index 4547110..851eb82 100644
--- a/scripts/makefile.lnx
+++ b/scripts/makefile.lnx
@@ -56,7 +56,7 @@
 	ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
 
 libpng.so.$(PNGVER): $(OBJSDLL)
-	gcc -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
+	$(CC) -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
 	 $(OBJSDLL)
 
 pngtest: pngtest.o libpng.so
diff --git a/scripts/makefile.mip b/scripts/makefile.mip
index fa157a2..2b3cccd 100644
--- a/scripts/makefile.mip
+++ b/scripts/makefile.mip
@@ -24,7 +24,7 @@
 	$(RANLIB) $@
 
 pngtest: pngtest.o libpng.a
-	cc -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
+	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index cd980cd..965cf91 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -30,7 +30,7 @@
 	$(RANLIB) $@
 
 pngtest: pngtest.o libpng.a
-	$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
+	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
diff --git a/scripts/makefile.std b/scripts/makefile.std
index ebe000b..7cc6059 100644
--- a/scripts/makefile.std
+++ b/scripts/makefile.std
@@ -29,7 +29,7 @@
 	$(RANLIB) $@
 
 pngtest: pngtest.o libpng.a
-	$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
+	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
diff --git a/scripts/makefile.sun b/scripts/makefile.sun
index ccd0a28..975ca17 100644
--- a/scripts/makefile.sun
+++ b/scripts/makefile.sun
@@ -33,7 +33,7 @@
 	$(RANLIB) $@
 
 pngtest: pngtest.o libpng.a
-	$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
+	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest