diff options
| author | Paul Eggert | 2015-09-10 02:39:13 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-09-10 02:44:41 -0700 |
| commit | 6ee7eabb5dbdf39f2d7471c9e42fc90c315e6a9f (patch) | |
| tree | f3534f8cd5fa457d3a8ba09760a246eca6e1f142 /src/image.c | |
| parent | 831945a1cb675444fb819d8b820cd65402930545 (diff) | |
| download | emacs-6ee7eabb5dbdf39f2d7471c9e42fc90c315e6a9f.tar.gz emacs-6ee7eabb5dbdf39f2d7471c9e42fc90c315e6a9f.zip | |
Port to GIFLIB 5.0.6 and later
Problem reported by Mitchel Humpherys in:
http://lists.gnu.org/archive/html/emacs-devel/2015-09/msg00420.html
* src/image.c (HAVE_GIFERRORSTRING) [HAVE_GIF]: New macro.
(GifErrorString, init_gif_functions) [HAVE_GIF && WINDOWSNT]:
(gif_load) [HAVE_GIF]: Use it.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/image.c b/src/image.c index 85cf801f6a9..2aa01e4a990 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7499,6 +7499,12 @@ gif_image_p (Lisp_Object object) | |||
| 7499 | # define GIFLIB_MAJOR 4 | 7499 | # define GIFLIB_MAJOR 4 |
| 7500 | # endif | 7500 | # endif |
| 7501 | 7501 | ||
| 7502 | /* GifErrorString is declared to return char const * when GIFLIB_MAJOR | ||
| 7503 | and GIFLIB_MINOR indicate 5.1 or later. Do not bother using it in | ||
| 7504 | earlier releases, where either it returns char * or GIFLIB_MINOR | ||
| 7505 | may be incorrect. */ | ||
| 7506 | # define HAVE_GIFERRORSTRING (5 < GIFLIB_MAJOR + (1 <= GIFLIB_MINOR)) | ||
| 7507 | |||
| 7502 | # ifdef WINDOWSNT | 7508 | # ifdef WINDOWSNT |
| 7503 | 7509 | ||
| 7504 | /* GIF library details. */ | 7510 | /* GIF library details. */ |
| @@ -7514,7 +7520,9 @@ DEF_DLL_FN (GifFileType *, DGifOpenFileName, (const char *)); | |||
| 7514 | # else | 7520 | # else |
| 7515 | DEF_DLL_FN (GifFileType *, DGifOpen, (void *, InputFunc, int *)); | 7521 | DEF_DLL_FN (GifFileType *, DGifOpen, (void *, InputFunc, int *)); |
| 7516 | DEF_DLL_FN (GifFileType *, DGifOpenFileName, (const char *, int *)); | 7522 | DEF_DLL_FN (GifFileType *, DGifOpenFileName, (const char *, int *)); |
| 7517 | DEF_DLL_FN (char *, GifErrorString, (int)); | 7523 | # endif |
| 7524 | # if HAVE_GIFERRORSTRING | ||
| 7525 | DEF_DLL_FN (char const *, GifErrorString, (int)); | ||
| 7518 | # endif | 7526 | # endif |
| 7519 | 7527 | ||
| 7520 | static bool | 7528 | static bool |
| @@ -7529,7 +7537,7 @@ init_gif_functions (void) | |||
| 7529 | LOAD_DLL_FN (library, DGifSlurp); | 7537 | LOAD_DLL_FN (library, DGifSlurp); |
| 7530 | LOAD_DLL_FN (library, DGifOpen); | 7538 | LOAD_DLL_FN (library, DGifOpen); |
| 7531 | LOAD_DLL_FN (library, DGifOpenFileName); | 7539 | LOAD_DLL_FN (library, DGifOpenFileName); |
| 7532 | # if GIFLIB_MAJOR >= 5 | 7540 | # if HAVE_GIFERRORSTRING |
| 7533 | LOAD_DLL_FN (library, GifErrorString); | 7541 | LOAD_DLL_FN (library, GifErrorString); |
| 7534 | # endif | 7542 | # endif |
| 7535 | return 1; | 7543 | return 1; |
| @@ -7641,20 +7649,19 @@ gif_load (struct frame *f, struct image *img) | |||
| 7641 | /* Open the GIF file. */ | 7649 | /* Open the GIF file. */ |
| 7642 | #if GIFLIB_MAJOR < 5 | 7650 | #if GIFLIB_MAJOR < 5 |
| 7643 | gif = DGifOpenFileName (SSDATA (encoded_file)); | 7651 | gif = DGifOpenFileName (SSDATA (encoded_file)); |
| 7644 | if (gif == NULL) | ||
| 7645 | { | ||
| 7646 | image_error ("Cannot open `%s'", file); | ||
| 7647 | return 0; | ||
| 7648 | } | ||
| 7649 | #else | 7652 | #else |
| 7650 | gif = DGifOpenFileName (SSDATA (encoded_file), &gif_err); | 7653 | gif = DGifOpenFileName (SSDATA (encoded_file), &gif_err); |
| 7654 | #endif | ||
| 7651 | if (gif == NULL) | 7655 | if (gif == NULL) |
| 7652 | { | 7656 | { |
| 7657 | #if HAVE_GIFERRORSTRING | ||
| 7653 | image_error ("Cannot open `%s': %s", | 7658 | image_error ("Cannot open `%s': %s", |
| 7654 | file, build_string (GifErrorString (gif_err))); | 7659 | file, build_string (GifErrorString (gif_err))); |
| 7660 | #else | ||
| 7661 | image_error ("Cannot open `%s'", file); | ||
| 7662 | #endif | ||
| 7655 | return 0; | 7663 | return 0; |
| 7656 | } | 7664 | } |
| 7657 | #endif | ||
| 7658 | } | 7665 | } |
| 7659 | else | 7666 | else |
| 7660 | { | 7667 | { |
| @@ -7672,20 +7679,19 @@ gif_load (struct frame *f, struct image *img) | |||
| 7672 | 7679 | ||
| 7673 | #if GIFLIB_MAJOR < 5 | 7680 | #if GIFLIB_MAJOR < 5 |
| 7674 | gif = DGifOpen (&memsrc, gif_read_from_memory); | 7681 | gif = DGifOpen (&memsrc, gif_read_from_memory); |
| 7675 | if (!gif) | ||
| 7676 | { | ||
| 7677 | image_error ("Cannot open memory source `%s'", img->spec); | ||
| 7678 | return 0; | ||
| 7679 | } | ||
| 7680 | #else | 7682 | #else |
| 7681 | gif = DGifOpen (&memsrc, gif_read_from_memory, &gif_err); | 7683 | gif = DGifOpen (&memsrc, gif_read_from_memory, &gif_err); |
| 7684 | #endif | ||
| 7682 | if (!gif) | 7685 | if (!gif) |
| 7683 | { | 7686 | { |
| 7687 | #if HAVE_GIFERRORSTRING | ||
| 7684 | image_error ("Cannot open memory source `%s': %s", | 7688 | image_error ("Cannot open memory source `%s': %s", |
| 7685 | img->spec, build_string (GifErrorString (gif_err))); | 7689 | img->spec, build_string (GifErrorString (gif_err))); |
| 7690 | #else | ||
| 7691 | image_error ("Cannot open memory source `%s'", img->spec); | ||
| 7692 | #endif | ||
| 7686 | return 0; | 7693 | return 0; |
| 7687 | } | 7694 | } |
| 7688 | #endif | ||
| 7689 | } | 7695 | } |
| 7690 | 7696 | ||
| 7691 | /* Before reading entire contents, check the declared image size. */ | 7697 | /* Before reading entire contents, check the declared image size. */ |
| @@ -7980,8 +7986,8 @@ gif_load (struct frame *f, struct image *img) | |||
| 7980 | 7986 | ||
| 7981 | if (gif_close (gif, &gif_err) == GIF_ERROR) | 7987 | if (gif_close (gif, &gif_err) == GIF_ERROR) |
| 7982 | { | 7988 | { |
| 7983 | #if 5 <= GIFLIB_MAJOR | 7989 | #if HAVE_GIFERRORSTRING |
| 7984 | char *error_text = GifErrorString (gif_err); | 7990 | char const *error_text = GifErrorString (gif_err); |
| 7985 | 7991 | ||
| 7986 | if (error_text) | 7992 | if (error_text) |
| 7987 | image_error ("Error closing `%s': %s", | 7993 | image_error ("Error closing `%s': %s", |