aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-08-13 13:48:28 -0700
committerPaul Eggert2015-08-13 13:48:58 -0700
commitfbee6265a72a4129d2efbf15a622b13e8b4aae9f (patch)
tree0c1e1e9724c323def043965a236bc021225a9cbd /src
parentb532875a6021cd1715321dda932b187522840944 (diff)
downloademacs-fbee6265a72a4129d2efbf15a622b13e8b4aae9f.tar.gz
emacs-fbee6265a72a4129d2efbf15a622b13e8b4aae9f.zip
Make add_to_log varargs
* src/alloc.c (run_finalizer_handler): * src/charset.c (load_charset_map_from_vector): * src/nsimage.m (ns_load_image): * src/xfaces.c (load_pixmap, load_color2): Simplify, now that add_to_log has a variable number of args. * src/image.c (image_error): Take a variable number of args. Callers simplified. * src/lisp.h (add_to_log, vadd_to_log): Adjust to new APIs. * src/xdisp.c (format_nargs, vadd_to_log): New functions. (add_to_log): Make varargs, and reimplement in terms of vadd_to_log. * src/xfaces.c (merge_face_ref): Fix typo that omitted color name.
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c2
-rw-r--r--src/charset.c2
-rw-r--r--src/image.c181
-rw-r--r--src/lisp.h3
-rw-r--r--src/nsimage.m2
-rw-r--r--src/xdisp.c51
-rw-r--r--src/xfaces.c8
7 files changed, 135 insertions, 114 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 050097c905a..66e62daf136 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3765,7 +3765,7 @@ queue_doomed_finalizers (struct Lisp_Finalizer *dest,
3765static Lisp_Object 3765static Lisp_Object
3766run_finalizer_handler (Lisp_Object args) 3766run_finalizer_handler (Lisp_Object args)
3767{ 3767{
3768 add_to_log ("finalizer failed: %S", args, Qnil); 3768 add_to_log ("finalizer failed: %S", args);
3769 return Qnil; 3769 return Qnil;
3770} 3770}
3771 3771
diff --git a/src/charset.c b/src/charset.c
index b19e34400fe..eeebf172bdf 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -555,7 +555,7 @@ load_charset_map_from_vector (struct charset *charset, Lisp_Object vec, int cont
555 555
556 if (len % 2 == 1) 556 if (len % 2 == 1)
557 { 557 {
558 add_to_log ("Failure in loading charset map: %V", vec, Qnil); 558 add_to_log ("Failure in loading charset map: %V", vec);
559 return; 559 return;
560 } 560 }
561 561
diff --git a/src/image.c b/src/image.c
index 066db74f786..313419b3232 100644
--- a/src/image.c
+++ b/src/image.c
@@ -629,16 +629,19 @@ valid_image_p (Lisp_Object object)
629} 629}
630 630
631 631
632/* Log error message with format string FORMAT and argument ARG. 632/* Log error message with format string FORMAT and trailing arguments.
633 Signaling an error, e.g. when an image cannot be loaded, is not a 633 Signaling an error, e.g. when an image cannot be loaded, is not a
634 good idea because this would interrupt redisplay, and the error 634 good idea because this would interrupt redisplay, and the error
635 message display would lead to another redisplay. This function 635 message display would lead to another redisplay. This function
636 therefore simply displays a message. */ 636 therefore simply displays a message. */
637 637
638static void 638static void
639image_error (const char *format, Lisp_Object arg1, Lisp_Object arg2) 639image_error (const char *format, ...)
640{ 640{
641 add_to_log (format, arg1, arg2); 641 va_list ap;
642 va_start (ap, format);
643 vadd_to_log (format, ap);
644 va_end (ap);
642} 645}
643 646
644 647
@@ -1954,7 +1957,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
1954 depth > 16 ? 32 : depth > 8 ? 16 : 8, 0); 1957 depth > 16 ? 32 : depth > 8 ? 16 : 8, 0);
1955 if (*ximg == NULL) 1958 if (*ximg == NULL)
1956 { 1959 {
1957 image_error ("Unable to allocate X image", Qnil, Qnil); 1960 image_error ("Unable to allocate X image");
1958 return 0; 1961 return 0;
1959 } 1962 }
1960 1963
@@ -1976,7 +1979,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
1976 { 1979 {
1977 x_destroy_x_image (*ximg); 1980 x_destroy_x_image (*ximg);
1978 *ximg = NULL; 1981 *ximg = NULL;
1979 image_error ("Unable to create X pixmap", Qnil, Qnil); 1982 image_error ("Unable to create X pixmap");
1980 return 0; 1983 return 0;
1981 } 1984 }
1982 1985
@@ -1997,7 +2000,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
1997 if (depth != 1 && depth != 4 && depth != 8 2000 if (depth != 1 && depth != 4 && depth != 8
1998 && depth != 16 && depth != 24 && depth != 32) 2001 && depth != 16 && depth != 24 && depth != 32)
1999 { 2002 {
2000 image_error ("Invalid image bit depth specified", Qnil, Qnil); 2003 image_error ("Invalid image bit depth specified");
2001 return 0; 2004 return 0;
2002 } 2005 }
2003 2006
@@ -2055,7 +2058,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
2055 Lisp_Object errcode; 2058 Lisp_Object errcode;
2056 /* All system errors are < 10000, so the following is safe. */ 2059 /* All system errors are < 10000, so the following is safe. */
2057 XSETINT (errcode, err); 2060 XSETINT (errcode, err);
2058 image_error ("Unable to create bitmap, error code %d", errcode, Qnil); 2061 image_error ("Unable to create bitmap, error code %d", errcode);
2059 x_destroy_x_image (*ximg); 2062 x_destroy_x_image (*ximg);
2060 *ximg = NULL; 2063 *ximg = NULL;
2061 return 0; 2064 return 0;
@@ -2070,7 +2073,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
2070 if (*pixmap == 0) 2073 if (*pixmap == 0)
2071 { 2074 {
2072 *ximg = NULL; 2075 *ximg = NULL;
2073 image_error ("Unable to allocate NSImage for XPM pixmap", Qnil, Qnil); 2076 image_error ("Unable to allocate NSImage for XPM pixmap");
2074 return 0; 2077 return 0;
2075 } 2078 }
2076 *ximg = *pixmap; 2079 *ximg = *pixmap;
@@ -2791,7 +2794,7 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
2791 if (!check_image_size (f, *width, *height)) 2794 if (!check_image_size (f, *width, *height))
2792 { 2795 {
2793 if (!inhibit_image_error) 2796 if (!inhibit_image_error)
2794 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 2797 image_error ("Invalid image size (see `max-image-size')");
2795 goto failure; 2798 goto failure;
2796 } 2799 }
2797 else if (data == NULL) 2800 else if (data == NULL)
@@ -2936,13 +2939,13 @@ xbm_load_image (struct frame *f, struct image *img, unsigned char *contents,
2936 if (img->pixmap == NO_PIXMAP) 2939 if (img->pixmap == NO_PIXMAP)
2937 { 2940 {
2938 x_clear_image (f, img); 2941 x_clear_image (f, img);
2939 image_error ("Unable to create X pixmap for `%s'", img->spec, Qnil); 2942 image_error ("Unable to create X pixmap for `%s'", img->spec);
2940 } 2943 }
2941 else 2944 else
2942 success_p = 1; 2945 success_p = 1;
2943 } 2946 }
2944 else 2947 else
2945 image_error ("Error loading XBM image `%s'", img->spec, Qnil); 2948 image_error ("Error loading XBM image `%s'", img->spec);
2946 2949
2947 return success_p; 2950 return success_p;
2948} 2951}
@@ -2983,14 +2986,14 @@ xbm_load (struct frame *f, struct image *img)
2983 file = x_find_image_file (file_name); 2986 file = x_find_image_file (file_name);
2984 if (!STRINGP (file)) 2987 if (!STRINGP (file))
2985 { 2988 {
2986 image_error ("Cannot find image file `%s'", file_name, Qnil); 2989 image_error ("Cannot find image file `%s'", file_name);
2987 return 0; 2990 return 0;
2988 } 2991 }
2989 2992
2990 contents = slurp_file (SSDATA (file), &size); 2993 contents = slurp_file (SSDATA (file), &size);
2991 if (contents == NULL) 2994 if (contents == NULL)
2992 { 2995 {
2993 image_error ("Error loading XBM image `%s'", img->spec, Qnil); 2996 image_error ("Error loading XBM image `%s'", img->spec);
2994 return 0; 2997 return 0;
2995 } 2998 }
2996 2999
@@ -3025,8 +3028,7 @@ xbm_load (struct frame *f, struct image *img)
3025 eassert (img->width > 0 && img->height > 0); 3028 eassert (img->width > 0 && img->height > 0);
3026 if (!check_image_size (f, img->width, img->height)) 3029 if (!check_image_size (f, img->width, img->height))
3027 { 3030 {
3028 image_error ("Invalid image size (see `max-image-size')", 3031 image_error ("Invalid image size (see `max-image-size')");
3029 Qnil, Qnil);
3030 return 0; 3032 return 0;
3031 } 3033 }
3032 } 3034 }
@@ -3104,7 +3106,7 @@ xbm_load (struct frame *f, struct image *img)
3104 else 3106 else
3105 { 3107 {
3106 image_error ("Unable to create pixmap for XBM image `%s'", 3108 image_error ("Unable to create pixmap for XBM image `%s'",
3107 img->spec, Qnil); 3109 img->spec);
3108 x_clear_image (f, img); 3110 x_clear_image (f, img);
3109 } 3111 }
3110 3112
@@ -3626,7 +3628,7 @@ xpm_load (struct frame *f, struct image *img)
3626 Lisp_Object file = x_find_image_file (specified_file); 3628 Lisp_Object file = x_find_image_file (specified_file);
3627 if (!STRINGP (file)) 3629 if (!STRINGP (file))
3628 { 3630 {
3629 image_error ("Cannot find image file `%s'", specified_file, Qnil); 3631 image_error ("Cannot find image file `%s'", specified_file);
3630#ifdef ALLOC_XPM_COLORS 3632#ifdef ALLOC_XPM_COLORS
3631 xpm_free_color_cache (); 3633 xpm_free_color_cache ();
3632#endif 3634#endif
@@ -3657,7 +3659,7 @@ xpm_load (struct frame *f, struct image *img)
3657 Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL); 3659 Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL);
3658 if (!STRINGP (buffer)) 3660 if (!STRINGP (buffer))
3659 { 3661 {
3660 image_error ("Invalid image data `%s'", buffer, Qnil); 3662 image_error ("Invalid image data `%s'", buffer);
3661#ifdef ALLOC_XPM_COLORS 3663#ifdef ALLOC_XPM_COLORS
3662 xpm_free_color_cache (); 3664 xpm_free_color_cache ();
3663#endif 3665#endif
@@ -3815,23 +3817,23 @@ xpm_load (struct frame *f, struct image *img)
3815 switch (rc) 3817 switch (rc)
3816 { 3818 {
3817 case XpmOpenFailed: 3819 case XpmOpenFailed:
3818 image_error ("Error opening XPM file (%s)", img->spec, Qnil); 3820 image_error ("Error opening XPM file (%s)", img->spec);
3819 break; 3821 break;
3820 3822
3821 case XpmFileInvalid: 3823 case XpmFileInvalid:
3822 image_error ("Invalid XPM file (%s)", img->spec, Qnil); 3824 image_error ("Invalid XPM file (%s)", img->spec);
3823 break; 3825 break;
3824 3826
3825 case XpmNoMemory: 3827 case XpmNoMemory:
3826 image_error ("Out of memory (%s)", img->spec, Qnil); 3828 image_error ("Out of memory (%s)", img->spec);
3827 break; 3829 break;
3828 3830
3829 case XpmColorFailed: 3831 case XpmColorFailed:
3830 image_error ("Color allocation error (%s)", img->spec, Qnil); 3832 image_error ("Color allocation error (%s)", img->spec);
3831 break; 3833 break;
3832 3834
3833 default: 3835 default:
3834 image_error ("Unknown error (%s)", img->spec, Qnil); 3836 image_error ("Unknown error (%s)", img->spec);
3835 break; 3837 break;
3836 } 3838 }
3837 } 3839 }
@@ -4101,7 +4103,7 @@ xpm_load_image (struct frame *f,
4101 4103
4102 if (!check_image_size (f, width, height)) 4104 if (!check_image_size (f, width, height))
4103 { 4105 {
4104 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 4106 image_error ("Invalid image size (see `max-image-size')");
4105 goto failure; 4107 goto failure;
4106 } 4108 }
4107 4109
@@ -4112,7 +4114,7 @@ xpm_load_image (struct frame *f,
4112#endif 4114#endif
4113 ) 4115 )
4114 { 4116 {
4115 image_error ("Image too large", Qnil, Qnil); 4117 image_error ("Image too large");
4116 goto failure; 4118 goto failure;
4117 } 4119 }
4118 4120
@@ -4262,7 +4264,7 @@ xpm_load_image (struct frame *f,
4262 return 1; 4264 return 1;
4263 4265
4264 failure: 4266 failure:
4265 image_error ("Invalid XPM file (%s)", img->spec, Qnil); 4267 image_error ("Invalid XPM file (%s)", img->spec);
4266 x_destroy_x_image (ximg); 4268 x_destroy_x_image (ximg);
4267 x_destroy_x_image (mask_img); 4269 x_destroy_x_image (mask_img);
4268 x_clear_image (f, img); 4270 x_clear_image (f, img);
@@ -4291,14 +4293,14 @@ xpm_load (struct frame *f,
4291 file = x_find_image_file (file_name); 4293 file = x_find_image_file (file_name);
4292 if (!STRINGP (file)) 4294 if (!STRINGP (file))
4293 { 4295 {
4294 image_error ("Cannot find image file `%s'", file_name, Qnil); 4296 image_error ("Cannot find image file `%s'", file_name);
4295 return 0; 4297 return 0;
4296 } 4298 }
4297 4299
4298 contents = slurp_file (SSDATA (file), &size); 4300 contents = slurp_file (SSDATA (file), &size);
4299 if (contents == NULL) 4301 if (contents == NULL)
4300 { 4302 {
4301 image_error ("Error loading XPM image `%s'", img->spec, Qnil); 4303 image_error ("Error loading XPM image `%s'", img->spec);
4302 return 0; 4304 return 0;
4303 } 4305 }
4304 4306
@@ -4312,7 +4314,7 @@ xpm_load (struct frame *f,
4312 data = image_spec_value (img->spec, QCdata, NULL); 4314 data = image_spec_value (img->spec, QCdata, NULL);
4313 if (!STRINGP (data)) 4315 if (!STRINGP (data))
4314 { 4316 {
4315 image_error ("Invalid image data `%s'", data, Qnil); 4317 image_error ("Invalid image data `%s'", data);
4316 return 0; 4318 return 0;
4317 } 4319 }
4318 success_p = xpm_load_image (f, img, SDATA (data), 4320 success_p = xpm_load_image (f, img, SDATA (data),
@@ -4734,7 +4736,7 @@ XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
4734 *pixel = *pixel & ~(1 << x % 8); 4736 *pixel = *pixel & ~(1 << x % 8);
4735 } 4737 }
4736 else 4738 else
4737 image_error ("XPutPixel: palette image not supported", Qnil, Qnil); 4739 image_error ("XPutPixel: palette image not supported");
4738} 4740}
4739 4741
4740#endif /* HAVE_NTGUI */ 4742#endif /* HAVE_NTGUI */
@@ -5266,14 +5268,14 @@ pbm_load (struct frame *f, struct image *img)
5266 file = x_find_image_file (specified_file); 5268 file = x_find_image_file (specified_file);
5267 if (!STRINGP (file)) 5269 if (!STRINGP (file))
5268 { 5270 {
5269 image_error ("Cannot find image file `%s'", specified_file, Qnil); 5271 image_error ("Cannot find image file `%s'", specified_file);
5270 return 0; 5272 return 0;
5271 } 5273 }
5272 5274
5273 contents = slurp_file (SSDATA (file), &size); 5275 contents = slurp_file (SSDATA (file), &size);
5274 if (contents == NULL) 5276 if (contents == NULL)
5275 { 5277 {
5276 image_error ("Error reading `%s'", file, Qnil); 5278 image_error ("Error reading `%s'", file);
5277 return 0; 5279 return 0;
5278 } 5280 }
5279 5281
@@ -5286,7 +5288,7 @@ pbm_load (struct frame *f, struct image *img)
5286 data = image_spec_value (img->spec, QCdata, NULL); 5288 data = image_spec_value (img->spec, QCdata, NULL);
5287 if (!STRINGP (data)) 5289 if (!STRINGP (data))
5288 { 5290 {
5289 image_error ("Invalid image data `%s'", data, Qnil); 5291 image_error ("Invalid image data `%s'", data);
5290 return 0; 5292 return 0;
5291 } 5293 }
5292 p = SDATA (data); 5294 p = SDATA (data);
@@ -5296,7 +5298,7 @@ pbm_load (struct frame *f, struct image *img)
5296 /* Check magic number. */ 5298 /* Check magic number. */
5297 if (end - p < 2 || *p++ != 'P') 5299 if (end - p < 2 || *p++ != 'P')
5298 { 5300 {
5299 image_error ("Not a PBM image: `%s'", img->spec, Qnil); 5301 image_error ("Not a PBM image: `%s'", img->spec);
5300 error: 5302 error:
5301 xfree (contents); 5303 xfree (contents);
5302 img->pixmap = NO_PIXMAP; 5304 img->pixmap = NO_PIXMAP;
@@ -5330,7 +5332,7 @@ pbm_load (struct frame *f, struct image *img)
5330 break; 5332 break;
5331 5333
5332 default: 5334 default:
5333 image_error ("Not a PBM image: `%s'", img->spec, Qnil); 5335 image_error ("Not a PBM image: `%s'", img->spec);
5334 goto error; 5336 goto error;
5335 } 5337 }
5336 5338
@@ -5349,14 +5351,14 @@ pbm_load (struct frame *f, struct image *img)
5349 max_color_idx = pbm_scan_number (&p, end); 5351 max_color_idx = pbm_scan_number (&p, end);
5350 if (max_color_idx > 65535 || max_color_idx < 0) 5352 if (max_color_idx > 65535 || max_color_idx < 0)
5351 { 5353 {
5352 image_error ("Unsupported maximum PBM color value", Qnil, Qnil); 5354 image_error ("Unsupported maximum PBM color value");
5353 goto error; 5355 goto error;
5354 } 5356 }
5355 } 5357 }
5356 5358
5357 if (!check_image_size (f, width, height)) 5359 if (!check_image_size (f, width, height))
5358 { 5360 {
5359 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 5361 image_error ("Invalid image size (see `max-image-size')");
5360 goto error; 5362 goto error;
5361 } 5363 }
5362 5364
@@ -5430,7 +5432,7 @@ pbm_load (struct frame *f, struct image *img)
5430#endif 5432#endif
5431 x_clear_image (f, img); 5433 x_clear_image (f, img);
5432 image_error ("Invalid image size in image `%s'", 5434 image_error ("Invalid image size in image `%s'",
5433 img->spec, Qnil); 5435 img->spec);
5434 goto error; 5436 goto error;
5435 } 5437 }
5436 c = *p++; 5438 c = *p++;
@@ -5465,7 +5467,7 @@ pbm_load (struct frame *f, struct image *img)
5465#endif 5467#endif
5466 x_clear_image (f, img); 5468 x_clear_image (f, img);
5467 image_error ("Invalid image size in image `%s'", 5469 image_error ("Invalid image size in image `%s'",
5468 img->spec, Qnil); 5470 img->spec);
5469 goto error; 5471 goto error;
5470 } 5472 }
5471 5473
@@ -5509,7 +5511,7 @@ pbm_load (struct frame *f, struct image *img)
5509 x_destroy_x_image (ximg); 5511 x_destroy_x_image (ximg);
5510#endif 5512#endif
5511 image_error ("Invalid pixel value in image `%s'", 5513 image_error ("Invalid pixel value in image `%s'",
5512 img->spec, Qnil); 5514 img->spec);
5513 goto error; 5515 goto error;
5514 } 5516 }
5515 5517
@@ -5800,7 +5802,7 @@ my_png_error (png_struct *png_ptr, const char *msg)
5800 eassert (png_ptr != NULL); 5802 eassert (png_ptr != NULL);
5801 /* Avoid compiler warning about deprecated direct access to 5803 /* Avoid compiler warning about deprecated direct access to
5802 png_ptr's fields in libpng versions 1.4.x. */ 5804 png_ptr's fields in libpng versions 1.4.x. */
5803 image_error ("PNG error: %s", build_string (msg), Qnil); 5805 image_error ("PNG error: %s", build_string (msg));
5804 PNG_LONGJMP (png_ptr); 5806 PNG_LONGJMP (png_ptr);
5805} 5807}
5806 5808
@@ -5809,7 +5811,7 @@ static void
5809my_png_warning (png_struct *png_ptr, const char *msg) 5811my_png_warning (png_struct *png_ptr, const char *msg)
5810{ 5812{
5811 eassert (png_ptr != NULL); 5813 eassert (png_ptr != NULL);
5812 image_error ("PNG warning: %s", build_string (msg), Qnil); 5814 image_error ("PNG warning: %s", build_string (msg));
5813} 5815}
5814 5816
5815/* Memory source for PNG decoding. */ 5817/* Memory source for PNG decoding. */
@@ -5904,7 +5906,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5904 file = x_find_image_file (specified_file); 5906 file = x_find_image_file (specified_file);
5905 if (!STRINGP (file)) 5907 if (!STRINGP (file))
5906 { 5908 {
5907 image_error ("Cannot find image file `%s'", specified_file, Qnil); 5909 image_error ("Cannot find image file `%s'", specified_file);
5908 return 0; 5910 return 0;
5909 } 5911 }
5910 5912
@@ -5912,7 +5914,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5912 fp = emacs_fopen (SSDATA (file), "rb"); 5914 fp = emacs_fopen (SSDATA (file), "rb");
5913 if (!fp) 5915 if (!fp)
5914 { 5916 {
5915 image_error ("Cannot open image file `%s'", file, Qnil); 5917 image_error ("Cannot open image file `%s'", file);
5916 return 0; 5918 return 0;
5917 } 5919 }
5918 5920
@@ -5921,7 +5923,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5921 || png_sig_cmp (sig, 0, sizeof sig)) 5923 || png_sig_cmp (sig, 0, sizeof sig))
5922 { 5924 {
5923 fclose (fp); 5925 fclose (fp);
5924 image_error ("Not a PNG file: `%s'", file, Qnil); 5926 image_error ("Not a PNG file: `%s'", file);
5925 return 0; 5927 return 0;
5926 } 5928 }
5927 } 5929 }
@@ -5929,7 +5931,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5929 { 5931 {
5930 if (!STRINGP (specified_data)) 5932 if (!STRINGP (specified_data))
5931 { 5933 {
5932 image_error ("Invalid image data `%s'", specified_data, Qnil); 5934 image_error ("Invalid image data `%s'", specified_data);
5933 return 0; 5935 return 0;
5934 } 5936 }
5935 5937
@@ -5942,7 +5944,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
5942 if (tbr.len < sizeof sig 5944 if (tbr.len < sizeof sig
5943 || png_sig_cmp (tbr.bytes, 0, sizeof sig)) 5945 || png_sig_cmp (tbr.bytes, 0, sizeof sig))
5944 { 5946 {
5945 image_error ("Not a PNG image: `%s'", img->spec, Qnil); 5947 image_error ("Not a PNG image: `%s'", img->spec);
5946 return 0; 5948 return 0;
5947 } 5949 }
5948 5950
@@ -6010,7 +6012,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c)
6010 if (! (width <= INT_MAX && height <= INT_MAX 6012 if (! (width <= INT_MAX && height <= INT_MAX
6011 && check_image_size (f, width, height))) 6013 && check_image_size (f, width, height)))
6012 { 6014 {
6013 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 6015 image_error ("Invalid image size (see `max-image-size')");
6014 goto error; 6016 goto error;
6015 } 6017 }
6016 6018
@@ -6668,20 +6670,20 @@ jpeg_load_body (struct frame *f, struct image *img,
6668 file = x_find_image_file (specified_file); 6670 file = x_find_image_file (specified_file);
6669 if (!STRINGP (file)) 6671 if (!STRINGP (file))
6670 { 6672 {
6671 image_error ("Cannot find image file `%s'", specified_file, Qnil); 6673 image_error ("Cannot find image file `%s'", specified_file);
6672 return 0; 6674 return 0;
6673 } 6675 }
6674 6676
6675 fp = emacs_fopen (SSDATA (file), "rb"); 6677 fp = emacs_fopen (SSDATA (file), "rb");
6676 if (fp == NULL) 6678 if (fp == NULL)
6677 { 6679 {
6678 image_error ("Cannot open `%s'", file, Qnil); 6680 image_error ("Cannot open `%s'", file);
6679 return 0; 6681 return 0;
6680 } 6682 }
6681 } 6683 }
6682 else if (!STRINGP (specified_data)) 6684 else if (!STRINGP (specified_data))
6683 { 6685 {
6684 image_error ("Invalid image data `%s'", specified_data, Qnil); 6686 image_error ("Invalid image data `%s'", specified_data);
6685 return 0; 6687 return 0;
6686 } 6688 }
6687 6689
@@ -6703,7 +6705,7 @@ jpeg_load_body (struct frame *f, struct image *img,
6703 } 6705 }
6704 6706
6705 case MY_JPEG_INVALID_IMAGE_SIZE: 6707 case MY_JPEG_INVALID_IMAGE_SIZE:
6706 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 6708 image_error ("Invalid image size (see `max-image-size')");
6707 break; 6709 break;
6708 6710
6709 case MY_JPEG_CANNOT_CREATE_X: 6711 case MY_JPEG_CANNOT_CREATE_X:
@@ -7183,7 +7185,7 @@ tiff_load (struct frame *f, struct image *img)
7183 file = x_find_image_file (specified_file); 7185 file = x_find_image_file (specified_file);
7184 if (!STRINGP (file)) 7186 if (!STRINGP (file))
7185 { 7187 {
7186 image_error ("Cannot find image file `%s'", specified_file, Qnil); 7188 image_error ("Cannot find image file `%s'", specified_file);
7187 return 0; 7189 return 0;
7188 } 7190 }
7189# ifdef WINDOWSNT 7191# ifdef WINDOWSNT
@@ -7194,7 +7196,7 @@ tiff_load (struct frame *f, struct image *img)
7194 tiff = TIFFOpen (SSDATA (file), "r"); 7196 tiff = TIFFOpen (SSDATA (file), "r");
7195 if (tiff == NULL) 7197 if (tiff == NULL)
7196 { 7198 {
7197 image_error ("Cannot open `%s'", file, Qnil); 7199 image_error ("Cannot open `%s'", file);
7198 return 0; 7200 return 0;
7199 } 7201 }
7200 } 7202 }
@@ -7202,7 +7204,7 @@ tiff_load (struct frame *f, struct image *img)
7202 { 7204 {
7203 if (!STRINGP (specified_data)) 7205 if (!STRINGP (specified_data))
7204 { 7206 {
7205 image_error ("Invalid image data `%s'", specified_data, Qnil); 7207 image_error ("Invalid image data `%s'", specified_data);
7206 return 0; 7208 return 0;
7207 } 7209 }
7208 7210
@@ -7222,7 +7224,7 @@ tiff_load (struct frame *f, struct image *img)
7222 7224
7223 if (!tiff) 7225 if (!tiff)
7224 { 7226 {
7225 image_error ("Cannot open memory source for `%s'", img->spec, Qnil); 7227 image_error ("Cannot open memory source for `%s'", img->spec);
7226 return 0; 7228 return 0;
7227 } 7229 }
7228 } 7230 }
@@ -7248,7 +7250,7 @@ tiff_load (struct frame *f, struct image *img)
7248 7250
7249 if (!check_image_size (f, width, height)) 7251 if (!check_image_size (f, width, height))
7250 { 7252 {
7251 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 7253 image_error ("Invalid image size (see `max-image-size')");
7252 TIFFClose (tiff); 7254 TIFFClose (tiff);
7253 return 0; 7255 return 0;
7254 } 7256 }
@@ -7278,7 +7280,7 @@ tiff_load (struct frame *f, struct image *img)
7278 TIFFClose (tiff); 7280 TIFFClose (tiff);
7279 if (!rc) 7281 if (!rc)
7280 { 7282 {
7281 image_error ("Error reading TIFF image `%s'", img->spec, Qnil); 7283 image_error ("Error reading TIFF image `%s'", img->spec);
7282 xfree (buf); 7284 xfree (buf);
7283 return 0; 7285 return 0;
7284 } 7286 }
@@ -7615,7 +7617,7 @@ gif_load (struct frame *f, struct image *img)
7615 file = x_find_image_file (specified_file); 7617 file = x_find_image_file (specified_file);
7616 if (!STRINGP (file)) 7618 if (!STRINGP (file))
7617 { 7619 {
7618 image_error ("Cannot find image file `%s'", specified_file, Qnil); 7620 image_error ("Cannot find image file `%s'", specified_file);
7619 return 0; 7621 return 0;
7620 } 7622 }
7621#ifdef WINDOWSNT 7623#ifdef WINDOWSNT
@@ -7627,7 +7629,7 @@ gif_load (struct frame *f, struct image *img)
7627 gif = DGifOpenFileName (SSDATA (file)); 7629 gif = DGifOpenFileName (SSDATA (file));
7628 if (gif == NULL) 7630 if (gif == NULL)
7629 { 7631 {
7630 image_error ("Cannot open `%s'", file, Qnil); 7632 image_error ("Cannot open `%s'", file);
7631 return 0; 7633 return 0;
7632 } 7634 }
7633#else 7635#else
@@ -7644,7 +7646,7 @@ gif_load (struct frame *f, struct image *img)
7644 { 7646 {
7645 if (!STRINGP (specified_data)) 7647 if (!STRINGP (specified_data))
7646 { 7648 {
7647 image_error ("Invalid image data `%s'", specified_data, Qnil); 7649 image_error ("Invalid image data `%s'", specified_data);
7648 return 0; 7650 return 0;
7649 } 7651 }
7650 7652
@@ -7658,7 +7660,7 @@ gif_load (struct frame *f, struct image *img)
7658 gif = DGifOpen (&memsrc, gif_read_from_memory); 7660 gif = DGifOpen (&memsrc, gif_read_from_memory);
7659 if (!gif) 7661 if (!gif)
7660 { 7662 {
7661 image_error ("Cannot open memory source `%s'", img->spec, Qnil); 7663 image_error ("Cannot open memory source `%s'", img->spec);
7662 return 0; 7664 return 0;
7663 } 7665 }
7664#else 7666#else
@@ -7675,7 +7677,7 @@ gif_load (struct frame *f, struct image *img)
7675 /* Before reading entire contents, check the declared image size. */ 7677 /* Before reading entire contents, check the declared image size. */
7676 if (!check_image_size (f, gif->SWidth, gif->SHeight)) 7678 if (!check_image_size (f, gif->SWidth, gif->SHeight))
7677 { 7679 {
7678 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 7680 image_error ("Invalid image size (see `max-image-size')");
7679 gif_close (gif, NULL); 7681 gif_close (gif, NULL);
7680 return 0; 7682 return 0;
7681 } 7683 }
@@ -7684,7 +7686,7 @@ gif_load (struct frame *f, struct image *img)
7684 rc = DGifSlurp (gif); 7686 rc = DGifSlurp (gif);
7685 if (rc == GIF_ERROR || gif->ImageCount <= 0) 7687 if (rc == GIF_ERROR || gif->ImageCount <= 0)
7686 { 7688 {
7687 image_error ("Error reading `%s'", img->spec, Qnil); 7689 image_error ("Error reading `%s'", img->spec);
7688 gif_close (gif, NULL); 7690 gif_close (gif, NULL);
7689 return 0; 7691 return 0;
7690 } 7692 }
@@ -7714,7 +7716,7 @@ gif_load (struct frame *f, struct image *img)
7714 7716
7715 if (!check_image_size (f, width, height)) 7717 if (!check_image_size (f, width, height))
7716 { 7718 {
7717 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 7719 image_error ("Invalid image size (see `max-image-size')");
7718 gif_close (gif, NULL); 7720 gif_close (gif, NULL);
7719 return 0; 7721 return 0;
7720 } 7722 }
@@ -7732,7 +7734,7 @@ gif_load (struct frame *f, struct image *img)
7732 && 0 <= subimg_top && subimg_top <= height - subimg_height 7734 && 0 <= subimg_top && subimg_top <= height - subimg_height
7733 && 0 <= subimg_left && subimg_left <= width - subimg_width)) 7735 && 0 <= subimg_left && subimg_left <= width - subimg_width))
7734 { 7736 {
7735 image_error ("Subimage does not fit in image", Qnil, Qnil); 7737 image_error ("Subimage does not fit in image");
7736 gif_close (gif, NULL); 7738 gif_close (gif, NULL);
7737 return 0; 7739 return 0;
7738 } 7740 }
@@ -7971,7 +7973,7 @@ gif_load (struct frame *f, struct image *img)
7971 image_error ("Error closing `%s': %s", 7973 image_error ("Error closing `%s': %s",
7972 img->spec, build_string (error_text)); 7974 img->spec, build_string (error_text));
7973#else 7975#else
7974 image_error ("Error closing `%s'", img->spec, Qnil); 7976 image_error ("Error closing `%s'", img->spec);
7975#endif 7977#endif
7976 } 7978 }
7977 7979
@@ -8220,9 +8222,7 @@ imagemagick_error (MagickWand *wand)
8220 ExceptionType severity; 8222 ExceptionType severity;
8221 8223
8222 description = MagickGetException (wand, &severity); 8224 description = MagickGetException (wand, &severity);
8223 image_error ("ImageMagick error: %s", 8225 image_error ("ImageMagick error: %s", build_string (description));
8224 build_string (description),
8225 Qnil);
8226 MagickRelinquishMemory (description); 8226 MagickRelinquishMemory (description);
8227} 8227}
8228 8228
@@ -8383,8 +8383,7 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
8383 DestroyMagickWand (composite_wand); 8383 DestroyMagickWand (composite_wand);
8384 DestroyMagickWand (sub_wand); 8384 DestroyMagickWand (sub_wand);
8385 cache->wand = NULL; 8385 cache->wand = NULL;
8386 image_error ("Imagemagick pixel iterator creation failed", 8386 image_error ("Imagemagick pixel iterator creation failed");
8387 Qnil, Qnil);
8388 return NULL; 8387 return NULL;
8389 } 8388 }
8390 8389
@@ -8395,8 +8394,7 @@ imagemagick_compute_animated_image (MagickWand *super_wand, int ino)
8395 DestroyMagickWand (sub_wand); 8394 DestroyMagickWand (sub_wand);
8396 DestroyPixelIterator (source_iterator); 8395 DestroyPixelIterator (source_iterator);
8397 cache->wand = NULL; 8396 cache->wand = NULL;
8398 image_error ("Imagemagick pixel iterator creation failed", 8397 image_error ("Imagemagick pixel iterator creation failed");
8399 Qnil, Qnil);
8400 return NULL; 8398 return NULL;
8401 } 8399 }
8402 8400
@@ -8571,7 +8569,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8571 status = MagickScaleImage (image_wand, desired_width, desired_height); 8569 status = MagickScaleImage (image_wand, desired_width, desired_height);
8572 if (status == MagickFalse) 8570 if (status == MagickFalse)
8573 { 8571 {
8574 image_error ("Imagemagick scale failed", Qnil, Qnil); 8572 image_error ("Imagemagick scale failed");
8575 imagemagick_error (image_wand); 8573 imagemagick_error (image_wand);
8576 goto imagemagick_error; 8574 goto imagemagick_error;
8577 } 8575 }
@@ -8621,7 +8619,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8621 status = MagickRotateImage (image_wand, bg_wand, rotation); 8619 status = MagickRotateImage (image_wand, bg_wand, rotation);
8622 if (status == MagickFalse) 8620 if (status == MagickFalse)
8623 { 8621 {
8624 image_error ("Imagemagick image rotate failed", Qnil, Qnil); 8622 image_error ("Imagemagick image rotate failed");
8625 imagemagick_error (image_wand); 8623 imagemagick_error (image_wand);
8626 goto imagemagick_error; 8624 goto imagemagick_error;
8627 } 8625 }
@@ -8651,7 +8649,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8651 if (! (image_width <= INT_MAX && image_height <= INT_MAX 8649 if (! (image_width <= INT_MAX && image_height <= INT_MAX
8652 && check_image_size (f, image_width, image_height))) 8650 && check_image_size (f, image_width, image_height)))
8653 { 8651 {
8654 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 8652 image_error ("Invalid image size (see `max-image-size')");
8655 goto imagemagick_error; 8653 goto imagemagick_error;
8656 } 8654 }
8657 8655
@@ -8678,7 +8676,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8678#ifdef COLOR_TABLE_SUPPORT 8676#ifdef COLOR_TABLE_SUPPORT
8679 free_color_table (); 8677 free_color_table ();
8680#endif 8678#endif
8681 image_error ("Imagemagick X bitmap allocation failure", Qnil, Qnil); 8679 image_error ("Imagemagick X bitmap allocation failure");
8682 goto imagemagick_error; 8680 goto imagemagick_error;
8683 } 8681 }
8684 8682
@@ -8718,7 +8716,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8718#ifdef COLOR_TABLE_SUPPORT 8716#ifdef COLOR_TABLE_SUPPORT
8719 free_color_table (); 8717 free_color_table ();
8720#endif 8718#endif
8721 image_error ("Imagemagick X bitmap allocation failure", Qnil, Qnil); 8719 image_error ("Imagemagick X bitmap allocation failure");
8722 goto imagemagick_error; 8720 goto imagemagick_error;
8723 } 8721 }
8724 8722
@@ -8734,8 +8732,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8734 free_color_table (); 8732 free_color_table ();
8735#endif 8733#endif
8736 x_destroy_x_image (ximg); 8734 x_destroy_x_image (ximg);
8737 image_error ("Imagemagick pixel iterator creation failed", 8735 image_error ("Imagemagick pixel iterator creation failed");
8738 Qnil, Qnil);
8739 goto imagemagick_error; 8736 goto imagemagick_error;
8740 } 8737 }
8741 8738
@@ -8787,7 +8784,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
8787 8784
8788 MagickWandTerminus (); 8785 MagickWandTerminus ();
8789 /* TODO more cleanup. */ 8786 /* TODO more cleanup. */
8790 image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec, Qnil); 8787 image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec);
8791 return 0; 8788 return 0;
8792} 8789}
8793 8790
@@ -8811,7 +8808,7 @@ imagemagick_load (struct frame *f, struct image *img)
8811 file = x_find_image_file (file_name); 8808 file = x_find_image_file (file_name);
8812 if (!STRINGP (file)) 8809 if (!STRINGP (file))
8813 { 8810 {
8814 image_error ("Cannot find image file `%s'", file_name, Qnil); 8811 image_error ("Cannot find image file `%s'", file_name);
8815 return 0; 8812 return 0;
8816 } 8813 }
8817#ifdef WINDOWSNT 8814#ifdef WINDOWSNT
@@ -8828,7 +8825,7 @@ imagemagick_load (struct frame *f, struct image *img)
8828 data = image_spec_value (img->spec, QCdata, NULL); 8825 data = image_spec_value (img->spec, QCdata, NULL);
8829 if (!STRINGP (data)) 8826 if (!STRINGP (data))
8830 { 8827 {
8831 image_error ("Invalid image data `%s'", data, Qnil); 8828 image_error ("Invalid image data `%s'", data);
8832 return 0; 8829 return 0;
8833 } 8830 }
8834 success_p = imagemagick_load_image (f, img, SDATA (data), 8831 success_p = imagemagick_load_image (f, img, SDATA (data),
@@ -9092,7 +9089,7 @@ svg_load (struct frame *f, struct image *img)
9092 file = x_find_image_file (file_name); 9089 file = x_find_image_file (file_name);
9093 if (!STRINGP (file)) 9090 if (!STRINGP (file))
9094 { 9091 {
9095 image_error ("Cannot find image file `%s'", file_name, Qnil); 9092 image_error ("Cannot find image file `%s'", file_name);
9096 return 0; 9093 return 0;
9097 } 9094 }
9098 9095
@@ -9100,7 +9097,7 @@ svg_load (struct frame *f, struct image *img)
9100 contents = slurp_file (SSDATA (file), &size); 9097 contents = slurp_file (SSDATA (file), &size);
9101 if (contents == NULL) 9098 if (contents == NULL)
9102 { 9099 {
9103 image_error ("Error loading SVG image `%s'", img->spec, Qnil); 9100 image_error ("Error loading SVG image `%s'", img->spec);
9104 return 0; 9101 return 0;
9105 } 9102 }
9106 /* If the file was slurped into memory properly, parse it. */ 9103 /* If the file was slurped into memory properly, parse it. */
@@ -9116,7 +9113,7 @@ svg_load (struct frame *f, struct image *img)
9116 data = image_spec_value (img->spec, QCdata, NULL); 9113 data = image_spec_value (img->spec, QCdata, NULL);
9117 if (!STRINGP (data)) 9114 if (!STRINGP (data))
9118 { 9115 {
9119 image_error ("Invalid image data `%s'", data, Qnil); 9116 image_error ("Invalid image data `%s'", data);
9120 return 0; 9117 return 0;
9121 } 9118 }
9122 original_filename = BVAR (current_buffer, filename); 9119 original_filename = BVAR (current_buffer, filename);
@@ -9183,7 +9180,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9183 rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); 9180 rsvg_handle_get_dimensions (rsvg_handle, &dimension_data);
9184 if (! check_image_size (f, dimension_data.width, dimension_data.height)) 9181 if (! check_image_size (f, dimension_data.width, dimension_data.height))
9185 { 9182 {
9186 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 9183 image_error ("Invalid image size (see `max-image-size')");
9187 goto rsvg_error; 9184 goto rsvg_error;
9188 } 9185 }
9189 9186
@@ -9315,7 +9312,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
9315 g_object_unref (rsvg_handle); 9312 g_object_unref (rsvg_handle);
9316 /* FIXME: Use error->message so the user knows what is the actual 9313 /* FIXME: Use error->message so the user knows what is the actual
9317 problem with the image. */ 9314 problem with the image. */
9318 image_error ("Error parsing SVG image `%s'", img->spec, Qnil); 9315 image_error ("Error parsing SVG image `%s'", img->spec);
9319 g_error_free (err); 9316 g_error_free (err);
9320 return 0; 9317 return 0;
9321} 9318}
@@ -9468,7 +9465,7 @@ gs_load (struct frame *f, struct image *img)
9468 if (! (in_width <= INT_MAX && in_height <= INT_MAX 9465 if (! (in_width <= INT_MAX && in_height <= INT_MAX
9469 && check_image_size (f, in_width, in_height))) 9466 && check_image_size (f, in_width, in_height)))
9470 { 9467 {
9471 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 9468 image_error ("Invalid image size (see `max-image-size')");
9472 return 0; 9469 return 0;
9473 } 9470 }
9474 img->width = in_width; 9471 img->width = in_width;
@@ -9489,7 +9486,7 @@ gs_load (struct frame *f, struct image *img)
9489 9486
9490 if (!img->pixmap) 9487 if (!img->pixmap)
9491 { 9488 {
9492 image_error ("Unable to create pixmap for `%s'", img->spec, Qnil); 9489 image_error ("Unable to create pixmap for `%s'", img->spec);
9493 return 0; 9490 return 0;
9494 } 9491 }
9495 9492
@@ -9602,7 +9599,7 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
9602 } 9599 }
9603 else 9600 else
9604 image_error ("Cannot get X image of `%s'; colors will not be freed", 9601 image_error ("Cannot get X image of `%s'; colors will not be freed",
9605 img->spec, Qnil); 9602 img->spec);
9606 9603
9607 unblock_input (); 9604 unblock_input ();
9608 } 9605 }
diff --git a/src/lisp.h b/src/lisp.h
index 02109d72174..2545203a674 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3667,7 +3667,8 @@ extern Lisp_Object sit_for (Lisp_Object, bool, int);
3667/* Defined in xdisp.c. */ 3667/* Defined in xdisp.c. */
3668extern bool noninteractive_need_newline; 3668extern bool noninteractive_need_newline;
3669extern Lisp_Object echo_area_buffer[2]; 3669extern Lisp_Object echo_area_buffer[2];
3670extern void add_to_log (const char *, Lisp_Object, Lisp_Object); 3670extern void add_to_log (char const *, ...);
3671extern void vadd_to_log (char const *, va_list);
3671extern void check_message_stack (void); 3672extern void check_message_stack (void);
3672extern void setup_echo_area_for_printing (bool); 3673extern void setup_echo_area_for_printing (bool);
3673extern bool push_message (void); 3674extern bool push_message (void);
diff --git a/src/nsimage.m b/src/nsimage.m
index 9302cd2f212..13e8504f460 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -102,7 +102,7 @@ ns_load_image (struct frame *f, struct image *img,
102 102
103 if (eImg == nil) 103 if (eImg == nil)
104 { 104 {
105 add_to_log ("Unable to load image %s", img->spec, Qnil); 105 add_to_log ("Unable to load image %s", img->spec);
106 return 0; 106 return 0;
107 } 107 }
108 108
diff --git a/src/xdisp.c b/src/xdisp.c
index 9b761746252..52c77bd434d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -9797,27 +9797,50 @@ include the height of both, if present, in the return value. */)
9797 Messages 9797 Messages
9798 ***********************************************************************/ 9798 ***********************************************************************/
9799 9799
9800/* Return the number of arguments the format string FORMAT needs. */
9800 9801
9801/* Add a message with format string FORMAT and arguments ARG1 and ARG2 9802static ptrdiff_t
9803format_nargs (char const *format)
9804{
9805 ptrdiff_t nargs = 0;
9806 for (char const *p = format; (p = strchr (p, '%')); p++)
9807 if (p[1] == '%')
9808 p++;
9809 else
9810 nargs++;
9811 return nargs;
9812}
9813
9814/* Add a message with format string FORMAT and formatted arguments
9802 to *Messages*. */ 9815 to *Messages*. */
9803 9816
9804void 9817void
9805add_to_log (const char *format, Lisp_Object arg1, Lisp_Object arg2) 9818add_to_log (const char *format, ...)
9806{ 9819{
9807 Lisp_Object msg, fmt; 9820 va_list ap;
9808 char *buffer; 9821 va_start (ap, format);
9809 ptrdiff_t len; 9822 vadd_to_log (format, ap);
9810 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 9823 va_end (ap);
9811 USE_SAFE_ALLOCA; 9824}
9812
9813 fmt = msg = Qnil;
9814 GCPRO4 (fmt, msg, arg1, arg2);
9815 9825
9816 fmt = build_string (format); 9826void
9817 msg = CALLN (Fformat, fmt, arg1, arg2); 9827vadd_to_log (char const *format, va_list ap)
9828{
9829 ptrdiff_t nargs = 1 + format_nargs (format);
9830 Lisp_Object args[10];
9831 eassert (nargs <= ARRAYELTS (args));
9832 args[0] = build_string (format);
9833 for (ptrdiff_t i = 1; i <= nargs; i++)
9834 args[i] = va_arg (ap, Lisp_Object);
9835 Lisp_Object msg = Qnil;
9836 struct gcpro gcpro1, gcpro2;
9837 GCPRO2 (args, msg);
9838 gcpro1.nvars = nargs;
9839 msg = Fformat (nargs, args);
9818 9840
9819 len = SBYTES (msg) + 1; 9841 ptrdiff_t len = SBYTES (msg) + 1;
9820 buffer = SAFE_ALLOCA (len); 9842 USE_SAFE_ALLOCA;
9843 char *buffer = SAFE_ALLOCA (len);
9821 memcpy (buffer, SDATA (msg), len); 9844 memcpy (buffer, SDATA (msg), len);
9822 9845
9823 message_dolog (buffer, len - 1, true, false); 9846 message_dolog (buffer, len - 1, true, false);
diff --git a/src/xfaces.c b/src/xfaces.c
index f0b6d393f99..ce300e7ef23 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -797,7 +797,7 @@ load_pixmap (struct frame *f, Lisp_Object name)
797 797
798 if (bitmap_id < 0) 798 if (bitmap_id < 0)
799 { 799 {
800 add_to_log ("Invalid or undefined bitmap `%s'", name, Qnil); 800 add_to_log ("Invalid or undefined bitmap `%s'", name);
801 bitmap_id = 0; 801 bitmap_id = 0;
802 } 802 }
803 else 803 else
@@ -1099,7 +1099,7 @@ load_color2 (struct frame *f, struct face *face, Lisp_Object name,
1099 to the values in an existing cell. */ 1099 to the values in an existing cell. */
1100 if (!defined_color (f, SSDATA (name), color, true)) 1100 if (!defined_color (f, SSDATA (name), color, true))
1101 { 1101 {
1102 add_to_log ("Unable to load color \"%s\"", name, Qnil); 1102 add_to_log ("Unable to load color \"%s\"", name);
1103 1103
1104 switch (target_index) 1104 switch (target_index)
1105 { 1105 {
@@ -2247,7 +2247,7 @@ merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to,
2247 else 2247 else
2248 { 2248 {
2249 if (err_msgs) 2249 if (err_msgs)
2250 add_to_log ("Invalid face color", color_name, Qnil); 2250 add_to_log ("Invalid face color %S", color_name);
2251 ok = false; 2251 ok = false;
2252 } 2252 }
2253 } 2253 }
@@ -2452,7 +2452,7 @@ merge_face_ref (struct frame *f, Lisp_Object face_ref, Lisp_Object *to,
2452 /* FACE_REF ought to be a face name. */ 2452 /* FACE_REF ought to be a face name. */
2453 ok = merge_named_face (f, face_ref, to, named_merge_points); 2453 ok = merge_named_face (f, face_ref, to, named_merge_points);
2454 if (!ok && err_msgs) 2454 if (!ok && err_msgs)
2455 add_to_log ("Invalid face reference: %s", face_ref, Qnil); 2455 add_to_log ("Invalid face reference: %s", face_ref);
2456 } 2456 }
2457 2457
2458 return ok; 2458 return ok;