aboutsummaryrefslogtreecommitdiff
blob: b3b4ed04ec56a1baaa0f1b7ebf14832ab86480d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
Fix compilation with giflib-5.
Backported from Emacs 24, comprises parts of the following commits:

commit be316ede5fffb724852ee225489e70778d240bb0
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Tue Jan 7 13:14:32 2014 -0800

    Fix misdisplay of interlaced GIFs with libgif5.

commit f3606ef766bcec86789316a05949f1e67a51e7c1
Author: Barry Fishman <barry_fishman@acm.org>
Date:   Wed Oct 9 20:37:44 2013 -0400

    Handle giflib 5 changes (tiny change)

--- emacs-23.4-orig/configure.in
+++ emacs-23.4/configure.in
@@ -2226,8 +2226,9 @@
 if test "${HAVE_X11}" = "yes" && test "${with_gif}" != "no"; then
   AC_CHECK_HEADER(gif_lib.h,
 # EGifPutExtensionLast only exists from version libungif-4.1.0b1.
-# Earlier versions can crash Emacs.
-    [AC_CHECK_LIB(gif, EGifPutExtensionLast, HAVE_GIF=yes, try_libungif=yes)])
+# Earlier versions can crash Emacs, but version 5.0 removes EGifPutExtensionLast.
+    [AC_CHECK_LIB(gif, GifMakeMapObject, HAVE_GIF=yes,
+        [AC_CHECK_LIB(gif, EGifPutExtensionLast, HAVE_GIF=yes, try_libungif=yes)])])
 
   if test "$HAVE_GIF" = yes; then
       ac_gif_lib_name="-lgif"
--- emacs-23.4-orig/src/image.c
+++ emacs-23.4/src/image.c
@@ -7244,6 +7244,13 @@
 
 #endif /* HAVE_NTGUI */
 
+/* Giflib before 5.0 didn't define these macros.  */
+#ifndef GIFLIB_MAJOR
+#define GIFLIB_MAJOR 0
+#endif
+#ifndef GIFLIB_MINOR
+#define GIFLIB_MINOR 0
+#endif
 
 #ifdef HAVE_NTGUI
 
@@ -7350,7 +7357,11 @@
 	}
 
       /* Open the GIF file.  */
+#if GIFLIB_MAJOR < 5
       gif = fn_DGifOpenFileName (SDATA (file));
+#else
+      gif = fn_DGifOpenFileName (SDATA (file), NULL);
+#endif
       if (gif == NULL)
 	{
 	  image_error ("Cannot open `%s'", file, Qnil);
@@ -7366,7 +7377,11 @@
       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);
@@ -7379,7 +7394,11 @@
   if (!check_image_size (f, gif->SWidth, gif->SHeight))
     {
       image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
+#if GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 0)
       fn_DGifCloseFile (gif);
+#else
+      fn_DGifCloseFile (gif, NULL);
+#endif
       UNGCPRO;
       return 0;
     }
@@ -7389,7 +7408,11 @@
   if (rc == GIF_ERROR)
     {
       image_error ("Error reading `%s'", img->spec, Qnil);
+#if GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 0)
       fn_DGifCloseFile (gif);
+#else
+      fn_DGifCloseFile (gif, NULL);
+#endif
       UNGCPRO;
       return 0;
     }
@@ -7400,7 +7423,11 @@
     {
       image_error ("Invalid image number `%s' in image `%s'",
 		   image, img->spec);
+#if GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 0)
       fn_DGifCloseFile (gif);
+#else
+      fn_DGifCloseFile (gif, NULL);
+#endif
       UNGCPRO;
       return 0;
     }
@@ -7422,7 +7449,11 @@
   if (!check_image_size (f, width, height))
     {
       image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
+#if GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 0)
       fn_DGifCloseFile (gif);
+#else
+      fn_DGifCloseFile (gif, NULL);
+#endif
       UNGCPRO;
       return 0;
     }
@@ -7430,7 +7461,11 @@
   /* Create the X image and pixmap.  */
   if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
     {
+#if GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 0)
       fn_DGifCloseFile (gif);
+#else
+      fn_DGifCloseFile (gif, NULL);
+#endif
       UNGCPRO;
       return 0;
     }
@@ -7482,7 +7517,7 @@
      problems with bytes >= 0x80.  */
   raster = (unsigned char *) gif->SavedImages[ino].RasterBits;
 
-  if (gif->SavedImages[ino].ImageDesc.Interlace)
+  if (GIFLIB_MAJOR < 5 && gif->SavedImages[ino].ImageDesc.Interlace)
     {
       int pass;
       int row = interlace_start[0];
@@ -7537,7 +7572,11 @@
 				Fcons (make_number (gif->ImageCount),
 				       img->data.lisp_val));
 
+#if GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 0)
   fn_DGifCloseFile (gif);
+#else
+  fn_DGifCloseFile (gif, NULL);
+#endif
 
   /* Maybe fill in the background field while we have ximg handy. */
   if (NILP (image_spec_value (img->spec, QCbackground, NULL)))