aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schwab2011-01-30 00:56:33 +0100
committerAndreas Schwab2011-01-30 00:56:33 +0100
commitdf61c79005470fad666b3c3ae257eef1e06bd079 (patch)
tree08ee46acbb8455740257536bca5f17fe6e06dd8e
parentc2e79cb408e118b45ca4566f806d7fb81bb28a4e (diff)
downloademacs-df61c79005470fad666b3c3ae257eef1e06bd079.tar.gz
emacs-df61c79005470fad666b3c3ae257eef1e06bd079.zip
Fix use of pointers to image library functions
* src/image.c (DEF_IMGLIB_FN): Add parameter rettype, use it instead of int. All uses adjusted. (PNG_JMPBUF, png_load, jpeg_load, tiff_load, gif_load) (svg_load_image): Remove casts.
-rw-r--r--src/ChangeLog7
-rw-r--r--src/image.c197
2 files changed, 100 insertions, 104 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1d14be1ab70..af76f670e6c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12011-01-29 Andreas Schwab <schwab@linux-m68k.org>
2
3 * image.c (DEF_IMGLIB_FN): Add parameter rettype, use it instead
4 of int. All uses adjusted.
5 (PNG_JMPBUF, png_load, jpeg_load, tiff_load, gif_load)
6 (svg_load_image): Remove casts.
7
12011-01-29 Chong Yidong <cyd@stupidchicken.com> 82011-01-29 Chong Yidong <cyd@stupidchicken.com>
2 9
3 * image.c (fn_png_longjmp, fn_png_set_longjmp_fn): New png 10 * image.c (fn_png_longjmp, fn_png_set_longjmp_fn): New png
diff --git a/src/image.c b/src/image.c
index 91b33c45507..b814b795fab 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1977,7 +1977,7 @@ mark_image_cache (struct image_cache *c)
1977#ifdef HAVE_NTGUI 1977#ifdef HAVE_NTGUI
1978 1978
1979/* Macro for defining functions that will be loaded from image DLLs. */ 1979/* Macro for defining functions that will be loaded from image DLLs. */
1980#define DEF_IMGLIB_FN(func) int (FAR CDECL *fn_##func)() 1980#define DEF_IMGLIB_FN(rettype, func) rettype (FAR CDECL *fn_##func)()
1981 1981
1982/* Macro for loading those image functions from the library. */ 1982/* Macro for loading those image functions from the library. */
1983#define LOAD_IMGLIB_FN(lib,func) { \ 1983#define LOAD_IMGLIB_FN(lib,func) { \
@@ -3387,10 +3387,10 @@ xpm_free_colors (dpy, cmap, pixels, npixels, closure)
3387 3387
3388/* XPM library details. */ 3388/* XPM library details. */
3389 3389
3390DEF_IMGLIB_FN (XpmFreeAttributes); 3390DEF_IMGLIB_FN (void, XpmFreeAttributes);
3391DEF_IMGLIB_FN (XpmCreateImageFromBuffer); 3391DEF_IMGLIB_FN (int, XpmCreateImageFromBuffer);
3392DEF_IMGLIB_FN (XpmReadFileToImage); 3392DEF_IMGLIB_FN (int, XpmReadFileToImage);
3393DEF_IMGLIB_FN (XImageFree); 3393DEF_IMGLIB_FN (void, XImageFree);
3394 3394
3395static int 3395static int
3396init_xpm_functions (Lisp_Object libraries) 3396init_xpm_functions (Lisp_Object libraries)
@@ -5568,31 +5568,31 @@ png_image_p (object)
5568#ifdef HAVE_NTGUI 5568#ifdef HAVE_NTGUI
5569/* PNG library details. */ 5569/* PNG library details. */
5570 5570
5571DEF_IMGLIB_FN (png_get_io_ptr); 5571DEF_IMGLIB_FN (png_voidp, png_get_io_ptr);
5572DEF_IMGLIB_FN (png_sig_cmp); 5572DEF_IMGLIB_FN (int, png_sig_cmp);
5573DEF_IMGLIB_FN (png_create_read_struct); 5573DEF_IMGLIB_FN (png_structp, png_create_read_struct);
5574DEF_IMGLIB_FN (png_create_info_struct); 5574DEF_IMGLIB_FN (png_infop, png_create_info_struct);
5575DEF_IMGLIB_FN (png_destroy_read_struct); 5575DEF_IMGLIB_FN (void, png_destroy_read_struct);
5576DEF_IMGLIB_FN (png_set_read_fn); 5576DEF_IMGLIB_FN (void, png_set_read_fn);
5577DEF_IMGLIB_FN (png_set_sig_bytes); 5577DEF_IMGLIB_FN (void, png_set_sig_bytes);
5578DEF_IMGLIB_FN (png_read_info); 5578DEF_IMGLIB_FN (void, png_read_info);
5579DEF_IMGLIB_FN (png_get_IHDR); 5579DEF_IMGLIB_FN (png_uint_32, png_get_IHDR);
5580DEF_IMGLIB_FN (png_get_valid); 5580DEF_IMGLIB_FN (png_uint_32, png_get_valid);
5581DEF_IMGLIB_FN (png_set_strip_16); 5581DEF_IMGLIB_FN (void, png_set_strip_16);
5582DEF_IMGLIB_FN (png_set_expand); 5582DEF_IMGLIB_FN (void, png_set_expand);
5583DEF_IMGLIB_FN (png_set_gray_to_rgb); 5583DEF_IMGLIB_FN (void, png_set_gray_to_rgb);
5584DEF_IMGLIB_FN (png_set_background); 5584DEF_IMGLIB_FN (void, png_set_background);
5585DEF_IMGLIB_FN (png_get_bKGD); 5585DEF_IMGLIB_FN (png_uint_32, png_get_bKGD);
5586DEF_IMGLIB_FN (png_read_update_info); 5586DEF_IMGLIB_FN (void, png_read_update_info);
5587DEF_IMGLIB_FN (png_get_channels); 5587DEF_IMGLIB_FN (png_byte, png_get_channels);
5588DEF_IMGLIB_FN (png_get_rowbytes); 5588DEF_IMGLIB_FN (png_size_t, png_get_rowbytes);
5589DEF_IMGLIB_FN (png_read_image); 5589DEF_IMGLIB_FN (void, png_read_image);
5590DEF_IMGLIB_FN (png_read_end); 5590DEF_IMGLIB_FN (void, png_read_end);
5591DEF_IMGLIB_FN (png_error); 5591DEF_IMGLIB_FN (void, png_error);
5592 5592
5593#if (PNG_LIBPNG_VER >= 10500) 5593#if (PNG_LIBPNG_VER >= 10500)
5594DEF_IMGLIB_FN (png_longjmp); 5594DEF_IMGLIB_FN (void, png_longjmp);
5595DEF_IMGLIB_FN (png_set_longjmp_fn); 5595DEF_IMGLIB_FN (jmp_buf *, png_set_longjmp_fn);
5596#endif /* libpng version >= 1.5 */ 5596#endif /* libpng version >= 1.5 */
5597 5597
5598static int 5598static int
@@ -5669,13 +5669,10 @@ init_png_functions (Lisp_Object libraries)
5669#define PNG_LONGJMP(ptr) (longjmp ((ptr)->jmpbuf, 1)) 5669#define PNG_LONGJMP(ptr) (longjmp ((ptr)->jmpbuf, 1))
5670#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) 5670#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf)
5671#else 5671#else
5672/* In libpng version 1.5, the jmpbuf member is hidden. 5672/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */
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 ((ptr), 1)) 5673#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1))
5677#define PNG_JMPBUF(ptr) \ 5674#define PNG_JMPBUF(ptr) \
5678 (*(jmp_buf *)(fn_png_set_longjmp_fn((ptr), longjmp, sizeof (jmp_buf)))) 5675 (*fn_png_set_longjmp_fn((ptr), longjmp, sizeof (jmp_buf)))
5679#endif 5676#endif
5680 5677
5681/* Error and warning handlers installed when the PNG library 5678/* Error and warning handlers installed when the PNG library
@@ -5832,11 +5829,10 @@ png_load (f, img)
5832 tbr.bytes += sizeof (sig); 5829 tbr.bytes += sizeof (sig);
5833 } 5830 }
5834 5831
5835 /* Initialize read and info structs for PNG lib. Casting return 5832 /* Initialize read and info structs for PNG lib. */
5836 value avoids a GCC warning on W32. */ 5833 png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING,
5837 png_ptr = (png_structp)fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, 5834 NULL, my_png_error,
5838 NULL, my_png_error, 5835 my_png_warning);
5839 my_png_warning);
5840 if (!png_ptr) 5836 if (!png_ptr)
5841 { 5837 {
5842 if (fp) fclose (fp); 5838 if (fp) fclose (fp);
@@ -5844,8 +5840,7 @@ png_load (f, img)
5844 return 0; 5840 return 0;
5845 } 5841 }
5846 5842
5847 /* Casting return value avoids a GCC warning on W32. */ 5843 info_ptr = fn_png_create_info_struct (png_ptr);
5848 info_ptr = (png_infop)fn_png_create_info_struct (png_ptr);
5849 if (!info_ptr) 5844 if (!info_ptr)
5850 { 5845 {
5851 fn_png_destroy_read_struct (&png_ptr, NULL, NULL); 5846 fn_png_destroy_read_struct (&png_ptr, NULL, NULL);
@@ -5854,8 +5849,7 @@ png_load (f, img)
5854 return 0; 5849 return 0;
5855 } 5850 }
5856 5851
5857 /* Casting return value avoids a GCC warning on W32. */ 5852 end_info = fn_png_create_info_struct (png_ptr);
5858 end_info = (png_infop)fn_png_create_info_struct (png_ptr);
5859 if (!end_info) 5853 if (!end_info)
5860 { 5854 {
5861 fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL); 5855 fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
@@ -6222,14 +6216,14 @@ jpeg_image_p (object)
6222#ifdef HAVE_NTGUI 6216#ifdef HAVE_NTGUI
6223 6217
6224/* JPEG library details. */ 6218/* JPEG library details. */
6225DEF_IMGLIB_FN (jpeg_CreateDecompress); 6219DEF_IMGLIB_FN (void, jpeg_CreateDecompress);
6226DEF_IMGLIB_FN (jpeg_start_decompress); 6220DEF_IMGLIB_FN (boolean, jpeg_start_decompress);
6227DEF_IMGLIB_FN (jpeg_finish_decompress); 6221DEF_IMGLIB_FN (boolean, jpeg_finish_decompress);
6228DEF_IMGLIB_FN (jpeg_destroy_decompress); 6222DEF_IMGLIB_FN (void, jpeg_destroy_decompress);
6229DEF_IMGLIB_FN (jpeg_read_header); 6223DEF_IMGLIB_FN (int, jpeg_read_header);
6230DEF_IMGLIB_FN (jpeg_read_scanlines); 6224DEF_IMGLIB_FN (JDIMENSION, jpeg_read_scanlines);
6231DEF_IMGLIB_FN (jpeg_std_error); 6225DEF_IMGLIB_FN (struct jpeg_error_mgr *, jpeg_std_error);
6232DEF_IMGLIB_FN (jpeg_resync_to_restart); 6226DEF_IMGLIB_FN (boolean, jpeg_resync_to_restart);
6233 6227
6234static int 6228static int
6235init_jpeg_functions (Lisp_Object libraries) 6229init_jpeg_functions (Lisp_Object libraries)
@@ -6547,9 +6541,8 @@ jpeg_load (f, img)
6547 } 6541 }
6548 6542
6549 /* Customize libjpeg's error handling to call my_error_exit when an 6543 /* Customize libjpeg's error handling to call my_error_exit when an
6550 error is detected. This function will perform a longjmp. 6544 error is detected. This function will perform a longjmp. */
6551 Casting return value avoids a GCC warning on W32. */ 6545 cinfo.err = fn_jpeg_std_error (&mgr.pub);
6552 cinfo.err = (struct jpeg_error_mgr *)fn_jpeg_std_error (&mgr.pub);
6553 mgr.pub.error_exit = my_error_exit; 6546 mgr.pub.error_exit = my_error_exit;
6554 6547
6555 if ((rc = setjmp (mgr.setjmp_buffer)) != 0) 6548 if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
@@ -6777,14 +6770,14 @@ tiff_image_p (object)
6777#ifdef HAVE_NTGUI 6770#ifdef HAVE_NTGUI
6778 6771
6779/* TIFF library details. */ 6772/* TIFF library details. */
6780DEF_IMGLIB_FN (TIFFSetErrorHandler); 6773DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetErrorHandler);
6781DEF_IMGLIB_FN (TIFFSetWarningHandler); 6774DEF_IMGLIB_FN (TIFFErrorHandler, TIFFSetWarningHandler);
6782DEF_IMGLIB_FN (TIFFOpen); 6775DEF_IMGLIB_FN (TIFF *, TIFFOpen);
6783DEF_IMGLIB_FN (TIFFClientOpen); 6776DEF_IMGLIB_FN (TIFF *, TIFFClientOpen);
6784DEF_IMGLIB_FN (TIFFGetField); 6777DEF_IMGLIB_FN (int, TIFFGetField);
6785DEF_IMGLIB_FN (TIFFReadRGBAImage); 6778DEF_IMGLIB_FN (int, TIFFReadRGBAImage);
6786DEF_IMGLIB_FN (TIFFClose); 6779DEF_IMGLIB_FN (void, TIFFClose);
6787DEF_IMGLIB_FN (TIFFSetDirectory); 6780DEF_IMGLIB_FN (int, TIFFSetDirectory);
6788 6781
6789static int 6782static int
6790init_tiff_functions (Lisp_Object libraries) 6783init_tiff_functions (Lisp_Object libraries)
@@ -6994,9 +6987,8 @@ tiff_load (f, img)
6994 return 0; 6987 return 0;
6995 } 6988 }
6996 6989
6997 /* Try to open the image file. Casting return value avoids a 6990 /* Try to open the image file. */
6998 GCC warning on W32. */ 6991 tiff = fn_TIFFOpen (SDATA (file), "r");
6999 tiff = (TIFF *)fn_TIFFOpen (SDATA (file), "r");
7000 if (tiff == NULL) 6992 if (tiff == NULL)
7001 { 6993 {
7002 image_error ("Cannot open `%s'", file, Qnil); 6994 image_error ("Cannot open `%s'", file, Qnil);
@@ -7011,15 +7003,14 @@ tiff_load (f, img)
7011 memsrc.len = SBYTES (specified_data); 7003 memsrc.len = SBYTES (specified_data);
7012 memsrc.index = 0; 7004 memsrc.index = 0;
7013 7005
7014 /* Casting return value avoids a GCC warning on W32. */ 7006 tiff = fn_TIFFClientOpen ("memory_source", "r", &memsrc,
7015 tiff = (TIFF *)fn_TIFFClientOpen ("memory_source", "r", &memsrc, 7007 (TIFFReadWriteProc) tiff_read_from_memory,
7016 (TIFFReadWriteProc) tiff_read_from_memory, 7008 (TIFFReadWriteProc) tiff_write_from_memory,
7017 (TIFFReadWriteProc) tiff_write_from_memory, 7009 tiff_seek_in_memory,
7018 tiff_seek_in_memory, 7010 tiff_close_memory,
7019 tiff_close_memory, 7011 tiff_size_of_memory,
7020 tiff_size_of_memory, 7012 tiff_mmap_memory,
7021 tiff_mmap_memory, 7013 tiff_unmap_memory);
7022 tiff_unmap_memory);
7023 7014
7024 if (!tiff) 7015 if (!tiff)
7025 { 7016 {
@@ -7257,10 +7248,10 @@ gif_image_p (object)
7257#ifdef HAVE_NTGUI 7248#ifdef HAVE_NTGUI
7258 7249
7259/* GIF library details. */ 7250/* GIF library details. */
7260DEF_IMGLIB_FN (DGifCloseFile); 7251DEF_IMGLIB_FN (int, DGifCloseFile);
7261DEF_IMGLIB_FN (DGifSlurp); 7252DEF_IMGLIB_FN (int, DGifSlurp);
7262DEF_IMGLIB_FN (DGifOpen); 7253DEF_IMGLIB_FN (GifFileType *, DGifOpen);
7263DEF_IMGLIB_FN (DGifOpenFileName); 7254DEF_IMGLIB_FN (GifFileType *, DGifOpenFileName);
7264 7255
7265static int 7256static int
7266init_gif_functions (Lisp_Object libraries) 7257init_gif_functions (Lisp_Object libraries)
@@ -7358,9 +7349,8 @@ gif_load (f, img)
7358 return 0; 7349 return 0;
7359 } 7350 }
7360 7351
7361 /* Open the GIF file. Casting return value avoids a GCC warning 7352 /* Open the GIF file. */
7362 on W32. */ 7353 gif = fn_DGifOpenFileName (SDATA (file));
7363 gif = (GifFileType *)fn_DGifOpenFileName (SDATA (file));
7364 if (gif == NULL) 7354 if (gif == NULL)
7365 { 7355 {
7366 image_error ("Cannot open `%s'", file, Qnil); 7356 image_error ("Cannot open `%s'", file, Qnil);
@@ -7376,8 +7366,7 @@ gif_load (f, img)
7376 memsrc.len = SBYTES (specified_data); 7366 memsrc.len = SBYTES (specified_data);
7377 memsrc.index = 0; 7367 memsrc.index = 0;
7378 7368
7379 /* Casting return value avoids a GCC warning on W32. */ 7369 gif = fn_DGifOpen (&memsrc, gif_read_from_memory);
7380 gif = (GifFileType *) fn_DGifOpen (&memsrc, gif_read_from_memory);
7381 if (!gif) 7370 if (!gif)
7382 { 7371 {
7383 image_error ("Cannot open memory source `%s'", img->spec, Qnil); 7372 image_error ("Cannot open memory source `%s'", img->spec, Qnil);
@@ -7674,25 +7663,25 @@ svg_image_p (object)
7674#ifdef HAVE_NTGUI 7663#ifdef HAVE_NTGUI
7675 7664
7676/* SVG library functions. */ 7665/* SVG library functions. */
7677DEF_IMGLIB_FN (rsvg_handle_new); 7666DEF_IMGLIB_FN (RsvgHandle *, rsvg_handle_new);
7678DEF_IMGLIB_FN (rsvg_handle_get_dimensions); 7667DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions);
7679DEF_IMGLIB_FN (rsvg_handle_write); 7668DEF_IMGLIB_FN (gboolean, rsvg_handle_write);
7680DEF_IMGLIB_FN (rsvg_handle_close); 7669DEF_IMGLIB_FN (gboolean, rsvg_handle_close);
7681DEF_IMGLIB_FN (rsvg_handle_get_pixbuf); 7670DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf);
7682DEF_IMGLIB_FN (rsvg_handle_free); 7671DEF_IMGLIB_FN (void, rsvg_handle_free);
7683 7672
7684DEF_IMGLIB_FN (gdk_pixbuf_get_width); 7673DEF_IMGLIB_FN (int, gdk_pixbuf_get_width);
7685DEF_IMGLIB_FN (gdk_pixbuf_get_height); 7674DEF_IMGLIB_FN (int, gdk_pixbuf_get_height);
7686DEF_IMGLIB_FN (gdk_pixbuf_get_pixels); 7675DEF_IMGLIB_FN (guchar *, gdk_pixbuf_get_pixels);
7687DEF_IMGLIB_FN (gdk_pixbuf_get_rowstride); 7676DEF_IMGLIB_FN (int, gdk_pixbuf_get_rowstride);
7688DEF_IMGLIB_FN (gdk_pixbuf_get_colorspace); 7677DEF_IMGLIB_FN (GdkColorspace, gdk_pixbuf_get_colorspace);
7689DEF_IMGLIB_FN (gdk_pixbuf_get_n_channels); 7678DEF_IMGLIB_FN (int, gdk_pixbuf_get_n_channels);
7690DEF_IMGLIB_FN (gdk_pixbuf_get_has_alpha); 7679DEF_IMGLIB_FN (gboolean, gdk_pixbuf_get_has_alpha);
7691DEF_IMGLIB_FN (gdk_pixbuf_get_bits_per_sample); 7680DEF_IMGLIB_FN (int, gdk_pixbuf_get_bits_per_sample);
7692 7681
7693DEF_IMGLIB_FN (g_type_init); 7682DEF_IMGLIB_FN (void, g_type_init);
7694DEF_IMGLIB_FN (g_object_unref); 7683DEF_IMGLIB_FN (void, g_object_unref);
7695DEF_IMGLIB_FN (g_error_free); 7684DEF_IMGLIB_FN (void, g_error_free);
7696 7685
7697Lisp_Object Qgdk_pixbuf, Qglib, Qgobject; 7686Lisp_Object Qgdk_pixbuf, Qglib, Qgobject;
7698 7687
@@ -7846,7 +7835,7 @@ svg_load_image (f, img, contents, size)
7846 gnome type library functions. */ 7835 gnome type library functions. */
7847 fn_g_type_init (); 7836 fn_g_type_init ();
7848 /* Make a handle to a new rsvg object. */ 7837 /* Make a handle to a new rsvg object. */
7849 rsvg_handle = (RsvgHandle *) fn_rsvg_handle_new (); 7838 rsvg_handle = fn_rsvg_handle_new ();
7850 7839
7851 /* Parse the contents argument and fill in the rsvg_handle. */ 7840 /* Parse the contents argument and fill in the rsvg_handle. */
7852 fn_rsvg_handle_write (rsvg_handle, contents, size, &error); 7841 fn_rsvg_handle_write (rsvg_handle, contents, size, &error);
@@ -7866,14 +7855,14 @@ svg_load_image (f, img, contents, size)
7866 7855
7867 /* We can now get a valid pixel buffer from the svg file, if all 7856 /* We can now get a valid pixel buffer from the svg file, if all
7868 went ok. */ 7857 went ok. */
7869 pixbuf = (GdkPixbuf *) fn_rsvg_handle_get_pixbuf (rsvg_handle); 7858 pixbuf = fn_rsvg_handle_get_pixbuf (rsvg_handle);
7870 if (!pixbuf) goto rsvg_error; 7859 if (!pixbuf) goto rsvg_error;
7871 fn_g_object_unref (rsvg_handle); 7860 fn_g_object_unref (rsvg_handle);
7872 7861
7873 /* Extract some meta data from the svg handle. */ 7862 /* Extract some meta data from the svg handle. */
7874 width = fn_gdk_pixbuf_get_width (pixbuf); 7863 width = fn_gdk_pixbuf_get_width (pixbuf);
7875 height = fn_gdk_pixbuf_get_height (pixbuf); 7864 height = fn_gdk_pixbuf_get_height (pixbuf);
7876 pixels = (const guint8 *) fn_gdk_pixbuf_get_pixels (pixbuf); 7865 pixels = fn_gdk_pixbuf_get_pixels (pixbuf);
7877 rowstride = fn_gdk_pixbuf_get_rowstride (pixbuf); 7866 rowstride = fn_gdk_pixbuf_get_rowstride (pixbuf);
7878 7867
7879 /* Validate the svg meta data. */ 7868 /* Validate the svg meta data. */