From 59b5141dd7247260cbc383e0bc2afde139d55670 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 15 Aug 2015 17:16:28 -0700 Subject: [PATCH] Fix quoting in Fformat calls * src/image.c (xbm_read_bitmap_data, xbm_load_image, xbm_load) (xpm_load, xpm_load_image, pbm_load, png_load_body) (jpeg_load_body, tiff_load, gif_load, imagemagick_load_image) (imagemagick_load, svg_load, svg_load_image, gs_load) (x_kill_gs_process): * src/lread.c (load_warn_old_style_backquotes): * src/xfaces.c (load_pixmap): * src/xselect.c (x_clipboard_manager_error_1): Quote diagnostics according to user preference when calling Fformat or its derivatives. --- src/image.c | 154 ++++++++++++++++++++++++++++---------------------- src/lread.c | 3 +- src/xfaces.c | 2 +- src/xselect.c | 6 +- 4 files changed, 92 insertions(+), 73 deletions(-) diff --git a/src/image.c b/src/image.c index 313419b3232..fb8c6e79168 100644 --- a/src/image.c +++ b/src/image.c @@ -2794,7 +2794,7 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e if (!check_image_size (f, *width, *height)) { if (!inhibit_image_error) - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); goto failure; } else if (data == NULL) @@ -2939,13 +2939,14 @@ xbm_load_image (struct frame *f, struct image *img, unsigned char *contents, if (img->pixmap == NO_PIXMAP) { x_clear_image (f, img); - image_error ("Unable to create X pixmap for `%s'", img->spec); + image_error ("Unable to create X pixmap for "uLSQM"%s"uRSQM, + img->spec); } else success_p = 1; } else - image_error ("Error loading XBM image `%s'", img->spec); + image_error ("Error loading XBM image "uLSQM"%s"uRSQM, img->spec); return success_p; } @@ -2986,14 +2987,14 @@ xbm_load (struct frame *f, struct image *img) file = x_find_image_file (file_name); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", file_name); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, file_name); return 0; } contents = slurp_file (SSDATA (file), &size); if (contents == NULL) { - image_error ("Error loading XBM image `%s'", img->spec); + image_error ("Error loading XBM image "uLSQM"%s"uRSQM, img->spec); return 0; } @@ -3028,7 +3029,8 @@ xbm_load (struct frame *f, struct image *img) eassert (img->width > 0 && img->height > 0); if (!check_image_size (f, img->width, img->height)) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see " + uLSQM"max-image-size"uRSQM")"); return 0; } } @@ -3105,7 +3107,8 @@ xbm_load (struct frame *f, struct image *img) success_p = 1; else { - image_error ("Unable to create pixmap for XBM image `%s'", + image_error (("Unable to create pixmap for XBM image " + uLSQM"%s"uRSQM), img->spec); x_clear_image (f, img); } @@ -3628,7 +3631,8 @@ xpm_load (struct frame *f, struct image *img) Lisp_Object file = x_find_image_file (specified_file); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", specified_file); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, + specified_file); #ifdef ALLOC_XPM_COLORS xpm_free_color_cache (); #endif @@ -3659,7 +3663,7 @@ xpm_load (struct frame *f, struct image *img) Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL); if (!STRINGP (buffer)) { - image_error ("Invalid image data `%s'", buffer); + image_error ("Invalid image data "uLSQM"%s"uRSQM, buffer); #ifdef ALLOC_XPM_COLORS xpm_free_color_cache (); #endif @@ -4103,7 +4107,7 @@ xpm_load_image (struct frame *f, if (!check_image_size (f, width, height)) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); goto failure; } @@ -4293,14 +4297,14 @@ xpm_load (struct frame *f, file = x_find_image_file (file_name); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", file_name); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, file_name); return 0; } contents = slurp_file (SSDATA (file), &size); if (contents == NULL) { - image_error ("Error loading XPM image `%s'", img->spec); + image_error ("Error loading XPM image "uLSQM"%s"uRSQM, img->spec); return 0; } @@ -4314,7 +4318,7 @@ xpm_load (struct frame *f, data = image_spec_value (img->spec, QCdata, NULL); if (!STRINGP (data)) { - image_error ("Invalid image data `%s'", data); + image_error ("Invalid image data "uLSQM"%s"uRSQM, data); return 0; } success_p = xpm_load_image (f, img, SDATA (data), @@ -5268,14 +5272,15 @@ pbm_load (struct frame *f, struct image *img) file = x_find_image_file (specified_file); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", specified_file); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, + specified_file); return 0; } contents = slurp_file (SSDATA (file), &size); if (contents == NULL) { - image_error ("Error reading `%s'", file); + image_error ("Error reading "uLSQM"%s"uRSQM, file); return 0; } @@ -5288,7 +5293,7 @@ pbm_load (struct frame *f, struct image *img) data = image_spec_value (img->spec, QCdata, NULL); if (!STRINGP (data)) { - image_error ("Invalid image data `%s'", data); + image_error ("Invalid image data "uLSQM"%s"uRSQM, data); return 0; } p = SDATA (data); @@ -5298,7 +5303,7 @@ pbm_load (struct frame *f, struct image *img) /* Check magic number. */ if (end - p < 2 || *p++ != 'P') { - image_error ("Not a PBM image: `%s'", img->spec); + image_error ("Not a PBM image: "uLSQM"%s"uRSQM, img->spec); error: xfree (contents); img->pixmap = NO_PIXMAP; @@ -5332,7 +5337,7 @@ pbm_load (struct frame *f, struct image *img) break; default: - image_error ("Not a PBM image: `%s'", img->spec); + image_error ("Not a PBM image: "uLSQM"%s"uRSQM, img->spec); goto error; } @@ -5358,7 +5363,7 @@ pbm_load (struct frame *f, struct image *img) if (!check_image_size (f, width, height)) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); goto error; } @@ -5431,7 +5436,8 @@ pbm_load (struct frame *f, struct image *img) x_destroy_x_image (ximg); #endif x_clear_image (f, img); - image_error ("Invalid image size in image `%s'", + image_error (("Invalid image size in image " + uLSQM"%s"uRSQM), img->spec); goto error; } @@ -5466,7 +5472,7 @@ pbm_load (struct frame *f, struct image *img) x_destroy_x_image (ximg); #endif x_clear_image (f, img); - image_error ("Invalid image size in image `%s'", + image_error ("Invalid image size in image "uLSQM"%s"uRSQM, img->spec); goto error; } @@ -5510,7 +5516,7 @@ pbm_load (struct frame *f, struct image *img) #else x_destroy_x_image (ximg); #endif - image_error ("Invalid pixel value in image `%s'", + image_error ("Invalid pixel value in image "uLSQM"%s"uRSQM, img->spec); goto error; } @@ -5906,7 +5912,8 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) file = x_find_image_file (specified_file); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", specified_file); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, + specified_file); return 0; } @@ -5914,7 +5921,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) fp = emacs_fopen (SSDATA (file), "rb"); if (!fp) { - image_error ("Cannot open image file `%s'", file); + image_error ("Cannot open image file "uLSQM"%s"uRSQM, file); return 0; } @@ -5923,7 +5930,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) || png_sig_cmp (sig, 0, sizeof sig)) { fclose (fp); - image_error ("Not a PNG file: `%s'", file); + image_error ("Not a PNG file: "uLSQM"%s"uRSQM, file); return 0; } } @@ -5931,7 +5938,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) { if (!STRINGP (specified_data)) { - image_error ("Invalid image data `%s'", specified_data); + image_error ("Invalid image data "uLSQM"%s"uRSQM, specified_data); return 0; } @@ -5944,7 +5951,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) if (tbr.len < sizeof sig || png_sig_cmp (tbr.bytes, 0, sizeof sig)) { - image_error ("Not a PNG image: `%s'", img->spec); + image_error ("Not a PNG image: "uLSQM"%s"uRSQM, img->spec); return 0; } @@ -6012,7 +6019,7 @@ png_load_body (struct frame *f, struct image *img, struct png_load_context *c) if (! (width <= INT_MAX && height <= INT_MAX && check_image_size (f, width, height))) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); goto error; } @@ -6670,20 +6677,21 @@ jpeg_load_body (struct frame *f, struct image *img, file = x_find_image_file (specified_file); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", specified_file); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, + specified_file); return 0; } fp = emacs_fopen (SSDATA (file), "rb"); if (fp == NULL) { - image_error ("Cannot open `%s'", file); + image_error ("Cannot open "uLSQM"%s"uRSQM, file); return 0; } } else if (!STRINGP (specified_data)) { - image_error ("Invalid image data `%s'", specified_data); + image_error ("Invalid image data "uLSQM"%s"uRSQM, specified_data); return 0; } @@ -6699,13 +6707,14 @@ jpeg_load_body (struct frame *f, struct image *img, { char buf[JMSG_LENGTH_MAX]; mgr->cinfo.err->format_message ((j_common_ptr) &mgr->cinfo, buf); - image_error ("Error reading JPEG image `%s': %s", img->spec, - build_string (buf)); + image_error ("Error reading JPEG image "uLSQM"%s"uRSQM": %s", + img->spec, build_string (buf)); break; } case MY_JPEG_INVALID_IMAGE_SIZE: - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see " + uLSQM"max-image-size"uRSQM")"); break; case MY_JPEG_CANNOT_CREATE_X: @@ -7185,7 +7194,8 @@ tiff_load (struct frame *f, struct image *img) file = x_find_image_file (specified_file); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", specified_file); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, + specified_file); return 0; } # ifdef WINDOWSNT @@ -7196,7 +7206,7 @@ tiff_load (struct frame *f, struct image *img) tiff = TIFFOpen (SSDATA (file), "r"); if (tiff == NULL) { - image_error ("Cannot open `%s'", file); + image_error ("Cannot open "uLSQM"%s"uRSQM, file); return 0; } } @@ -7204,7 +7214,7 @@ tiff_load (struct frame *f, struct image *img) { if (!STRINGP (specified_data)) { - image_error ("Invalid image data `%s'", specified_data); + image_error ("Invalid image data "uLSQM"%s"uRSQM, specified_data); return 0; } @@ -7224,7 +7234,8 @@ tiff_load (struct frame *f, struct image *img) if (!tiff) { - image_error ("Cannot open memory source for `%s'", img->spec); + image_error ("Cannot open memory source for "uLSQM"%s"uRSQM, + img->spec); return 0; } } @@ -7236,8 +7247,9 @@ tiff_load (struct frame *f, struct image *img) if (! (TYPE_MINIMUM (tdir_t) <= ino && ino <= TYPE_MAXIMUM (tdir_t) && TIFFSetDirectory (tiff, ino))) { - image_error ("Invalid image number `%s' in image `%s'", - image, img->spec); + image_error + ("Invalid image number "uLSQM"%s"uRSQM" in image "uLSQM"%s"uRSQM, + image, img->spec); TIFFClose (tiff); return 0; } @@ -7250,7 +7262,7 @@ tiff_load (struct frame *f, struct image *img) if (!check_image_size (f, width, height)) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); TIFFClose (tiff); return 0; } @@ -7280,7 +7292,7 @@ tiff_load (struct frame *f, struct image *img) TIFFClose (tiff); if (!rc) { - image_error ("Error reading TIFF image `%s'", img->spec); + image_error ("Error reading TIFF image "uLSQM"%s"uRSQM, img->spec); xfree (buf); return 0; } @@ -7617,7 +7629,8 @@ gif_load (struct frame *f, struct image *img) file = x_find_image_file (specified_file); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", specified_file); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, + specified_file); return 0; } #ifdef WINDOWSNT @@ -7629,14 +7642,14 @@ gif_load (struct frame *f, struct image *img) gif = DGifOpenFileName (SSDATA (file)); if (gif == NULL) { - image_error ("Cannot open `%s'", file); + image_error ("Cannot open "uLSQM"%s"uRSQM, file); return 0; } #else gif = DGifOpenFileName (SSDATA (file), &gif_err); if (gif == NULL) { - image_error ("Cannot open `%s': %s", + image_error ("Cannot open "uLSQM"%s"uRSQM": %s", file, build_string (GifErrorString (gif_err))); return 0; } @@ -7646,7 +7659,7 @@ gif_load (struct frame *f, struct image *img) { if (!STRINGP (specified_data)) { - image_error ("Invalid image data `%s'", specified_data); + image_error ("Invalid image data "uLSQM"%s"uRSQM, specified_data); return 0; } @@ -7660,14 +7673,14 @@ gif_load (struct frame *f, struct image *img) gif = DGifOpen (&memsrc, gif_read_from_memory); if (!gif) { - image_error ("Cannot open memory source `%s'", img->spec); + image_error ("Cannot open memory source "uLSQM"%s"uRSQM, img->spec); return 0; } #else gif = DGifOpen (&memsrc, gif_read_from_memory, &gif_err); if (!gif) { - image_error ("Cannot open memory source `%s': %s", + image_error ("Cannot open memory source "uLSQM"%s"uRSQM": %s", img->spec, build_string (GifErrorString (gif_err))); return 0; } @@ -7677,7 +7690,7 @@ gif_load (struct frame *f, struct image *img) /* Before reading entire contents, check the declared image size. */ if (!check_image_size (f, gif->SWidth, gif->SHeight)) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); gif_close (gif, NULL); return 0; } @@ -7686,7 +7699,7 @@ gif_load (struct frame *f, struct image *img) rc = DGifSlurp (gif); if (rc == GIF_ERROR || gif->ImageCount <= 0) { - image_error ("Error reading `%s'", img->spec); + image_error ("Error reading "uLSQM"%s"uRSQM, img->spec); gif_close (gif, NULL); return 0; } @@ -7697,8 +7710,9 @@ gif_load (struct frame *f, struct image *img) idx = INTEGERP (image_number) ? XFASTINT (image_number) : 0; if (idx < 0 || idx >= gif->ImageCount) { - image_error ("Invalid image number `%s' in image `%s'", - image_number, img->spec); + image_error + ("Invalid image number "uLSQM"%s"uRSQM" in image "uLSQM"%s"uRSQM, + image_number, img->spec); gif_close (gif, NULL); return 0; } @@ -7716,7 +7730,7 @@ gif_load (struct frame *f, struct image *img) if (!check_image_size (f, width, height)) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); gif_close (gif, NULL); return 0; } @@ -7970,10 +7984,10 @@ gif_load (struct frame *f, struct image *img) char *error_text = GifErrorString (gif_err); if (error_text) - image_error ("Error closing `%s': %s", + image_error ("Error closing "uLSQM"%s"uRSQM": %s", img->spec, build_string (error_text)); #else - image_error ("Error closing `%s'", img->spec); + image_error ("Error closing "uLSQM"%s"uRSQM, img->spec); #endif } @@ -8514,8 +8528,9 @@ imagemagick_load_image (struct frame *f, struct image *img, if (ino < 0 || ino >= MagickGetNumberImages (image_wand)) { - image_error ("Invalid image number `%s' in image `%s'", - image, img->spec); + image_error + ("Invalid image number "uLSQM"%s"uRSQM" in image "uLSQM"%s"uRSQM, + image, img->spec); DestroyMagickWand (image_wand); return 0; } @@ -8649,7 +8664,7 @@ imagemagick_load_image (struct frame *f, struct image *img, if (! (image_width <= INT_MAX && image_height <= INT_MAX && check_image_size (f, image_width, image_height))) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); goto imagemagick_error; } @@ -8784,7 +8799,7 @@ imagemagick_load_image (struct frame *f, struct image *img, MagickWandTerminus (); /* TODO more cleanup. */ - image_error ("Error parsing IMAGEMAGICK image `%s'", img->spec); + image_error ("Error parsing IMAGEMAGICK image "uLSQM"%s"uRSQM, img->spec); return 0; } @@ -8808,7 +8823,7 @@ imagemagick_load (struct frame *f, struct image *img) file = x_find_image_file (file_name); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", file_name); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, file_name); return 0; } #ifdef WINDOWSNT @@ -8825,7 +8840,7 @@ imagemagick_load (struct frame *f, struct image *img) data = image_spec_value (img->spec, QCdata, NULL); if (!STRINGP (data)) { - image_error ("Invalid image data `%s'", data); + image_error ("Invalid image data "uLSQM"%s"uRSQM, data); return 0; } success_p = imagemagick_load_image (f, img, SDATA (data), @@ -9089,7 +9104,7 @@ svg_load (struct frame *f, struct image *img) file = x_find_image_file (file_name); if (!STRINGP (file)) { - image_error ("Cannot find image file `%s'", file_name); + image_error ("Cannot find image file "uLSQM"%s"uRSQM, file_name); return 0; } @@ -9097,7 +9112,7 @@ svg_load (struct frame *f, struct image *img) contents = slurp_file (SSDATA (file), &size); if (contents == NULL) { - image_error ("Error loading SVG image `%s'", img->spec); + image_error ("Error loading SVG image "uLSQM"%s"uRSQM, img->spec); return 0; } /* If the file was slurped into memory properly, parse it. */ @@ -9113,7 +9128,7 @@ svg_load (struct frame *f, struct image *img) data = image_spec_value (img->spec, QCdata, NULL); if (!STRINGP (data)) { - image_error ("Invalid image data `%s'", data); + image_error ("Invalid image data "uLSQM"%s"uRSQM, data); return 0; } original_filename = BVAR (current_buffer, filename); @@ -9180,7 +9195,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); if (! check_image_size (f, dimension_data.width, dimension_data.height)) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); goto rsvg_error; } @@ -9312,7 +9327,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. * g_object_unref (rsvg_handle); /* FIXME: Use error->message so the user knows what is the actual problem with the image. */ - image_error ("Error parsing SVG image `%s'", img->spec); + image_error ("Error parsing SVG image "uLSQM"%s"uRSQM, img->spec); g_error_free (err); return 0; } @@ -9465,7 +9480,7 @@ gs_load (struct frame *f, struct image *img) if (! (in_width <= INT_MAX && in_height <= INT_MAX && check_image_size (f, in_width, in_height))) { - image_error ("Invalid image size (see `max-image-size')"); + image_error ("Invalid image size (see "uLSQM"max-image-size"uRSQM")"); return 0; } img->width = in_width; @@ -9486,7 +9501,7 @@ gs_load (struct frame *f, struct image *img) if (!img->pixmap) { - image_error ("Unable to create pixmap for `%s'", img->spec); + image_error ("Unable to create pixmap for "uLSQM"%s"uRSQM, img->spec); return 0; } @@ -9598,7 +9613,8 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f) #endif } else - image_error ("Cannot get X image of `%s'; colors will not be freed", + image_error (("Cannot get X image of "uLSQM"%s"uRSQM";" + " colors will not be freed"), img->spec); unblock_input (); diff --git a/src/lread.c b/src/lread.c index fe4d3672b44..ebd594c1a16 100644 --- a/src/lread.c +++ b/src/lread.c @@ -947,7 +947,8 @@ load_warn_old_style_backquotes (Lisp_Object file) { if (!NILP (Vold_style_backquotes)) { - AUTO_STRING (format, "Loading `%s': old-style backquotes detected!"); + Lisp_Object format = build_string ("Loading "uLSQM"%s"uRSQM + ": old-style backquotes detected!"); CALLN (Fmessage, format, file); } } diff --git a/src/xfaces.c b/src/xfaces.c index ce300e7ef23..d519578198b 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -797,7 +797,7 @@ load_pixmap (struct frame *f, Lisp_Object name) if (bitmap_id < 0) { - add_to_log ("Invalid or undefined bitmap `%s'", name); + add_to_log ("Invalid or undefined bitmap "uLSQM"%s"uRSQM, name); bitmap_id = 0; } else diff --git a/src/xselect.c b/src/xselect.c index bd2d65e795f..b54ddd83237 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -2147,8 +2147,10 @@ x_clipboard_manager_save (Lisp_Object frame) static Lisp_Object x_clipboard_manager_error_1 (Lisp_Object err) { - AUTO_STRING (format, "X clipboard manager error: %s\n\ -If the problem persists, set `x-select-enable-clipboard-manager' to nil."); + Lisp_Object format + = build_string ("X clipboard manager error: %s\n" + "If the problem persists, set " + uLSQM"x-select-enable-clipboard-manager"uRSQM" to nil."); CALLN (Fmessage, format, CAR (CDR (err))); return Qnil; } -- 2.39.2