From: Eli Zaretskii Date: Tue, 13 Sep 2022 13:26:50 +0000 (+0300) Subject: Fix last change in image.c X-Git-Tag: emacs-29.0.90~1856^2~563 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=dfbe745ed9ba89e516ef89955f2ca88be04d1d72;p=emacs.git Fix last change in image.c * src/image.c (svg_load_image): Don't call Lisp to remove trailing whitespace from librsvg error messages, do it in C instead; this reduces consing and is much cleaner. Don't display empty error reason if librsvg happens to return an empty message text. (syms_of_image): Don't DEFSYM string-trim-right. (Bug#57755) --- diff --git a/src/image.c b/src/image.c index 2e04685e7f9..b1d597d7213 100644 --- a/src/image.c +++ b/src/image.c @@ -11540,13 +11540,18 @@ svg_load_image (struct frame *f, struct image *img, char *contents, return true; rsvg_error: - if (err == NULL) + if (!err || !err->message[0]) image_error ("Error parsing SVG image"); else { - image_error ("Error parsing SVG image: %s", - call2 (Qstring_trim_right, build_string (err->message), - Qnil)); + char *errmsg = err->message; + ptrdiff_t errlen = strlen (errmsg); + + /* Remove trailing whitespace from the error message text. It + has a newline at the end, and perhaps more whitespace. */ + while (c_isspace (errmsg[errlen - 1])) + errlen--; + image_error ("Error parsing SVG image: %s", make_string (errmsg, errlen)); g_error_free (err); } @@ -12272,6 +12277,4 @@ The options are: /* MagickExportImagePixels is in 6.4.6-9, but not 6.4.4-10. */ imagemagick_render_type = 0; #endif - - DEFSYM (Qstring_trim_right, "string-trim-right"); }