diff options
| author | Eli Zaretskii | 2010-12-31 18:33:40 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2010-12-31 18:33:40 +0200 |
| commit | 18da2e74f0df222de51b24ac516deab2680814ec (patch) | |
| tree | 509cfabae3aef381d7a9c058f8d63991e8f0df1c /src | |
| parent | ca6e909ce36b365d705dd29e5c7f9a5a7904c719 (diff) | |
| download | emacs-18da2e74f0df222de51b24ac516deab2680814ec.tar.gz emacs-18da2e74f0df222de51b24ac516deab2680814ec.zip | |
More elegant solution for accessing png_ptr without GCC warnings.
image.c (png_jmpbuf): New macro.
(my_png_error, png_load): Use it instead of #ifdef'ing according
to PNG_LIBPNG_VER_MAJOR and PNG_LIBPNG_VER_MINOR.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 3 | ||||
| -rw-r--r-- | src/image.c | 18 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 19cf253db7e..acd579b9467 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -5,6 +5,9 @@ | |||
| 5 | version of PNG library we were compiled with. | 5 | version of PNG library we were compiled with. |
| 6 | (my_png_error, png_load): Avoid GCC warnings about direct access | 6 | (my_png_error, png_load): Avoid GCC warnings about direct access |
| 7 | to png_ptr->jmpbuf. (Bug#7716) | 7 | to png_ptr->jmpbuf. (Bug#7716) |
| 8 | (png_jmpbuf): New macro. | ||
| 9 | (my_png_error, png_load): Use it instead of #ifdef'ing according | ||
| 10 | to PNG_LIBPNG_VER_MAJOR and PNG_LIBPNG_VER_MINOR. | ||
| 8 | 11 | ||
| 9 | 2010-12-27 Stefan Monnier <monnier@iro.umontreal.ca> | 12 | 2010-12-27 Stefan Monnier <monnier@iro.umontreal.ca> |
| 10 | 13 | ||
diff --git a/src/image.c b/src/image.c index 8fce8489bf7..6842f27eed7 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -5648,6 +5648,12 @@ init_png_functions (Lisp_Object libraries) | |||
| 5648 | 5648 | ||
| 5649 | #endif /* HAVE_NTGUI */ | 5649 | #endif /* HAVE_NTGUI */ |
| 5650 | 5650 | ||
| 5651 | /* libpng before 1.4.0 didn't have png_jmpbuf; v1.4.0 and later | ||
| 5652 | deprecate direct access to png_ptr fields. */ | ||
| 5653 | #ifndef png_jmpbuf | ||
| 5654 | # define png_jmpbuf(PTR) ((PTR)->jmpbuf) | ||
| 5655 | #endif | ||
| 5656 | |||
| 5651 | /* Error and warning handlers installed when the PNG library | 5657 | /* Error and warning handlers installed when the PNG library |
| 5652 | is initialized. */ | 5658 | is initialized. */ |
| 5653 | 5659 | ||
| @@ -5660,12 +5666,7 @@ my_png_error (png_ptr, msg) | |||
| 5660 | /* Avoid compiler warning about deprecated direct access to | 5666 | /* Avoid compiler warning about deprecated direct access to |
| 5661 | png_ptr's fields in libpng versions 1.4.x. */ | 5667 | png_ptr's fields in libpng versions 1.4.x. */ |
| 5662 | image_error ("PNG error: %s", build_string (msg), Qnil); | 5668 | image_error ("PNG error: %s", build_string (msg), Qnil); |
| 5663 | #if PNG_LIBPNG_VER_MAJOR > 1 \ | ||
| 5664 | || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4) | ||
| 5665 | longjmp (png_jmpbuf (png_ptr), 1); | 5669 | longjmp (png_jmpbuf (png_ptr), 1); |
| 5666 | #else | ||
| 5667 | longjmp (png_ptr->jmpbuf, 1); | ||
| 5668 | #endif | ||
| 5669 | } | 5670 | } |
| 5670 | 5671 | ||
| 5671 | 5672 | ||
| @@ -5839,16 +5840,9 @@ png_load (f, img) | |||
| 5839 | return 0; | 5840 | return 0; |
| 5840 | } | 5841 | } |
| 5841 | 5842 | ||
| 5842 | /* Avoid compiler warning about deprecated direct access to | ||
| 5843 | png_ptr's fields in libpng versions 1.4.x. */ | ||
| 5844 | #if PNG_LIBPNG_VER_MAJOR > 1 \ | ||
| 5845 | || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4) | ||
| 5846 | /* Set error jump-back. We come back here when the PNG library | 5843 | /* Set error jump-back. We come back here when the PNG library |
| 5847 | detects an error. */ | 5844 | detects an error. */ |
| 5848 | if (setjmp (png_jmpbuf (png_ptr))) | 5845 | if (setjmp (png_jmpbuf (png_ptr))) |
| 5849 | #else | ||
| 5850 | if (setjmp (png_ptr->jmpbuf)) | ||
| 5851 | #endif | ||
| 5852 | { | 5846 | { |
| 5853 | error: | 5847 | error: |
| 5854 | if (png_ptr) | 5848 | if (png_ptr) |