aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
authorPaul Eggert2016-09-29 20:09:37 -0700
committerPaul Eggert2016-09-29 20:13:40 -0700
commit3c2c50260e19deff2a0a054882eaea4049f25a2f (patch)
tree09b502d87a2ef0440bedd7ce676be26ea5730f14 /src/image.c
parentcbb2e845187bfbcc62e2accc9df7891a2326608a (diff)
downloademacs-3c2c50260e19deff2a0a054882eaea4049f25a2f.tar.gz
emacs-3c2c50260e19deff2a0a054882eaea4049f25a2f.zip
Fix problems found by static checking --with-ns
This is for Fedora 24 when configured with --enable-gcc-warnings. Although it does not fix all the problems, it fixes many of them. * src/frame.c (XParseGeometry): * src/nsterm.m (mouseDown:): Mark locals with UNINIT to pacify --enable-gcc-warnings. * src/image.c (PIX_MASK_DRAW, DefaultDepthOfScreen): Remove unused macros. (slurp_file xbm_scan, xbm_read_bitmap_data, xbm_load_image) (xbm_file_p, xbm_load, xpm_scan, xpm_make_color_table_v) (xpm_put_color_table_v, xpm_get_color_table_v) (xpm_make_color_table_h, xpm_put_color_table_h) (xpm_get_color_table_h, xpm_load_image, xpm_load) (pbm_next_char, pbm_scan_number, pbm_load, svg_load) (svg_load_image): * src/nsfns.m (x_get_string_resource): * src/nsimage.m (ns_image_from_XBM): Fix pointer signedness problems. * src/image.c (xpm_load_image, x_build_heuristic_mask, pbm_load) (imagemagick_load_image): Omit unused locals. * src/nsfns.m (ns_send_types, ns_return_types, ns_drag_types) (Fx_open_connection): * src/nsfont.m (ns_antialias_threshold): Move extern decl to nsterm.h so it can be checked. * src/nsmenu.m (svcsMenu, dockMenu): Move to the only file that uses them, so they can be static. * src/nsterm.h (find_and_call_menu_selection): * src/nsterm.m (x_set_frame_alpha): Omit duplicate decls. * src/nsterm.h (ns_dump_glyphstring): Mark as EXTERNALLY_VISIBLE. * src/nsfns.m (ns_tooltip, ns_display_info_for_name) (ns_set_name_as_filename, x_set_menu_bar_lines) (x_set_tool_bar_lines, x_set_internal_border_width): * src/nsterm.m (ns_drag_types, ns_draw_text_decoration): Now static. * src/nsfns.m (ns_lisp_to_cursor_type, ns_cursor_type_to_lisp): * src/nsterm.m (ns_free_indexed_color, ns_color_to_lisp): Remove; unused. * src/nsfont.m (ns_dump_glyphstring): * src/nsterm.m (hide_bell, ns_get_color, ns_color_to_lisp) (ns_clear_frame, keyDown:): Fix signedness problem with printf arg. * src/nsterm.h (ns_input_events, ns_finish_events): * src/nsterm.m (ns_finish_events, hide_bell): Prototype the decls. * src/nsterm.m (NSMenuDidBeginTrackingNotification): Omit unnecessary decl. (dockMenu): (mainMenu) [NS_IMPL_COCOA]: Now static, and in this file. (ns_dumpglyphs_box_or_relief, changeFont:, initFrameFromEmacs:) (toggleFullScreen:): Use FACE_FROM_ID instead of FACE_FROM_ID_OR_NULL in contexts where the caller expects the result to be non-null. (applicationShouldTerminate:): Fix misleading indentation.
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c175
1 files changed, 80 insertions, 95 deletions
diff --git a/src/image.c b/src/image.c
index 53ec3873632..e508550629c 100644
--- a/src/image.c
+++ b/src/image.c
@@ -97,11 +97,9 @@ typedef struct ns_bitmap_record Bitmap_Record;
97#define NO_PIXMAP 0 97#define NO_PIXMAP 0
98 98
99#define PIX_MASK_RETAIN 0 99#define PIX_MASK_RETAIN 0
100#define PIX_MASK_DRAW 1
101 100
102#define x_defined_color(f, name, color_def, alloc) \ 101#define x_defined_color(f, name, color_def, alloc) \
103 ns_defined_color (f, name, color_def, alloc, 0) 102 ns_defined_color (f, name, color_def, alloc, 0)
104#define DefaultDepthOfScreen(screen) x_display_list->n_planes
105#endif /* HAVE_NS */ 103#endif /* HAVE_NS */
106 104
107#if (defined HAVE_X_WINDOWS \ 105#if (defined HAVE_X_WINDOWS \
@@ -2333,12 +2331,12 @@ x_find_image_file (Lisp_Object file)
2333 occurred. FD is a file descriptor open for reading FILE. Set 2331 occurred. FD is a file descriptor open for reading FILE. Set
2334 *SIZE to the size of the file. */ 2332 *SIZE to the size of the file. */
2335 2333
2336static unsigned char * 2334static char *
2337slurp_file (int fd, ptrdiff_t *size) 2335slurp_file (int fd, ptrdiff_t *size)
2338{ 2336{
2339 FILE *fp = fdopen (fd, "rb"); 2337 FILE *fp = fdopen (fd, "rb");
2340 2338
2341 unsigned char *buf = NULL; 2339 char *buf = NULL;
2342 struct stat st; 2340 struct stat st;
2343 2341
2344 if (fp) 2342 if (fp)
@@ -2563,9 +2561,9 @@ xbm_image_p (Lisp_Object object)
2563 scanning a number, store its value in *IVAL. */ 2561 scanning a number, store its value in *IVAL. */
2564 2562
2565static int 2563static int
2566xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival) 2564xbm_scan (char **s, char *end, char *sval, int *ival)
2567{ 2565{
2568 unsigned int c; 2566 unsigned char c;
2569 2567
2570 loop: 2568 loop:
2571 2569
@@ -2617,7 +2615,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
2617 if (*s < end) 2615 if (*s < end)
2618 *s = *s - 1; 2616 *s = *s - 1;
2619 *ival = value; 2617 *ival = value;
2620 c = XBM_TK_NUMBER; 2618 return XBM_TK_NUMBER;
2621 } 2619 }
2622 else if (c_isalpha (c) || c == '_') 2620 else if (c_isalpha (c) || c == '_')
2623 { 2621 {
@@ -2628,7 +2626,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
2628 *sval = 0; 2626 *sval = 0;
2629 if (*s < end) 2627 if (*s < end)
2630 *s = *s - 1; 2628 *s = *s - 1;
2631 c = XBM_TK_IDENT; 2629 return XBM_TK_IDENT;
2632 } 2630 }
2633 else if (c == '/' && **s == '*') 2631 else if (c == '/' && **s == '*')
2634 { 2632 {
@@ -2765,11 +2763,11 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data,
2765 bitmap remains unread). */ 2763 bitmap remains unread). */
2766 2764
2767static bool 2765static bool
2768xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *end, 2766xbm_read_bitmap_data (struct frame *f, char *contents, char *end,
2769 int *width, int *height, char **data, 2767 int *width, int *height, char **data,
2770 bool inhibit_image_error) 2768 bool inhibit_image_error)
2771{ 2769{
2772 unsigned char *s = contents; 2770 char *s = contents;
2773 char buffer[BUFSIZ]; 2771 char buffer[BUFSIZ];
2774 bool padding_p = 0; 2772 bool padding_p = 0;
2775 bool v10 = 0; 2773 bool v10 = 0;
@@ -2926,8 +2924,7 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
2926 successful. */ 2924 successful. */
2927 2925
2928static bool 2926static bool
2929xbm_load_image (struct frame *f, struct image *img, unsigned char *contents, 2927xbm_load_image (struct frame *f, struct image *img, char *contents, char *end)
2930 unsigned char *end)
2931{ 2928{
2932 bool rc; 2929 bool rc;
2933 char *data; 2930 char *data;
@@ -2987,8 +2984,8 @@ xbm_file_p (Lisp_Object data)
2987{ 2984{
2988 int w, h; 2985 int w, h;
2989 return (STRINGP (data) 2986 return (STRINGP (data)
2990 && xbm_read_bitmap_data (NULL, SDATA (data), 2987 && xbm_read_bitmap_data (NULL, SSDATA (data),
2991 (SDATA (data) + SBYTES (data)), 2988 SSDATA (data) + SBYTES (data),
2992 &w, &h, NULL, 1)); 2989 &w, &h, NULL, 1));
2993} 2990}
2994 2991
@@ -3017,7 +3014,7 @@ xbm_load (struct frame *f, struct image *img)
3017 } 3014 }
3018 3015
3019 ptrdiff_t size; 3016 ptrdiff_t size;
3020 unsigned char *contents = slurp_file (fd, &size); 3017 char *contents = slurp_file (fd, &size);
3021 if (contents == NULL) 3018 if (contents == NULL)
3022 { 3019 {
3023 image_error ("Error loading XBM image `%s'", file); 3020 image_error ("Error loading XBM image `%s'", file);
@@ -3078,9 +3075,8 @@ xbm_load (struct frame *f, struct image *img)
3078 } 3075 }
3079 3076
3080 if (in_memory_file_p) 3077 if (in_memory_file_p)
3081 success_p = xbm_load_image (f, img, SDATA (data), 3078 success_p = xbm_load_image (f, img, SSDATA (data),
3082 (SDATA (data) 3079 SSDATA (data) + SBYTES (data));
3083 + SBYTES (data)));
3084 else 3080 else
3085 { 3081 {
3086 USE_SAFE_ALLOCA; 3082 USE_SAFE_ALLOCA;
@@ -3894,14 +3890,12 @@ xpm_load (struct frame *f, struct image *img)
3894/* XPM support functions for NS where libxpm is not available. 3890/* XPM support functions for NS where libxpm is not available.
3895 Only XPM version 3 (without any extensions) is supported. */ 3891 Only XPM version 3 (without any extensions) is supported. */
3896 3892
3897static void xpm_put_color_table_v (Lisp_Object, const unsigned char *, 3893static void xpm_put_color_table_v (Lisp_Object, const char *,
3898 int, Lisp_Object); 3894 int, Lisp_Object);
3899static Lisp_Object xpm_get_color_table_v (Lisp_Object, 3895static Lisp_Object xpm_get_color_table_v (Lisp_Object, const char *, int);
3900 const unsigned char *, int); 3896static void xpm_put_color_table_h (Lisp_Object, const char *,
3901static void xpm_put_color_table_h (Lisp_Object, const unsigned char *,
3902 int, Lisp_Object); 3897 int, Lisp_Object);
3903static Lisp_Object xpm_get_color_table_h (Lisp_Object, 3898static Lisp_Object xpm_get_color_table_h (Lisp_Object, const char *, int);
3904 const unsigned char *, int);
3905 3899
3906/* Tokens returned from xpm_scan. */ 3900/* Tokens returned from xpm_scan. */
3907 3901
@@ -3920,12 +3914,9 @@ enum xpm_token
3920 length of the corresponding token, respectively. */ 3914 length of the corresponding token, respectively. */
3921 3915
3922static int 3916static int
3923xpm_scan (const unsigned char **s, 3917xpm_scan (const char **s, const char *end, const char **beg, ptrdiff_t *len)
3924 const unsigned char *end,
3925 const unsigned char **beg,
3926 ptrdiff_t *len)
3927{ 3918{
3928 int c; 3919 unsigned char c;
3929 3920
3930 while (*s < end) 3921 while (*s < end)
3931 { 3922 {
@@ -3988,12 +3979,9 @@ xpm_scan (const unsigned char **s,
3988 hash table is used. */ 3979 hash table is used. */
3989 3980
3990static Lisp_Object 3981static Lisp_Object
3991xpm_make_color_table_v (void (**put_func) (Lisp_Object, 3982xpm_make_color_table_v (void (**put_func) (Lisp_Object, const char *, int,
3992 const unsigned char *,
3993 int,
3994 Lisp_Object), 3983 Lisp_Object),
3995 Lisp_Object (**get_func) (Lisp_Object, 3984 Lisp_Object (**get_func) (Lisp_Object, const char *,
3996 const unsigned char *,
3997 int)) 3985 int))
3998{ 3986{
3999 *put_func = xpm_put_color_table_v; 3987 *put_func = xpm_put_color_table_v;
@@ -4003,28 +3991,27 @@ xpm_make_color_table_v (void (**put_func) (Lisp_Object,
4003 3991
4004static void 3992static void
4005xpm_put_color_table_v (Lisp_Object color_table, 3993xpm_put_color_table_v (Lisp_Object color_table,
4006 const unsigned char *chars_start, 3994 const char *chars_start,
4007 int chars_len, 3995 int chars_len,
4008 Lisp_Object color) 3996 Lisp_Object color)
4009{ 3997{
4010 ASET (color_table, *chars_start, color); 3998 unsigned char uc = *chars_start;
3999 ASET (color_table, uc, color);
4011} 4000}
4012 4001
4013static Lisp_Object 4002static Lisp_Object
4014xpm_get_color_table_v (Lisp_Object color_table, 4003xpm_get_color_table_v (Lisp_Object color_table,
4015 const unsigned char *chars_start, 4004 const char *chars_start,
4016 int chars_len) 4005 int chars_len)
4017{ 4006{
4018 return AREF (color_table, *chars_start); 4007 unsigned char uc = *chars_start;
4008 return AREF (color_table, uc);
4019} 4009}
4020 4010
4021static Lisp_Object 4011static Lisp_Object
4022xpm_make_color_table_h (void (**put_func) (Lisp_Object, 4012xpm_make_color_table_h (void (**put_func) (Lisp_Object, const char *, int,
4023 const unsigned char *,
4024 int,
4025 Lisp_Object), 4013 Lisp_Object),
4026 Lisp_Object (**get_func) (Lisp_Object, 4014 Lisp_Object (**get_func) (Lisp_Object, const char *,
4027 const unsigned char *,
4028 int)) 4015 int))
4029{ 4016{
4030 *put_func = xpm_put_color_table_h; 4017 *put_func = xpm_put_color_table_h;
@@ -4037,7 +4024,7 @@ xpm_make_color_table_h (void (**put_func) (Lisp_Object,
4037 4024
4038static void 4025static void
4039xpm_put_color_table_h (Lisp_Object color_table, 4026xpm_put_color_table_h (Lisp_Object color_table,
4040 const unsigned char *chars_start, 4027 const char *chars_start,
4041 int chars_len, 4028 int chars_len,
4042 Lisp_Object color) 4029 Lisp_Object color)
4043{ 4030{
@@ -4051,7 +4038,7 @@ xpm_put_color_table_h (Lisp_Object color_table,
4051 4038
4052static Lisp_Object 4039static Lisp_Object
4053xpm_get_color_table_h (Lisp_Object color_table, 4040xpm_get_color_table_h (Lisp_Object color_table,
4054 const unsigned char *chars_start, 4041 const char *chars_start,
4055 int chars_len) 4042 int chars_len)
4056{ 4043{
4057 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table); 4044 struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
@@ -4085,20 +4072,22 @@ xpm_str_to_color_key (const char *s)
4085static bool 4072static bool
4086xpm_load_image (struct frame *f, 4073xpm_load_image (struct frame *f,
4087 struct image *img, 4074 struct image *img,
4088 const unsigned char *contents, 4075 const char *contents,
4089 const unsigned char *end) 4076 const char *end)
4090{ 4077{
4091 const unsigned char *s = contents, *beg, *str; 4078 const char *s = contents, *beg, *str;
4092 unsigned char buffer[BUFSIZ]; 4079 char buffer[BUFSIZ];
4093 int width, height, x, y; 4080 int width, height, x, y;
4094 int num_colors, chars_per_pixel; 4081 int num_colors, chars_per_pixel;
4095 ptrdiff_t len; 4082 ptrdiff_t len;
4096 int LA1; 4083 int LA1;
4097 void (*put_color_table) (Lisp_Object, const unsigned char *, int, Lisp_Object); 4084 void (*put_color_table) (Lisp_Object, const char *, int, Lisp_Object);
4098 Lisp_Object (*get_color_table) (Lisp_Object, const unsigned char *, int); 4085 Lisp_Object (*get_color_table) (Lisp_Object, const char *, int);
4099 Lisp_Object frame, color_symbols, color_table; 4086 Lisp_Object frame, color_symbols, color_table;
4100 int best_key; 4087 int best_key;
4088#ifndef HAVE_NS
4101 bool have_mask = false; 4089 bool have_mask = false;
4090#endif
4102 XImagePtr ximg = NULL, mask_img = NULL; 4091 XImagePtr ximg = NULL, mask_img = NULL;
4103 4092
4104#define match() \ 4093#define match() \
@@ -4337,7 +4326,7 @@ xpm_load (struct frame *f,
4337 } 4326 }
4338 4327
4339 ptrdiff_t size; 4328 ptrdiff_t size;
4340 unsigned char *contents = slurp_file (fd, &size); 4329 char *contents = slurp_file (fd, &size);
4341 if (contents == NULL) 4330 if (contents == NULL)
4342 { 4331 {
4343 image_error ("Error loading XPM image `%s'", file); 4332 image_error ("Error loading XPM image `%s'", file);
@@ -4357,8 +4346,8 @@ xpm_load (struct frame *f,
4357 image_error ("Invalid image data `%s'", data); 4346 image_error ("Invalid image data `%s'", data);
4358 return 0; 4347 return 0;
4359 } 4348 }
4360 success_p = xpm_load_image (f, img, SDATA (data), 4349 success_p = xpm_load_image (f, img, SSDATA (data),
4361 SDATA (data) + SBYTES (data)); 4350 SSDATA (data) + SBYTES (data));
4362 } 4351 }
4363 4352
4364 return success_p; 4353 return success_p;
@@ -5051,13 +5040,13 @@ static void
5051x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how) 5040x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
5052{ 5041{
5053 XImagePtr_or_DC ximg; 5042 XImagePtr_or_DC ximg;
5054#ifndef HAVE_NTGUI 5043#ifdef HAVE_NTGUI
5055 XImagePtr mask_img;
5056#else
5057 HGDIOBJ prev; 5044 HGDIOBJ prev;
5058 char *mask_img; 5045 char *mask_img;
5059 int row_width; 5046 int row_width;
5060#endif /* HAVE_NTGUI */ 5047#elif !defined HAVE_NS
5048 XImagePtr mask_img;
5049#endif
5061 int x, y; 5050 int x, y;
5062 bool use_img_background; 5051 bool use_img_background;
5063 unsigned long bg = 0; 5052 unsigned long bg = 0;
@@ -5232,20 +5221,22 @@ pbm_image_p (Lisp_Object object)
5232 end of input. */ 5221 end of input. */
5233 5222
5234static int 5223static int
5235pbm_next_char (unsigned char **s, unsigned char *end) 5224pbm_next_char (char **s, char *end)
5236{ 5225{
5237 int c = -1; 5226 while (*s < end)
5238
5239 while (*s < end && (c = *(*s)++, c == '#'))
5240 { 5227 {
5241 /* Skip to the next line break. */ 5228 unsigned char c = *(*s)++;
5242 while (*s < end && (c = *(*s)++, c != '\n' && c != '\r')) 5229 if (c != '#')
5243 ; 5230 return c;
5244 5231 while (*s < end)
5245 c = -1; 5232 {
5233 c = *(*s)++;
5234 if (c == '\n' || c == '\r')
5235 break;
5236 }
5246 } 5237 }
5247 5238
5248 return c; 5239 return -1;
5249} 5240}
5250 5241
5251 5242
@@ -5254,7 +5245,7 @@ pbm_next_char (unsigned char **s, unsigned char *end)
5254 end of input. */ 5245 end of input. */
5255 5246
5256static int 5247static int
5257pbm_scan_number (unsigned char **s, unsigned char *end) 5248pbm_scan_number (char **s, char *end)
5258{ 5249{
5259 int c = 0, val = -1; 5250 int c = 0, val = -1;
5260 5251
@@ -5284,12 +5275,9 @@ pbm_load (struct frame *f, struct image *img)
5284 int width, height, max_color_idx = 0; 5275 int width, height, max_color_idx = 0;
5285 Lisp_Object specified_file; 5276 Lisp_Object specified_file;
5286 enum {PBM_MONO, PBM_GRAY, PBM_COLOR} type; 5277 enum {PBM_MONO, PBM_GRAY, PBM_COLOR} type;
5287 unsigned char *contents = NULL; 5278 char *contents = NULL;
5288 unsigned char *end, *p; 5279 char *end, *p;
5289#ifdef USE_CAIRO 5280#ifndef USE_CAIRO
5290 unsigned char *data = 0;
5291 uint32_t *dataptr;
5292#else
5293 XImagePtr ximg; 5281 XImagePtr ximg;
5294#endif 5282#endif
5295 5283
@@ -5325,7 +5313,7 @@ pbm_load (struct frame *f, struct image *img)
5325 image_error ("Invalid image data `%s'", data); 5313 image_error ("Invalid image data `%s'", data);
5326 return 0; 5314 return 0;
5327 } 5315 }
5328 p = SDATA (data); 5316 p = SSDATA (data);
5329 end = p + SBYTES (data); 5317 end = p + SBYTES (data);
5330 } 5318 }
5331 5319
@@ -5376,8 +5364,8 @@ pbm_load (struct frame *f, struct image *img)
5376 height = pbm_scan_number (&p, end); 5364 height = pbm_scan_number (&p, end);
5377 5365
5378#ifdef USE_CAIRO 5366#ifdef USE_CAIRO
5379 data = (unsigned char *) xmalloc (width * height * 4); 5367 uint32_t *data = xmalloc (width * height * 4);
5380 dataptr = (uint32_t *) data; 5368 uint32_t *dataptr = data;
5381#endif 5369#endif
5382 5370
5383 if (type != PBM_MONO) 5371 if (type != PBM_MONO)
@@ -5406,7 +5394,8 @@ pbm_load (struct frame *f, struct image *img)
5406 5394
5407 if (type == PBM_MONO) 5395 if (type == PBM_MONO)
5408 { 5396 {
5409 int c = 0, g; 5397 unsigned char c = 0;
5398 int g;
5410 struct image_keyword fmt[PBM_LAST]; 5399 struct image_keyword fmt[PBM_LAST];
5411 unsigned long fg = FRAME_FOREGROUND_PIXEL (f); 5400 unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
5412 unsigned long bg = FRAME_BACKGROUND_PIXEL (f); 5401 unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
@@ -8534,7 +8523,6 @@ imagemagick_load_image (struct frame *f, struct image *img,
8534 EMACS_INT ino; 8523 EMACS_INT ino;
8535 int desired_width, desired_height; 8524 int desired_width, desired_height;
8536 double rotation; 8525 double rotation;
8537 int pixelwidth;
8538 char hint_buffer[MaxTextExtent]; 8526 char hint_buffer[MaxTextExtent];
8539 char *filename_hint = NULL; 8527 char *filename_hint = NULL;
8540 8528
@@ -8763,7 +8751,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8763 on rgb display. 8751 on rgb display.
8764 seems about 3 times as fast as pixel pushing(not carefully measured) 8752 seems about 3 times as fast as pixel pushing(not carefully measured)
8765 */ 8753 */
8766 pixelwidth = CharPixel; /*??? TODO figure out*/ 8754 int pixelwidth = CharPixel; /*??? TODO figure out*/
8767 MagickExportImagePixels (image_wand, 0, 0, width, height, 8755 MagickExportImagePixels (image_wand, 0, 0, width, height,
8768 exportdepth, pixelwidth, ximg->data); 8756 exportdepth, pixelwidth, ximg->data);
8769 } 8757 }
@@ -8947,7 +8935,7 @@ static bool svg_image_p (Lisp_Object object);
8947static bool svg_load (struct frame *f, struct image *img); 8935static bool svg_load (struct frame *f, struct image *img);
8948 8936
8949static bool svg_load_image (struct frame *, struct image *, 8937static bool svg_load_image (struct frame *, struct image *,
8950 unsigned char *, ptrdiff_t, char *); 8938 char *, ptrdiff_t, char *);
8951 8939
8952/* Indices of image specification fields in svg_format, below. */ 8940/* Indices of image specification fields in svg_format, below. */
8953 8941
@@ -9155,7 +9143,7 @@ svg_load (struct frame *f, struct image *img)
9155 9143
9156 /* Read the entire file into memory. */ 9144 /* Read the entire file into memory. */
9157 ptrdiff_t size; 9145 ptrdiff_t size;
9158 unsigned char *contents = slurp_file (fd, &size); 9146 char *contents = slurp_file (fd, &size);
9159 if (contents == NULL) 9147 if (contents == NULL)
9160 { 9148 {
9161 image_error ("Error loading SVG image `%s'", file); 9149 image_error ("Error loading SVG image `%s'", file);
@@ -9179,7 +9167,7 @@ svg_load (struct frame *f, struct image *img)
9179 return 0; 9167 return 0;
9180 } 9168 }
9181 original_filename = BVAR (current_buffer, filename); 9169 original_filename = BVAR (current_buffer, filename);
9182 success_p = svg_load_image (f, img, SDATA (data), SBYTES (data), 9170 success_p = svg_load_image (f, img, SSDATA (data), SBYTES (data),
9183 (NILP (original_filename) ? NULL 9171 (NILP (original_filename) ? NULL
9184 : SSDATA (original_filename))); 9172 : SSDATA (original_filename)));
9185 } 9173 }
@@ -9187,19 +9175,16 @@ svg_load (struct frame *f, struct image *img)
9187 return success_p; 9175 return success_p;
9188} 9176}
9189 9177
9190/* svg_load_image is a helper function for svg_load, which does the 9178/* Load frame F and image IMG. CONTENTS contains the SVG XML data to
9191 actual loading given contents and size, apart from frame and image 9179 be parsed, SIZE is its size, and FILENAME is the name of the SVG
9192 structures, passed from svg_load. 9180 file being loaded.
9193 9181
9194 Uses librsvg to do most of the image processing. 9182 Use librsvg to do most of the image processing.
9195 9183
9196 Returns true when successful. */ 9184 Return true when successful. */
9197static bool 9185static bool
9198svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */ 9186svg_load_image (struct frame *f, struct image *img, char *contents,
9199 struct image *img, /* Pointer to emacs image structure. */ 9187 ptrdiff_t size, char *filename)
9200 unsigned char *contents, /* String containing the SVG XML data to be parsed. */
9201 ptrdiff_t size, /* Size of data in bytes. */
9202 char *filename) /* Name of SVG file being loaded. */
9203{ 9188{
9204 RsvgHandle *rsvg_handle; 9189 RsvgHandle *rsvg_handle;
9205 RsvgDimensionData dimension_data; 9190 RsvgDimensionData dimension_data;
@@ -9226,7 +9211,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9226 rsvg_handle_set_base_uri(rsvg_handle, filename); 9211 rsvg_handle_set_base_uri(rsvg_handle, filename);
9227 9212
9228 /* Parse the contents argument and fill in the rsvg_handle. */ 9213 /* Parse the contents argument and fill in the rsvg_handle. */
9229 rsvg_handle_write (rsvg_handle, contents, size, &err); 9214 rsvg_handle_write (rsvg_handle, (unsigned char *) contents, size, &err);
9230 if (err) goto rsvg_error; 9215 if (err) goto rsvg_error;
9231 9216
9232 /* The parsing is complete, rsvg_handle is ready to used, close it 9217 /* The parsing is complete, rsvg_handle is ready to used, close it