]> git.eshelyaron.com Git - emacs.git/commitdiff
MS-Windows follow-up to 2013-10-10T01:03:11Z!rgm@gnu.org: support giflib 5.x.
authorEli Zaretskii <eliz@gnu.org>
Thu, 10 Oct 2013 15:30:21 +0000 (18:30 +0300)
committerEli Zaretskii <eliz@gnu.org>
Thu, 10 Oct 2013 15:30:21 +0000 (18:30 +0300)
 src/image.c (GIFLIB_MAJOR): Define to 4 if undefined.
 (GIFLIB_MINOR, GIFLIB_RELEASE): Define to zero if undefined.
 (GifErrorString) [GIFLIB_MAJOR >= 5]: Define a function pointer.
 (gif_load): For giflib v5.x and later, display the error message
 produced by giflib when its functions fail.
 (syms_of_image) <Qlibgif_version> [HAVE_NTGUI]: New DEFSYM.

 lisp/term/w32-win.el (dynamic-library-alist): Define separate lists
 of GIF DLLs for versions before and after 5.0.0 of giflib.

Fixes: debbugs:15531
lisp/ChangeLog
lisp/term/w32-win.el
src/ChangeLog
src/image.c

index bb675ce5088a170310d1d6d14dedf87c947b8a5a..a06055ddb9b3a5623abe14a9f8bdf8356026f591 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-10  Eli Zaretskii  <eliz@gnu.org>
+
+       * term/w32-win.el (dynamic-library-alist): Define separate lists
+       of GIF DLLs for versions before and after 5.0.0 of giflib.
+       (Bug#15531)
+
 2013-10-10  João Távora <joaotavora@gmail.com>
 
        * vc/vc.el (vc-diff-build-argument-list-internal): If the file is
index 892ac9749d6caaca3e6f449263eba43a4b31aa6f..9690a5a7d75b7d5dc13bda77da4bafa24781a24d 100644 (file)
@@ -223,7 +223,19 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
               "libpng13d.dll" "libpng13.dll"))
        '(jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll")
        '(tiff "libtiff3.dll" "libtiff.dll")
-       '(gif "giflib4.dll" "libungif4.dll" "libungif.dll")
+       ;; Versions of giflib 5.0.0 and later changed signatures of
+       ;; several functions used by Emacs, which makes those versions
+       ;; incompatible with previous ones.  We select the correct
+       ;; libraries according to the version of giflib we were
+       ;; compiled against.  (If we were compiled without GIF support,
+       ;; libgif-version's value is -1.)
+       (if (>= libgif-version 50000)
+          ;; Yes, giflib 5.x uses 6 as the major version of the API,
+          ;; thus "libgif-6.dll" below (giflib 4.x used 5 as the
+          ;; major API version).
+          ;; giflib5.dll is from the lua-files project.
+          '(gif "libgif-6.dll" "giflib5.dll")
+        '(gif "libgif-5.dll" "giflib4.dll" "libungif4.dll" "libungif.dll"))
        '(svg "librsvg-2-2.dll")
        '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll")
        '(glib "libglib-2.0-0.dll")
index bdf3a9fb09f81cff257fb1a6dd359d9ffb09e830..409266220903d95b9f641b8c208108651b00ec6c 100644 (file)
@@ -1,3 +1,13 @@
+2013-10-10  Eli Zaretskii  <eliz@gnu.org>
+
+       * image.c (GIFLIB_MAJOR): Define to 4 if undefined.
+       (GIFLIB_MINOR, GIFLIB_RELEASE): Define to zero if undefined.
+       (GifErrorString) [GIFLIB_MAJOR >= 5]: Define a function pointer.
+       (gif_load): For giflib v5.x and later, display the error message
+       produced by giflib when its functions fail.
+       (syms_of_image) <Qlibgif_version> [HAVE_NTGUI]: New DEFSYM.
+       (Bug#15531)
+
 2013-10-10  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * keyboard.c (last_event_timestamp): Remove.  For X selection and
index c414f5b91bdd57a8b41d375132873b3391bc944a..86da611653368c8684ddc0f32e100cc637835184 100644 (file)
@@ -87,10 +87,11 @@ typedef struct w32_bitmap_record Bitmap_Record;
 #define x_defined_color w32_defined_color
 #define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
 
-/* Version of libpng that we were compiled with, or -1 if no PNG
-   support was compiled in.  This is tested by w32-win.el to correctly
-   set up the alist used to search for PNG libraries.  */
-Lisp_Object Qlibpng_version;
+/* Versions of libpng and libgif that we were compiled with, or -1 if
+   no PNG/GIF support was compiled in.  This is tested by w32-win.el
+   to correctly set up the alist used to search for the respective
+   image libraries.  */
+Lisp_Object Qlibpng_version, Qlibgif_version;
 #endif /* HAVE_NTGUI */
 
 #ifdef HAVE_NS
@@ -7219,8 +7220,15 @@ gif_image_p (Lisp_Object object)
 
 #endif /* HAVE_NTGUI */
 
+/* Giflib before 5.0 didn't define these macros.  */
 #ifndef GIFLIB_MAJOR
-#define GIFLIB_MAJOR 0
+#define GIFLIB_MAJOR 4
+#endif
+#ifndef GIFLIB_MINOR
+#define GIFLIB_MINOR 0
+#endif
+#ifndef GIFLIB_RELEASE
+#define GIFLIB_RELEASE 0
 #endif
 
 #ifdef WINDOWSNT
@@ -7234,6 +7242,7 @@ DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *));
 #else
 DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc, int *));
 DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName, (const char *, int *));
+DEF_IMGLIB_FN (char *, GifErrorString, (int));
 #endif
 
 static bool
@@ -7248,6 +7257,9 @@ init_gif_functions (void)
   LOAD_IMGLIB_FN (library, DGifSlurp);
   LOAD_IMGLIB_FN (library, DGifOpen);
   LOAD_IMGLIB_FN (library, DGifOpenFileName);
+#if GIFLIB_MAJOR >= 5
+  LOAD_IMGLIB_FN (library, GifErrorString);
+#endif
   return 1;
 }
 
@@ -7257,6 +7269,7 @@ init_gif_functions (void)
 #define fn_DGifSlurp           DGifSlurp
 #define fn_DGifOpen            DGifOpen
 #define fn_DGifOpenFileName    DGifOpenFileName
+#define fn_GifErrorString      GifErrorString
 
 #endif /* WINDOWSNT */
 
@@ -7313,6 +7326,9 @@ gif_load (struct frame *f, struct image *img)
   Lisp_Object specified_data = image_spec_value (img->spec, QCdata, NULL);
   unsigned long bgcolor = 0;
   EMACS_INT idx;
+#if GIFLIB_MAJOR >= 5
+  int gif_err;
+#endif
 
   if (NILP (specified_data))
     {
@@ -7326,14 +7342,20 @@ gif_load (struct frame *f, struct image *img)
       /* 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);
          return 0;
        }
+#else
+      gif = fn_DGifOpenFileName (SSDATA (file), &gif_err);
+      if (gif == NULL)
+       {
+         image_error ("Cannot open `%s': %s",
+                      file, build_string (fn_GifErrorString (gif_err)));
+         return 0;
+       }
+#endif
     }
   else
     {
@@ -7351,14 +7373,20 @@ gif_load (struct frame *f, struct image *img)
 
 #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);
          return 0;
        }
+#else
+      gif = fn_DGifOpen (&memsrc, gif_read_from_memory, &gif_err);
+      if (!gif)
+       {
+         image_error ("Cannot open memory source `%s': %s",
+                      img->spec, build_string (fn_GifErrorString (gif_err)));
+         return 0;
+       }
+#endif
     }
 
   /* Before reading entire contents, check the declared image size. */
@@ -9370,6 +9398,16 @@ non-numeric, there is no explicit limit on the size of images.  */);
        make_number (PNG_LIBPNG_VER)
 #else
        make_number (-1)
+#endif
+       );
+  DEFSYM (Qlibgif_version, "libgif-version");
+  Fset (Qlibgif_version,
+#ifdef HAVE_GIF
+       make_number (GIFLIB_MAJOR * 10000
+                    + GIFLIB_MINOR * 100
+                    + GIFLIB_RELEASE)
+#else
+       make_number (-1)
 #endif
        );
 #endif