File emacs-24.3-giflib5.patch of Package emacs

---
 emacs-24.3/src/image.c |   36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

--- emacs-24.3/src/image.c
+++ emacs-24.3/src/image.c	2014-09-03 10:07:32.000000000 +0000
@@ -7095,11 +7095,19 @@ gif_image_p (Lisp_Object object)
 
 #endif /* HAVE_NTGUI */
 
+#ifndef GIFLIB_MAJOR
+# define GIFLIB_MAJOR 0
+#endif
 
 #ifdef WINDOWSNT
 
 /* GIF library details.  */
+#if (GIFLIB_MAJOR > 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1))
+DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *, int *));
+#else
 DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *));
+#define DGifCloseFile(a, b) DGifCloseFile(a)
+#endif
 DEF_IMGLIB_FN (int, DGifSlurp, (GifFileType *));
 DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc));
 DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *));
@@ -7121,7 +7129,11 @@ init_gif_functions (void)
 
 #else
 
-#define fn_DGifCloseFile	DGifCloseFile
+#if (GIFLIB_MAJOR > 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1))
+#define fn_DGifCloseFile(a,b)	DGifCloseFile(a,b)
+#else
+#define fn_DGifCloseFile(a,b)	DGifCloseFile(a)
+#endif
 #define fn_DGifSlurp		DGifSlurp
 #define fn_DGifOpen		DGifOpen
 #define fn_DGifOpenFileName	DGifOpenFileName
@@ -7192,7 +7204,11 @@ gif_load (struct frame *f, struct image
 	}
 
       /* Open the GIF file.  */
+#if GIFLIB_MAJOR < 5
       gif = fn_DGifOpenFileName (SSDATA (file));
+#else
+      gif = fn_DGifOpenFileName (SSDATA (file), NULL);
+#endif
       if (gif == NULL)
 	{
 	  image_error ("Cannot open `%s'", file, Qnil);
@@ -7213,7 +7229,11 @@ gif_load (struct frame *f, struct image
       memsrc.len = SBYTES (specified_data);
       memsrc.index = 0;
 
+#if GIFLIB_MAJOR < 5
       gif = fn_DGifOpen (&memsrc, gif_read_from_memory);
+#else
+      gif = fn_DGifOpen (&memsrc, gif_read_from_memory, NULL);
+#endif
       if (!gif)
 	{
 	  image_error ("Cannot open memory source `%s'", img->spec, Qnil);
@@ -7225,7 +7245,7 @@ gif_load (struct frame *f, struct image
   if (!check_image_size (f, gif->SWidth, gif->SHeight))
     {
       image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
-      fn_DGifCloseFile (gif);
+      fn_DGifCloseFile (gif, NULL);
       return 0;
     }
 
@@ -7234,7 +7254,7 @@ gif_load (struct frame *f, struct image
   if (rc == GIF_ERROR || gif->ImageCount <= 0)
     {
       image_error ("Error reading `%s'", img->spec, Qnil);
-      fn_DGifCloseFile (gif);
+      fn_DGifCloseFile (gif, NULL);
       return 0;
     }
 
@@ -7246,7 +7266,7 @@ gif_load (struct frame *f, struct image
       {
 	image_error ("Invalid image number `%s' in image `%s'",
 		     image_number, img->spec);
-	fn_DGifCloseFile (gif);
+	fn_DGifCloseFile (gif, NULL);
 	return 0;
       }
   }
@@ -7264,14 +7284,14 @@ gif_load (struct frame *f, struct image
   if (!check_image_size (f, width, height))
     {
       image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
-      fn_DGifCloseFile (gif);
+      fn_DGifCloseFile (gif, NULL);
       return 0;
     }
 
   /* 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);
       return 0;
     }
 
@@ -7370,7 +7390,7 @@ gif_load (struct frame *f, struct image
 	  }
 
       /* Apply the pixel values.  */
-      if (gif->SavedImages[j].ImageDesc.Interlace)
+      if (GIFLIB_MAJOR < 5 && gif->SavedImages[j].ImageDesc.Interlace)
 	{
 	  int row, pass;
 
@@ -7447,7 +7467,7 @@ gif_load (struct frame *f, struct image
 			    Fcons (make_number (gif->ImageCount),
 				   img->lisp_data));
 
-  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)))
openSUSE Build Service is sponsored by