diff --git a/admin/ChangeLog b/admin/ChangeLog index 56166ffa7ce..de3fc5f52d3 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog @@ -1,3 +1,8 @@ +2010-12-31 Eli Zaretskii + + * nt/README.W32: Update the information about PNG support libraries. + (Bug#7716) + 2010-05-07 Chong Yidong * Version 23.2 released. diff --git a/admin/nt/README.W32 b/admin/nt/README.W32 index 9f1df8abd3a..b8d2610b655 100644 --- a/admin/nt/README.W32 +++ b/admin/nt/README.W32 @@ -119,14 +119,19 @@ See the end of the file for license conditions. libXpm library from X11R7.3. Emacs can also support some other image formats with appropriate - libraries. These libraries are all available as part of GTK, or from - gnuwin32.sourceforge.net. Emacs will find them if the directory they - are installed in is on the PATH. + libraries. These libraries are all available as part of GTK + download for Windows (http://www.gtk.org/download-windows.html), or + from the GnuWin32 project. Emacs will find them if the directory + they are installed in is on the PATH. - PNG: requires the PNG reference library 1.2 or later, which will - be named libpng13d.dll, libpng13.dll, libpng12d.dll, libpng12.dll - or libpng.dll. LibPNG requires zlib, which should come from the same - source as you got libpng. + PNG: requires the PNG reference library 1.4 or later, which will + be named libpng14.dll or libpng14-14.dll. LibPNG requires zlib, + which should come from the same source as you got libpng. + Starting with Emacs 23.3, the precompiled Emacs binaries are + built with libpng 1.4.x and later, and are incompatible with + earlier versions of libpng DLLs. So if you have libpng 1.2.x, + the PNG support will not work, and you will have to download + newer versions. JPEG: requires the Independant JPEG Group's libjpeg 6b or later, which will be called jpeg62.dll, libjpeg.dll, jpeg-62.dll or jpeg.dll. @@ -137,6 +142,9 @@ See the end of the file for license conditions. GIF: requires libungif or giflib 4.1 or later, which will be called giflib4.dll, libungif4.dll or libungif.dll. + If you have image support DLLs under different names, customize the + value of `image-library-alist'. + In addition, Emacs can be compiled to support SVG. This precompiled distribution has not been compiled that way, since the SVG library or one or more of its extensive dependencies appear to be diff --git a/lisp/ChangeLog b/lisp/ChangeLog index dad4c68cffa..c38f6a87b14 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-12-31 Eli Zaretskii + + * term/w32-win.el (image-library-alist): Set up correctly for + libpng versions both before and after 1.4.0. (Bug#7716) + 2010-12-25 Eli Zaretskii * time.el (display-time-mode): Mention display-time-interval in diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el index 1779d1025e0..7bded5b8758 100644 --- a/lisp/term/w32-win.el +++ b/lisp/term/w32-win.el @@ -200,17 +200,25 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.") ;;; Set default known names for image libraries (setq image-library-alist - '((xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll") - (png "libpng12d.dll" "libpng12.dll" "libpng.dll" - ;; these are libpng 1.2.8 from GTK+ - "libpng13d.dll" "libpng13.dll") - (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll") - (tiff "libtiff3.dll" "libtiff.dll") - (gif "giflib4.dll" "libungif4.dll" "libungif.dll") - (svg "librsvg-2-2.dll") - (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll") - (glib "libglib-2.0-0.dll") - (gobject "libgobject-2.0-0.dll"))) + (list + '(xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll") + ;; Versions of libpng 1.4.x and later are incompatible with + ;; earlier versions. Set up the list of libraries according to + ;; the version we were compiled against. (If we were compiled + ;; without PNG support, libpng-version's value is -1.) + (if (>= libpng-version 10400) + ;; libpng14-14.dll is libpng 1.4.3 from GTK+ + '(png "libpng14-14.dll" "libpng14.dll") + '(png "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll" + ;; these are libpng 1.2.8 from GTK+ + "libpng13d.dll" "libpng13.dll")) + '(jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll") + '(tiff "libtiff3.dll" "libtiff.dll") + '(gif "giflib4.dll" "libungif4.dll" "libungif.dll") + '(svg "librsvg-2-2.dll") + '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll") + '(glib "libglib-2.0-0.dll") + '(gobject "libgobject-2.0-0.dll"))) ;;; multi-tty support (defvar w32-initialized nil diff --git a/nt/ChangeLog b/nt/ChangeLog index 24b421b4567..5ff3362ef96 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,3 +1,8 @@ +2010-12-31 Eli Zaretskii + + * INSTALL: Update the information about PNG support libraries. + (Bug#7716) + 2010-08-02 Óscar Fuentes * cmdproxy.c (main): Use _snprintf instead of wsprintf, diff --git a/nt/INSTALL b/nt/INSTALL index 83986c4e7c2..fafa9a97b6a 100644 --- a/nt/INSTALL +++ b/nt/INSTALL @@ -279,6 +279,23 @@ If GTK 2.0 is installed, addpm will arrange for its image libraries to be on the DLL search path for Emacs. + For PNG images, we recommend to use versions 1.4.x and later of + libpng, because previous versions had security issues. You can find + precompiled libraries and headers on the GTK download page for + Windows (http://www.gtk.org/download-windows.html). + + Versions 1.4.0 and later of libpng are binary incompatible with + earlier versions, so Emacs will only look for libpng libraries which + are compatible with the version it was compiled against. That + version is given by the value of the Lisp variable `libpng-version'; + e.g., 10403 means version 1.4.3. The variable `image-library-alist' + is automatically set to name only those DLL names that are known to + be compatible with the version given by `libpng-version'. If PNG + support does not work for you even though you have the support DLL + installed, check the name of the installed DLL against + `image-library-alist' and the value of `libpng-version', and + download compatible DLLs if needed. + * Experimental SVG support SVG support is currently experimental, and not built by default. diff --git a/src/ChangeLog b/src/ChangeLog index b4bafbce1b3..19cf253db7e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2010-12-31 Eli Zaretskii + + * image.c : 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. (Bug#7716) + 2010-12-27 Stefan Monnier * .gdbinit (xgetptr): Fix the union+lsb case. diff --git a/src/image.c b/src/image.c index 0fa0a0cd064..8fce8489bf7 100644 --- a/src/image.c +++ b/src/image.c @@ -94,6 +94,11 @@ typedef struct w32_bitmap_record Bitmap_Record; 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 @@ my_png_error (png_ptr, msg) 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 @@ png_load (f, img) 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 @@ non-numeric, there is no explicit limit on the size of images. */); 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);