$NetBSD: patch-af,v 1.4 2014/05/23 22:29:33 dholland Exp $

* Build fix for newer versions of "libpng".
* Build fix for 5.0 version of giflib.
* Further build fixes for giflib 5.1.

--- src/image.c.orig	2008-08-25 22:18:33.000000000 +0000
+++ src/image.c
@@ -6328,11 +6328,7 @@ png_image_p (object)
 
 #ifdef HAVE_PNG
 
-#if defined HAVE_LIBPNG_PNG_H
-# include <libpng/png.h>
-#else
 # include <png.h>
-#endif
 
 #ifdef HAVE_NTGUI
 /* PNG library details.  */
@@ -6427,7 +6423,11 @@ my_png_error (png_ptr, msg)
 {
   xassert (png_ptr != NULL);
   image_error ("PNG error: %s", build_string (msg), Qnil);
+#if (PNG_LIBPNG_VER < 10500)
   longjmp (png_ptr->jmpbuf, 1);
+#else
+  png_longjmp (png_ptr, 1);
+#endif
 }
 
 
@@ -6603,7 +6603,7 @@ png_load (f, img)
 
   /* Set error jump-back.  We come back here when the PNG library
      detects an error.  */
-  if (setjmp (png_ptr->jmpbuf))
+  if (setjmp (png_jmpbuf(png_ptr)))
     {
     error:
       if (png_ptr)
@@ -8108,7 +8108,7 @@ gif_load (f, img)
 
       /* Open the GIF file.  Casting return value avoids a GCC warning
 	 on W32.  */
-      gif = (GifFileType *)fn_DGifOpenFileName (SDATA (file));
+      gif = (GifFileType *)fn_DGifOpenFileName (SDATA (file), NULL);
       if (gif == NULL)
 	{
 	  image_error ("Cannot open `%s'", file, Qnil);
@@ -8125,7 +8125,7 @@ gif_load (f, img)
       memsrc.index = 0;
 
       /* Casting return value avoids a GCC warning on W32.  */
-      gif = (GifFileType *)fn_DGifOpen(&memsrc, gif_read_from_memory);
+      gif = (GifFileType *)fn_DGifOpen(&memsrc, gif_read_from_memory, NULL);
       if (!gif)
 	{
 	  image_error ("Cannot open memory source `%s'", img->spec, Qnil);
@@ -8138,7 +8138,7 @@ gif_load (f, img)
   if (!check_image_size (f, gif->SWidth, gif->SHeight))
     {
       image_error ("Invalid image size", Qnil, Qnil);
-      fn_DGifCloseFile (gif);
+      fn_DGifCloseFile (gif, NULL);
       UNGCPRO;
       return 0;
     }
@@ -8148,7 +8148,7 @@ gif_load (f, img)
   if (rc == GIF_ERROR)
     {
       image_error ("Error reading `%s'", img->spec, Qnil);
-      fn_DGifCloseFile (gif);
+      fn_DGifCloseFile (gif, NULL);
       UNGCPRO;
       return 0;
     }
@@ -8159,7 +8159,7 @@ gif_load (f, img)
     {
       image_error ("Invalid image number `%s' in image `%s'",
 		   image, img->spec);
-      fn_DGifCloseFile (gif);
+      fn_DGifCloseFile (gif, NULL);
       UNGCPRO;
       return 0;
     }
@@ -8181,7 +8181,7 @@ gif_load (f, img)
   if (!check_image_size (f, width, height))
     {
       image_error ("Invalid image size", Qnil, Qnil);
-      fn_DGifCloseFile (gif);
+      fn_DGifCloseFile (gif, NULL);
       UNGCPRO;
       return 0;
     }
@@ -8189,7 +8189,7 @@ gif_load (f, img)
   /* Create the X image and pixmap.  */
   if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
     {
-      fn_DGifCloseFile (gif);
+      fn_DGifCloseFile (gif, NULL);
       UNGCPRO;
       return 0;
     }
@@ -8296,7 +8296,7 @@ gif_load (f, img)
 				Fcons (make_number (gif->ImageCount),
 				       img->data.lisp_val));
 
-  fn_DGifCloseFile (gif);
+  fn_DGifCloseFile (gif, NULL);
 
   /* Maybe fill in the background field while we have ximg handy. */
   if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
