diff options
| author | Paul Eggert | 2011-06-10 13:38:18 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-06-10 13:38:18 -0700 |
| commit | 109e28d0b3eaeaa92ef2030e2ef3b18462702e58 (patch) | |
| tree | 053e1c745c02f4ad659484ab80e0480f75465d35 /src/image.c | |
| parent | 529a133c390049085db38e7c8f745d650a2626ee (diff) | |
| parent | 60737f02aa2e76f7d1183158fa8d0a7d4aa89f64 (diff) | |
| download | emacs-109e28d0b3eaeaa92ef2030e2ef3b18462702e58.tar.gz emacs-109e28d0b3eaeaa92ef2030e2ef3b18462702e58.zip | |
Merge: Fix minor problems found by static checking.
* image.c (PixelGetMagickColor): Declare if ImageMagick headers don't.
Make identifiers static if they are not used in other modules.
* data.c (Qcompiled_function, Qframe, Qvector):
* image.c (QimageMagick, Qsvg):
* minibuf.c (Qmetadata):
* window.c (resize_window_check, resize_root_window): Now static.
* window.h (resize_window_check, resize_root_window): Remove decls.
* window.c (window_deletion_count, delete_deletable_window):
Remove; unused.
(window_body_lines): Now static.
(Fdelete_other_windows_internal): Mark vars as initialized.
Make sure 'resize_failed' is initialized.
(run_window_configuration_change_hook): Rename local to avoid shadowing.
(resize_window_apply): Remove unused local.
* window.h (delete_deletable_window): Remove decl.
* image.c (gif_load, svg_load_image): Rename locals to avoid shadowing.
(imagemagick_load_image): Fix pointer signedness problem by changing
last arg from unsigned char * to char *. All uses changed.
Also, fix a local for similar reasons.
Remove unused locals. Remove locals to avoid shadowing.
(fn_rsvg_handle_free): Remove; unused.
(svg_load, svg_load_image): Fix pointer signedness problem.
(imagemagick_load_image): Don't use garbage pointer image_wand.
* ftfont.c (ftfont_get_metrics, ftfont_drive_otf): Remove unused locals.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/src/image.c b/src/image.c index b6f54f01e95..f36e097b58c 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7146,12 +7146,12 @@ gif_load (struct frame *f, struct image *img) | |||
| 7146 | 7146 | ||
| 7147 | /* Which sub-image are we to display? */ | 7147 | /* Which sub-image are we to display? */ |
| 7148 | { | 7148 | { |
| 7149 | Lisp_Object index = image_spec_value (img->spec, QCindex, NULL); | 7149 | Lisp_Object image_number = image_spec_value (img->spec, QCindex, NULL); |
| 7150 | idx = INTEGERP (index) ? XFASTINT (index) : 0; | 7150 | idx = INTEGERP (image_number) ? XFASTINT (image_number) : 0; |
| 7151 | if (idx < 0 || idx >= gif->ImageCount) | 7151 | if (idx < 0 || idx >= gif->ImageCount) |
| 7152 | { | 7152 | { |
| 7153 | image_error ("Invalid image number `%s' in image `%s'", | 7153 | image_error ("Invalid image number `%s' in image `%s'", |
| 7154 | index, img->spec); | 7154 | image_number, img->spec); |
| 7155 | fn_DGifCloseFile (gif); | 7155 | fn_DGifCloseFile (gif); |
| 7156 | return 0; | 7156 | return 0; |
| 7157 | } | 7157 | } |
| @@ -7365,7 +7365,7 @@ gif_load (struct frame *f, struct image *img) | |||
| 7365 | ***********************************************************************/ | 7365 | ***********************************************************************/ |
| 7366 | #if defined (HAVE_IMAGEMAGICK) | 7366 | #if defined (HAVE_IMAGEMAGICK) |
| 7367 | 7367 | ||
| 7368 | Lisp_Object Qimagemagick; | 7368 | static Lisp_Object Qimagemagick; |
| 7369 | 7369 | ||
| 7370 | static int imagemagick_image_p (Lisp_Object); | 7370 | static int imagemagick_image_p (Lisp_Object); |
| 7371 | static int imagemagick_load (struct frame *, struct image *); | 7371 | static int imagemagick_load (struct frame *, struct image *); |
| @@ -7456,6 +7456,14 @@ imagemagick_image_p (Lisp_Object object) | |||
| 7456 | #define DrawRectangle DrawRectangleGif | 7456 | #define DrawRectangle DrawRectangleGif |
| 7457 | #include <wand/MagickWand.h> | 7457 | #include <wand/MagickWand.h> |
| 7458 | 7458 | ||
| 7459 | /* ImageMagick 6.5.3 through 6.6.5 hid PixelGetMagickColor for some reason. | ||
| 7460 | Emacs seems to work fine with the hidden version, so unhide it. */ | ||
| 7461 | #include <magick/version.h> | ||
| 7462 | #if 0x653 <= MagickLibVersion && MagickLibVersion <= 0x665 | ||
| 7463 | extern WandExport void PixelGetMagickColor (const PixelWand *, | ||
| 7464 | MagickPixelPacket *); | ||
| 7465 | #endif | ||
| 7466 | |||
| 7459 | /* Helper function for imagemagick_load, which does the actual loading | 7467 | /* Helper function for imagemagick_load, which does the actual loading |
| 7460 | given contents and size, apart from frame and image structures, | 7468 | given contents and size, apart from frame and image structures, |
| 7461 | passed from imagemagick_load. Uses librimagemagick to do most of | 7469 | passed from imagemagick_load. Uses librimagemagick to do most of |
| @@ -7471,7 +7479,7 @@ imagemagick_image_p (Lisp_Object object) | |||
| 7471 | static int | 7479 | static int |
| 7472 | imagemagick_load_image (struct frame *f, struct image *img, | 7480 | imagemagick_load_image (struct frame *f, struct image *img, |
| 7473 | unsigned char *contents, unsigned int size, | 7481 | unsigned char *contents, unsigned int size, |
| 7474 | unsigned char *filename) | 7482 | char *filename) |
| 7475 | { | 7483 | { |
| 7476 | unsigned long width; | 7484 | unsigned long width; |
| 7477 | unsigned long height; | 7485 | unsigned long height; |
| @@ -7479,8 +7487,6 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7479 | MagickBooleanType status; | 7487 | MagickBooleanType status; |
| 7480 | 7488 | ||
| 7481 | XImagePtr ximg; | 7489 | XImagePtr ximg; |
| 7482 | Lisp_Object specified_bg; | ||
| 7483 | XColor background; | ||
| 7484 | int x; | 7490 | int x; |
| 7485 | int y; | 7491 | int y; |
| 7486 | 7492 | ||
| @@ -7491,7 +7497,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7491 | MagickPixelPacket pixel; | 7497 | MagickPixelPacket pixel; |
| 7492 | Lisp_Object image; | 7498 | Lisp_Object image; |
| 7493 | Lisp_Object value; | 7499 | Lisp_Object value; |
| 7494 | Lisp_Object crop, geometry; | 7500 | Lisp_Object crop; |
| 7495 | long ino; | 7501 | long ino; |
| 7496 | int desired_width, desired_height; | 7502 | int desired_width, desired_height; |
| 7497 | double rotation; | 7503 | double rotation; |
| @@ -7552,23 +7558,18 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7552 | im_image = ReadImage (image_info, exception); | 7558 | im_image = ReadImage (image_info, exception); |
| 7553 | DestroyExceptionInfo (exception); | 7559 | DestroyExceptionInfo (exception); |
| 7554 | 7560 | ||
| 7555 | if (im_image != NULL) | 7561 | if (im_image == NULL) |
| 7556 | { | 7562 | goto imagemagick_no_wand; |
| 7557 | image_wand = NewMagickWandFromImage (im_image); | 7563 | image_wand = NewMagickWandFromImage (im_image); |
| 7558 | DestroyImage(im_image); | 7564 | DestroyImage(im_image); |
| 7559 | status = MagickTrue; | ||
| 7560 | } | ||
| 7561 | else | ||
| 7562 | status = MagickFalse; | ||
| 7563 | } | 7565 | } |
| 7564 | else | 7566 | else |
| 7565 | { | 7567 | { |
| 7566 | image_wand = NewMagickWand (); | 7568 | image_wand = NewMagickWand (); |
| 7567 | status = MagickReadImageBlob (image_wand, contents, size); | 7569 | if (MagickReadImageBlob (image_wand, contents, size) == MagickFalse) |
| 7570 | goto imagemagick_error; | ||
| 7568 | } | 7571 | } |
| 7569 | 7572 | ||
| 7570 | if (status == MagickFalse) goto imagemagick_error; | ||
| 7571 | |||
| 7572 | /* If width and/or height is set in the display spec assume we want | 7573 | /* If width and/or height is set in the display spec assume we want |
| 7573 | to scale to those values. If either h or w is unspecified, the | 7574 | to scale to those values. If either h or w is unspecified, the |
| 7574 | unspecified should be calculated from the specified to preserve | 7575 | unspecified should be calculated from the specified to preserve |
| @@ -7609,7 +7610,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7609 | than the alternatives, but it still reads the entire image into memory | 7610 | than the alternatives, but it still reads the entire image into memory |
| 7610 | before croping, which is aparently difficult to avoid when using | 7611 | before croping, which is aparently difficult to avoid when using |
| 7611 | imagemagick. */ | 7612 | imagemagick. */ |
| 7612 | int w, h, x, y; | 7613 | int w, h; |
| 7613 | w = XFASTINT (XCAR (crop)); | 7614 | w = XFASTINT (XCAR (crop)); |
| 7614 | crop = XCDR (crop); | 7615 | crop = XCDR (crop); |
| 7615 | if (CONSP (crop) && INTEGERP (XCAR (crop))) | 7616 | if (CONSP (crop) && INTEGERP (XCAR (crop))) |
| @@ -7723,7 +7724,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7723 | method is also well tested. Some aspects of this method are | 7724 | method is also well tested. Some aspects of this method are |
| 7724 | ad-hoc and needs to be more researched. */ | 7725 | ad-hoc and needs to be more researched. */ |
| 7725 | int imagedepth = 24;/*MagickGetImageDepth(image_wand);*/ | 7726 | int imagedepth = 24;/*MagickGetImageDepth(image_wand);*/ |
| 7726 | char* exportdepth = imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/ | 7727 | const char *exportdepth = imagedepth <= 8 ? "I" : "BGRP";/*"RGBP";*/ |
| 7727 | /* Try to create a x pixmap to hold the imagemagick pixmap. */ | 7728 | /* Try to create a x pixmap to hold the imagemagick pixmap. */ |
| 7728 | if (!x_create_x_image_and_pixmap (f, width, height, imagedepth, | 7729 | if (!x_create_x_image_and_pixmap (f, width, height, imagedepth, |
| 7729 | &ximg, &img->pixmap)) | 7730 | &ximg, &img->pixmap)) |
| @@ -7796,6 +7797,7 @@ imagemagick_load_image (struct frame *f, struct image *img, | |||
| 7796 | 7797 | ||
| 7797 | imagemagick_error: | 7798 | imagemagick_error: |
| 7798 | DestroyMagickWand (image_wand); | 7799 | DestroyMagickWand (image_wand); |
| 7800 | imagemagick_no_wand: | ||
| 7799 | MagickWandTerminus (); | 7801 | MagickWandTerminus (); |
| 7800 | /* TODO more cleanup. */ | 7802 | /* TODO more cleanup. */ |
| 7801 | image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec, Qnil); | 7803 | image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec, Qnil); |
| @@ -7825,7 +7827,7 @@ imagemagick_load (struct frame *f, struct image *img) | |||
| 7825 | image_error ("Cannot find image file `%s'", file_name, Qnil); | 7827 | image_error ("Cannot find image file `%s'", file_name, Qnil); |
| 7826 | return 0; | 7828 | return 0; |
| 7827 | } | 7829 | } |
| 7828 | success_p = imagemagick_load_image (f, img, 0, 0, SDATA (file)); | 7830 | success_p = imagemagick_load_image (f, img, 0, 0, SSDATA (file)); |
| 7829 | } | 7831 | } |
| 7830 | /* Else its not a file, its a lisp object. Load the image from a | 7832 | /* Else its not a file, its a lisp object. Load the image from a |
| 7831 | lisp object rather than a file. */ | 7833 | lisp object rather than a file. */ |
| @@ -7890,7 +7892,7 @@ static int svg_load_image (struct frame *, struct image *, | |||
| 7890 | 7892 | ||
| 7891 | /* The symbol `svg' identifying images of this type. */ | 7893 | /* The symbol `svg' identifying images of this type. */ |
| 7892 | 7894 | ||
| 7893 | Lisp_Object Qsvg; | 7895 | static Lisp_Object Qsvg; |
| 7894 | 7896 | ||
| 7895 | /* Indices of image specification fields in svg_format, below. */ | 7897 | /* Indices of image specification fields in svg_format, below. */ |
| 7896 | 7898 | ||
| @@ -7973,7 +7975,6 @@ DEF_IMGLIB_FN (void, rsvg_handle_get_dimensions); | |||
| 7973 | DEF_IMGLIB_FN (gboolean, rsvg_handle_write); | 7975 | DEF_IMGLIB_FN (gboolean, rsvg_handle_write); |
| 7974 | DEF_IMGLIB_FN (gboolean, rsvg_handle_close); | 7976 | DEF_IMGLIB_FN (gboolean, rsvg_handle_close); |
| 7975 | DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf); | 7977 | DEF_IMGLIB_FN (GdkPixbuf *, rsvg_handle_get_pixbuf); |
| 7976 | DEF_IMGLIB_FN (void, rsvg_handle_free); | ||
| 7977 | 7978 | ||
| 7978 | DEF_IMGLIB_FN (int, gdk_pixbuf_get_width); | 7979 | DEF_IMGLIB_FN (int, gdk_pixbuf_get_width); |
| 7979 | DEF_IMGLIB_FN (int, gdk_pixbuf_get_height); | 7980 | DEF_IMGLIB_FN (int, gdk_pixbuf_get_height); |
| @@ -8006,7 +8007,6 @@ init_svg_functions (Lisp_Object libraries) | |||
| 8006 | LOAD_IMGLIB_FN (library, rsvg_handle_write); | 8007 | LOAD_IMGLIB_FN (library, rsvg_handle_write); |
| 8007 | LOAD_IMGLIB_FN (library, rsvg_handle_close); | 8008 | LOAD_IMGLIB_FN (library, rsvg_handle_close); |
| 8008 | LOAD_IMGLIB_FN (library, rsvg_handle_get_pixbuf); | 8009 | LOAD_IMGLIB_FN (library, rsvg_handle_get_pixbuf); |
| 8009 | LOAD_IMGLIB_FN (library, rsvg_handle_free); | ||
| 8010 | 8010 | ||
| 8011 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_width); | 8011 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_width); |
| 8012 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_height); | 8012 | LOAD_IMGLIB_FN (gdklib, gdk_pixbuf_get_height); |
| @@ -8032,7 +8032,6 @@ init_svg_functions (Lisp_Object libraries) | |||
| 8032 | #define fn_rsvg_handle_write rsvg_handle_write | 8032 | #define fn_rsvg_handle_write rsvg_handle_write |
| 8033 | #define fn_rsvg_handle_close rsvg_handle_close | 8033 | #define fn_rsvg_handle_close rsvg_handle_close |
| 8034 | #define fn_rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf | 8034 | #define fn_rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf |
| 8035 | #define fn_rsvg_handle_free rsvg_handle_free | ||
| 8036 | 8035 | ||
| 8037 | #define fn_gdk_pixbuf_get_width gdk_pixbuf_get_width | 8036 | #define fn_gdk_pixbuf_get_width gdk_pixbuf_get_width |
| 8038 | #define fn_gdk_pixbuf_get_height gdk_pixbuf_get_height | 8037 | #define fn_gdk_pixbuf_get_height gdk_pixbuf_get_height |
| @@ -8074,7 +8073,7 @@ svg_load (struct frame *f, struct image *img) | |||
| 8074 | } | 8073 | } |
| 8075 | 8074 | ||
| 8076 | /* Read the entire file into memory. */ | 8075 | /* Read the entire file into memory. */ |
| 8077 | contents = slurp_file (SDATA (file), &size); | 8076 | contents = slurp_file (SSDATA (file), &size); |
| 8078 | if (contents == NULL) | 8077 | if (contents == NULL) |
| 8079 | { | 8078 | { |
| 8080 | image_error ("Error loading SVG image `%s'", img->spec, Qnil); | 8079 | image_error ("Error loading SVG image `%s'", img->spec, Qnil); |
| @@ -8117,7 +8116,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 8117 | { | 8116 | { |
| 8118 | RsvgHandle *rsvg_handle; | 8117 | RsvgHandle *rsvg_handle; |
| 8119 | RsvgDimensionData dimension_data; | 8118 | RsvgDimensionData dimension_data; |
| 8120 | GError *error = NULL; | 8119 | GError *err = NULL; |
| 8121 | GdkPixbuf *pixbuf; | 8120 | GdkPixbuf *pixbuf; |
| 8122 | int width; | 8121 | int width; |
| 8123 | int height; | 8122 | int height; |
| @@ -8136,13 +8135,13 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 8136 | rsvg_handle = fn_rsvg_handle_new (); | 8135 | rsvg_handle = fn_rsvg_handle_new (); |
| 8137 | 8136 | ||
| 8138 | /* Parse the contents argument and fill in the rsvg_handle. */ | 8137 | /* Parse the contents argument and fill in the rsvg_handle. */ |
| 8139 | fn_rsvg_handle_write (rsvg_handle, contents, size, &error); | 8138 | fn_rsvg_handle_write (rsvg_handle, contents, size, &err); |
| 8140 | if (error) goto rsvg_error; | 8139 | if (err) goto rsvg_error; |
| 8141 | 8140 | ||
| 8142 | /* The parsing is complete, rsvg_handle is ready to used, close it | 8141 | /* The parsing is complete, rsvg_handle is ready to used, close it |
| 8143 | for further writes. */ | 8142 | for further writes. */ |
| 8144 | fn_rsvg_handle_close (rsvg_handle, &error); | 8143 | fn_rsvg_handle_close (rsvg_handle, &err); |
| 8145 | if (error) goto rsvg_error; | 8144 | if (err) goto rsvg_error; |
| 8146 | 8145 | ||
| 8147 | fn_rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); | 8146 | fn_rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); |
| 8148 | if (! check_image_size (f, dimension_data.width, dimension_data.height)) | 8147 | if (! check_image_size (f, dimension_data.width, dimension_data.height)) |
| @@ -8182,7 +8181,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 8182 | color. */ | 8181 | color. */ |
| 8183 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 8182 | specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| 8184 | if (!STRINGP (specified_bg) | 8183 | if (!STRINGP (specified_bg) |
| 8185 | || !x_defined_color (f, SDATA (specified_bg), &background, 0)) | 8184 | || !x_defined_color (f, SSDATA (specified_bg), &background, 0)) |
| 8186 | { | 8185 | { |
| 8187 | #ifndef HAVE_NS | 8186 | #ifndef HAVE_NS |
| 8188 | background.pixel = FRAME_BACKGROUND_PIXEL (f); | 8187 | background.pixel = FRAME_BACKGROUND_PIXEL (f); |
| @@ -8257,7 +8256,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * | |||
| 8257 | /* FIXME: Use error->message so the user knows what is the actual | 8256 | /* FIXME: Use error->message so the user knows what is the actual |
| 8258 | problem with the image. */ | 8257 | problem with the image. */ |
| 8259 | image_error ("Error parsing SVG image `%s'", img->spec, Qnil); | 8258 | image_error ("Error parsing SVG image `%s'", img->spec, Qnil); |
| 8260 | fn_g_error_free (error); | 8259 | fn_g_error_free (err); |
| 8261 | return 0; | 8260 | return 0; |
| 8262 | } | 8261 | } |
| 8263 | 8262 | ||