diff src/image.c @ 112088:704900942a8e

Fix bug #7716 with PNG image support libraries on Windows. src/image.c <Qlibpng_version>: New variable. (syms_of_image): Intern and staticpro it. Set its value to the version of PNG library we were compiled with. (my_png_error, png_load): Avoid GCC warnings about direct access to png_ptr->jmpbuf. lisp/term/w32-win.el (image-library-alist): Set up correctly for libpng versions both before and after 1.4.0. admin/nt/README.W32: Update the information about PNG support libraries. nt/INSTALL: Update the information about PNG support libraries.
author Eli Zaretskii <eliz@gnu.org>
date Fri, 31 Dec 2010 14:38:06 +0200
parents 0792cbcb42ed
children 1d9002cd082f
line wrap: on
line diff
--- a/src/image.c	Thu Dec 30 20:39:41 2010 +0800
+++ b/src/image.c	Fri Dec 31 14:38:06 2010 +0200
@@ -94,6 +94,11 @@
    without modifying lots of files).  */
 extern void x_query_colors (struct frame *f, XColor *colors, int ncolors);
 extern void x_query_color (struct frame *f, XColor *color);
+
+/* Version of libpng that we were compiled with, or -1 if no PNG
+   support was compiled in.  This is tested by w32-win.el to correctly
+   set up the alist used to search for PNG libraries.  */
+Lisp_Object Qlibpng_version;
 #endif /* HAVE_NTGUI */
 
 #ifdef HAVE_NS
@@ -5652,8 +5657,15 @@
      char *msg;
 {
   xassert (png_ptr != NULL);
+  /* 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);
+#if PNG_LIBPNG_VER_MAJOR > 1					\
+  || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4)
+  longjmp (png_jmpbuf (png_ptr), 1);
+#else
   longjmp (png_ptr->jmpbuf, 1);
+#endif
 }
 
 
@@ -5827,9 +5839,16 @@
       return 0;
     }
 
+  /* Avoid compiler warning about deprecated direct access to
+     png_ptr's fields in libpng versions 1.4.x.  */
+#if PNG_LIBPNG_VER_MAJOR > 1					\
+  || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4)
   /* Set error jump-back.  We come back here when the PNG library
      detects an error.  */
+  if (setjmp (png_jmpbuf (png_ptr)))
+#else
   if (setjmp (png_ptr->jmpbuf))
+#endif
     {
     error:
       if (png_ptr)
@@ -8453,6 +8472,16 @@
   staticpro (&QCpt_height);
 #endif /* HAVE_GHOSTSCRIPT */
 
+#ifdef HAVE_NTGUI
+  Qlibpng_version = intern_c_string ("libpng-version");
+  staticpro (&Qlibpng_version);
+#if HAVE_PNG
+  SET_SYMBOL_VAL (XSYMBOL (Qlibpng_version), make_number (PNG_LIBPNG_VER));
+#else
+  SET_SYMBOL_VAL (XSYMBOL (Qlibpng_version), make_number (-1));
+#endif
+#endif
+
 #if defined (HAVE_XPM) || defined (HAVE_NS)
   Qxpm = intern_c_string ("xpm");
   staticpro (&Qxpm);