emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-23 r100432: Fix png support to allow


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-23 r100432: Fix png support to allow compiling with libpng-1.5 (Bug#7908).
Date: Sat, 29 Jan 2011 16:28:26 -0500
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100432
committer: Chong Yidong <address@hidden>
branch nick: emacs-23
timestamp: Sat 2011-01-29 16:28:26 -0500
message:
  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.
modified:
  src/ChangeLog
  src/image.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-01-28 17:07:12 +0000
+++ b/src/ChangeLog     2011-01-29 21:28:26 +0000
@@ -1,3 +1,11 @@
+2011-01-29  Chong Yidong  <address@hidden>
+
+       * 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
+       (Bug#7908).
+
 2011-01-28  Chong Yidong  <address@hidden>
 
        * m/intel386.h: Define NO_ARG_ARRAY.  Suggested by Dan Nicolaescu.

=== modified file 'src/image.c'
--- a/src/image.c       2011-01-16 15:40:47 +0000
+++ b/src/image.c       2011-01-29 21:28:26 +0000
@@ -5590,6 +5590,11 @@
 DEF_IMGLIB_FN (png_read_end);
 DEF_IMGLIB_FN (png_error);
 
+#if (PNG_LIBPNG_VER >= 10500)
+DEF_IMGLIB_FN (png_longjmp);
+DEF_IMGLIB_FN (png_set_longjmp_fn);
+#endif /* libpng version >= 1.5 */
+
 static int
 init_png_functions (Lisp_Object libraries)
 {
@@ -5620,6 +5625,12 @@
   LOAD_IMGLIB_FN (library, png_read_image);
   LOAD_IMGLIB_FN (library, png_read_end);
   LOAD_IMGLIB_FN (library, png_error);
+
+#if (PNG_LIBPNG_VER >= 10500)
+  LOAD_IMGLIB_FN (library, png_longjmp);
+  LOAD_IMGLIB_FN (library, png_set_longjmp_fn);
+#endif /* libpng version >= 1.5 */
+
   return 1;
 }
 #else
@@ -5646,8 +5657,27 @@
 #define fn_png_read_end                        png_read_end
 #define fn_png_error                   png_error
 
+#if (PNG_LIBPNG_VER >= 10500)
+#define fn_png_longjmp                 png_longjmp
+#define fn_png_set_longjmp_fn          png_set_longjmp_fn
+#endif /* libpng version >= 1.5 */
+
 #endif /* HAVE_NTGUI */
 
+
+#if (PNG_LIBPNG_VER < 10500)
+#define PNG_LONGJMP(ptr) (longjmp (ptr->jmpbuf, 1))
+#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf)
+#else
+/* In libpng version 1.5, the jmpbuf member is hidden.
+   We need the extra cast for PNG_JMPBUF because, for Windows,
+   DEF_IMGLIB_FN defines the return value of fn_png_set_longjmp_fn to
+   be int (Bug#7908).  */
+#define PNG_LONGJMP(ptr) (fn_png_longjmp (png_ptr, 1))
+#define PNG_JMPBUF(ptr) \
+  (*(jmp_buf *)(fn_png_set_longjmp_fn((ptr), longjmp, sizeof (jmp_buf))))
+#endif
+
 /* Error and warning handlers installed when the PNG library
    is initialized.  */
 
@@ -5660,7 +5690,7 @@
   /* Avoid compiler warning about deprecated direct access to
      png_ptr's fields in libpng versions 1.4.x.  */
   image_error ("PNG error: %s", build_string (msg), Qnil);
-  longjmp (png_ptr->jmpbuf, 1);
+  PNG_LONGJMP (png_ptr);
 }
 
 
@@ -5836,7 +5866,7 @@
 
   /* Set error jump-back.  We come back here when the PNG library
      detects an error.  */
-  if (setjmp (png_ptr->jmpbuf))
+  if (setjmp (PNG_JMPBUF (png_ptr)))
     {
     error:
       if (png_ptr)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]