diff options
| author | Chong Yidong | 2011-01-29 16:28:26 -0500 |
|---|---|---|
| committer | Chong Yidong | 2011-01-29 16:28:26 -0500 |
| commit | 7f9c5df9660fc124e5d1399eaf4b3f5da94c71aa (patch) | |
| tree | 71452aa6e099477a1770338244e72c0a65e40d8b /src | |
| parent | e935c6a287abf3dc87e2bc79d9019460a689d4aa (diff) | |
| download | emacs-7f9c5df9660fc124e5d1399eaf4b3f5da94c71aa.tar.gz emacs-7f9c5df9660fc124e5d1399eaf4b3f5da94c71aa.zip | |
Fix png support to allow compiling with libpng-1.5 (Bug#7908).
* image.c (fn_png_longjmp, fn_png_set_longjmp_fn): New png
function definitions for compiling with libpng-1.5.
(PNG_LONGJMP, PNG_JMPBUF): New macros for libpng-1.5.
(my_png_error, png_load): Use them. Suggested by Thomas Klausner.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/image.c | 34 |
2 files changed, 40 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a6e8d04d7c0..1d14be1ab70 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-01-29 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * image.c (fn_png_longjmp, fn_png_set_longjmp_fn): New png | ||
| 4 | function definitions for compiling with libpng-1.5. | ||
| 5 | (PNG_LONGJMP, PNG_JMPBUF): New macros for libpng-1.5. | ||
| 6 | (my_png_error, png_load): Use them. Suggested by Thomas Klausner | ||
| 7 | (Bug#7908). | ||
| 8 | |||
| 1 | 2011-01-28 Chong Yidong <cyd@stupidchicken.com> | 9 | 2011-01-28 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 10 | ||
| 3 | * m/intel386.h: Define NO_ARG_ARRAY. Suggested by Dan Nicolaescu. | 11 | * m/intel386.h: Define NO_ARG_ARRAY. Suggested by Dan Nicolaescu. |
diff --git a/src/image.c b/src/image.c index 631c73a6008..cc8589f924a 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -5590,6 +5590,11 @@ DEF_IMGLIB_FN (png_read_image); | |||
| 5590 | DEF_IMGLIB_FN (png_read_end); | 5590 | DEF_IMGLIB_FN (png_read_end); |
| 5591 | DEF_IMGLIB_FN (png_error); | 5591 | DEF_IMGLIB_FN (png_error); |
| 5592 | 5592 | ||
| 5593 | #if (PNG_LIBPNG_VER >= 10500) | ||
| 5594 | DEF_IMGLIB_FN (png_longjmp); | ||
| 5595 | DEF_IMGLIB_FN (png_set_longjmp_fn); | ||
| 5596 | #endif /* libpng version >= 1.5 */ | ||
| 5597 | |||
| 5593 | static int | 5598 | static int |
| 5594 | init_png_functions (Lisp_Object libraries) | 5599 | init_png_functions (Lisp_Object libraries) |
| 5595 | { | 5600 | { |
| @@ -5620,6 +5625,12 @@ init_png_functions (Lisp_Object libraries) | |||
| 5620 | LOAD_IMGLIB_FN (library, png_read_image); | 5625 | LOAD_IMGLIB_FN (library, png_read_image); |
| 5621 | LOAD_IMGLIB_FN (library, png_read_end); | 5626 | LOAD_IMGLIB_FN (library, png_read_end); |
| 5622 | LOAD_IMGLIB_FN (library, png_error); | 5627 | LOAD_IMGLIB_FN (library, png_error); |
| 5628 | |||
| 5629 | #if (PNG_LIBPNG_VER >= 10500) | ||
| 5630 | LOAD_IMGLIB_FN (library, png_longjmp); | ||
| 5631 | LOAD_IMGLIB_FN (library, png_set_longjmp_fn); | ||
| 5632 | #endif /* libpng version >= 1.5 */ | ||
| 5633 | |||
| 5623 | return 1; | 5634 | return 1; |
| 5624 | } | 5635 | } |
| 5625 | #else | 5636 | #else |
| @@ -5646,8 +5657,27 @@ init_png_functions (Lisp_Object libraries) | |||
| 5646 | #define fn_png_read_end png_read_end | 5657 | #define fn_png_read_end png_read_end |
| 5647 | #define fn_png_error png_error | 5658 | #define fn_png_error png_error |
| 5648 | 5659 | ||
| 5660 | #if (PNG_LIBPNG_VER >= 10500) | ||
| 5661 | #define fn_png_longjmp png_longjmp | ||
| 5662 | #define fn_png_set_longjmp_fn png_set_longjmp_fn | ||
| 5663 | #endif /* libpng version >= 1.5 */ | ||
| 5664 | |||
| 5649 | #endif /* HAVE_NTGUI */ | 5665 | #endif /* HAVE_NTGUI */ |
| 5650 | 5666 | ||
| 5667 | |||
| 5668 | #if (PNG_LIBPNG_VER < 10500) | ||
| 5669 | #define PNG_LONGJMP(ptr) (longjmp (ptr->jmpbuf, 1)) | ||
| 5670 | #define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) | ||
| 5671 | #else | ||
| 5672 | /* In libpng version 1.5, the jmpbuf member is hidden. | ||
| 5673 | We need the extra cast for PNG_JMPBUF because, for Windows, | ||
| 5674 | DEF_IMGLIB_FN defines the return value of fn_png_set_longjmp_fn to | ||
| 5675 | be int (Bug#7908). */ | ||
| 5676 | #define PNG_LONGJMP(ptr) (fn_png_longjmp (png_ptr, 1)) | ||
| 5677 | #define PNG_JMPBUF(ptr) \ | ||
| 5678 | (*(jmp_buf *)(fn_png_set_longjmp_fn((ptr), longjmp, sizeof (jmp_buf)))) | ||
| 5679 | #endif | ||
| 5680 | |||
| 5651 | /* Error and warning handlers installed when the PNG library | 5681 | /* Error and warning handlers installed when the PNG library |
| 5652 | is initialized. */ | 5682 | is initialized. */ |
| 5653 | 5683 | ||
| @@ -5660,7 +5690,7 @@ my_png_error (png_ptr, msg) | |||
| 5660 | /* Avoid compiler warning about deprecated direct access to | 5690 | /* Avoid compiler warning about deprecated direct access to |
| 5661 | png_ptr's fields in libpng versions 1.4.x. */ | 5691 | png_ptr's fields in libpng versions 1.4.x. */ |
| 5662 | image_error ("PNG error: %s", build_string (msg), Qnil); | 5692 | image_error ("PNG error: %s", build_string (msg), Qnil); |
| 5663 | longjmp (png_ptr->jmpbuf, 1); | 5693 | PNG_LONGJMP (png_ptr); |
| 5664 | } | 5694 | } |
| 5665 | 5695 | ||
| 5666 | 5696 | ||
| @@ -5836,7 +5866,7 @@ png_load (f, img) | |||
| 5836 | 5866 | ||
| 5837 | /* Set error jump-back. We come back here when the PNG library | 5867 | /* Set error jump-back. We come back here when the PNG library |
| 5838 | detects an error. */ | 5868 | detects an error. */ |
| 5839 | if (setjmp (png_ptr->jmpbuf)) | 5869 | if (setjmp (PNG_JMPBUF (png_ptr))) |
| 5840 | { | 5870 | { |
| 5841 | error: | 5871 | error: |
| 5842 | if (png_ptr) | 5872 | if (png_ptr) |