Skip to content
Browse files

MS-Windows follow-up to revision 114603: support giflib 5.x.

 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.
  • Loading branch information...
1 parent 61ba739 commit 2e31bba4d9dad48d3f090bfb3dc8e9472dbdbf43 Eli Zaretskii committed
Showing with 78 additions and 12 deletions.
  1. +6 −0 lisp/ChangeLog
  2. +13 −1 lisp/term/w32-win.el
  3. +10 −0 src/ChangeLog
  4. +49 −11 src/image.c
View
6 lisp/ChangeLog
@@ -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
View
14 lisp/term/w32-win.el
@@ -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")
View
10 src/ChangeLog
@@ -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
View
60 src/image.c
@@ -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. */
@@ -9372,6 +9400,16 @@ non-numeric, there is no explicit limit on the size of images. */);
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
DEFSYM (Qpbm, "pbm");

0 comments on commit 2e31bba

Please sign in to comment.
Something went wrong with that request. Please try again.