aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorGlenn Morris <[email protected]>2014-06-21 12:45:59 -0700
committerGlenn Morris <[email protected]>2014-06-21 12:45:59 -0700
commitc400516ab1d827d08225ffb3e1bc1969c73cc45e (patch)
treeb16343b9e11c916c96b12ab56b6024cad91d3aff /src/image.c
parent539ad293eb36b4cf458cbdb5a6b37f5cd1bb68a1 (diff)
parent8047f439ec7d0bbe0085800a13bee8da883ae4dd (diff)
Merge from emacs-24; up to 2014-06-06T02:22:[email protected]
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/src/image.c b/src/image.c
index 3220a45a28..f8c2402bfc 100644
--- a/src/image.c
+++ b/src/image.c
@@ -7250,7 +7250,11 @@ gif_image_p (Lisp_Object object)
#ifdef WINDOWSNT
/* GIF library details. */
+#if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR)
+DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *, int *));
+#else
DEF_IMGLIB_FN (int, DGifCloseFile, (GifFileType *));
+#endif
DEF_IMGLIB_FN (int, DGifSlurp, (GifFileType *));
#if GIFLIB_MAJOR < 5
DEF_IMGLIB_FN (GifFileType *, DGifOpen, (void *, InputFunc));
@@ -7320,6 +7324,22 @@ gif_read_from_memory (GifFileType *file, GifByteType *buf, int len)
return len;
}
+static int
+gif_close (GifFileType *gif, int *err)
+{
+ int retval;
+
+#if 5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR)
+ retval = fn_DGifCloseFile (gif, err);
+#else
+ retval = fn_DGifCloseFile (gif);
+#if GIFLIB_MAJOR >= 5
+ if (err)
+ *err = gif->Error;
+#endif
+#endif
+ return retval;
+}
/* Load GIF image IMG for use on frame F. Value is true if
successful. */
@@ -7344,9 +7364,7 @@ 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))
{
@@ -7414,7 +7432,7 @@ gif_load (struct frame *f, struct image *img)
if (!check_image_size (f, gif->SWidth, gif->SHeight))
{
image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
- fn_DGifCloseFile (gif);
+ gif_close (gif, NULL);
return 0;
}
@@ -7423,7 +7441,7 @@ gif_load (struct frame *f, struct image *img)
if (rc == GIF_ERROR || gif->ImageCount <= 0)
{
image_error ("Error reading `%s'", img->spec, Qnil);
- fn_DGifCloseFile (gif);
+ gif_close (gif, NULL);
return 0;
}
@@ -7435,7 +7453,7 @@ gif_load (struct frame *f, struct image *img)
{
image_error ("Invalid image number `%s' in image `%s'",
image_number, img->spec);
- fn_DGifCloseFile (gif);
+ gif_close (gif, NULL);
return 0;
}
}
@@ -7453,7 +7471,7 @@ gif_load (struct frame *f, struct image *img)
if (!check_image_size (f, width, height))
{
image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
- fn_DGifCloseFile (gif);
+ gif_close (gif, NULL);
return 0;
}
@@ -7471,7 +7489,7 @@ gif_load (struct frame *f, struct image *img)
&& 0 <= subimg_left && subimg_left <= width - subimg_width))
{
image_error ("Subimage does not fit in image", Qnil, Qnil);
- fn_DGifCloseFile (gif);
+ gif_close (gif, NULL);
return 0;
}
}
@@ -7479,7 +7497,7 @@ gif_load (struct frame *f, struct image *img)
/* Create the X image and pixmap. */
if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
{
- fn_DGifCloseFile (gif);
+ gif_close (gif, NULL);
return 0;
}
@@ -7650,7 +7668,18 @@ gif_load (struct frame *f, struct image *img)
Fcons (make_number (gif->ImageCount),
img->lisp_data));
- fn_DGifCloseFile (gif);
+ if (gif_close (gif, &gif_err) == GIF_ERROR)
+ {
+#if 5 <= GIFLIB_MAJOR
+ char *error_text = fn_GifErrorString (gif_err);
+
+ if (error_text)
+ image_error ("Error closing `%s': %s",
+ img->spec, build_string (error_text));
+#else
+ image_error ("Error closing `%s'", img->spec, Qnil);
+#endif
+ }
/* Maybe fill in the background field while we have ximg handy. */
if (NILP (image_spec_value (img->spec, QCbackground, NULL)))