From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#35548: image.c uses deprecated rsvg_handle_write etc. Date: Wed, 10 Jul 2019 12:44:26 -0700 Organization: UCLA Computer Science Department Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------989D23AD741F96A9D69F59D3" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="258141"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 Cc: 35548-done@debbugs.gnu.org To: YAMAMOTO Mitsuharu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jul 10 21:45:37 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hlIX2-0014yl-Qh for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Jul 2019 21:45:36 +0200 Original-Received: from localhost ([::1]:36536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlIX1-0008Pi-Lz for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Jul 2019 15:45:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45417) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlIWX-0008PW-Mu for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2019 15:45:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlIWV-0008IB-OH for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2019 15:45:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56070) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hlIWU-0008Fl-Gh for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2019 15:45:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hlIWU-00068h-Bx for bug-gnu-emacs@gnu.org; Wed, 10 Jul 2019 15:45:02 -0400 Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Jul 2019 19:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 35548 X-GNU-PR-Package: emacs Mail-Followup-To: 35548@debbugs.gnu.org, eggert@cs.ucla.edu, eggert@cs.ucla.edu Original-Received: via spool by 35548-done@debbugs.gnu.org id=D35548.156278787923549 (code D ref 35548); Wed, 10 Jul 2019 19:45:01 +0000 Original-Received: (at 35548-done) by debbugs.gnu.org; 10 Jul 2019 19:44:39 +0000 Original-Received: from localhost ([127.0.0.1]:36658 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlIW6-00067j-MR for submit@debbugs.gnu.org; Wed, 10 Jul 2019 15:44:39 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55008) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hlIW3-00067T-Qb for 35548-done@debbugs.gnu.org; Wed, 10 Jul 2019 15:44:37 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 31C001626CF; Wed, 10 Jul 2019 12:44:28 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id HOcDpvJtXdd6; Wed, 10 Jul 2019 12:44:27 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 219991626D2; Wed, 10 Jul 2019 12:44:27 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id fpGBZuBjSH6i; Wed, 10 Jul 2019 12:44:27 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id EA6381626CF; Wed, 10 Jul 2019 12:44:26 -0700 (PDT) In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:162657 Archived-At: This is a multi-part message in MIME format. --------------989D23AD741F96A9D69F59D3 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks, I attempted to port that patch to MS-Windows, installed the attached, and am marking this bug as done. --------------989D23AD741F96A9D69F59D3 Content-Type: text/x-patch; name="0001-Avoid-functions-deprecated-in-librsvg-2.45.1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Avoid-functions-deprecated-in-librsvg-2.45.1.patch" >From 40cd6278ba965f3a9fcdddc568eb9ee7c69cf899 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 10 Jul 2019 12:37:55 -0700 Subject: [PATCH] Avoid functions deprecated in librsvg 2.45.1 * src/image.c (init_svg_functions) [WINDOWSNT]: Load the pre-2.32 or 2.32 functions, depending on LIBRSVG_CHECK_VERSION. (svg_load_image): In librsvg 2.32 or later, use g_memory_input_stream_new_from_data, g_file_new_for_path and rsvg_handle_new_from_stream_sync rather than the deprecated-in-2.45 rsvg_handle_write and rsvg_handle_close. >From a patch by YAMAMOTO Mitsuharu (Bug#35548#11). --- src/image.c | 82 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 54 insertions(+), 28 deletions(-) diff --git a/src/image.c b/src/image.c index e898a7364a..3695342232 100644 --- a/src/image.c +++ b/src/image.c @@ -9300,14 +9300,23 @@ svg_image_p (Lisp_Object object) # endif /* SVG library functions. */ +# if LIBRSVG_CHECK_VERSION (2, 32, 0) +DEF_DLL_FN (GFile *, g_file_new_for_path, (char const *)); +DEF_DLL_FN (GInputStream *, g_memory_input_stream_new_from_data, + (void const *, gssize, GDestroyNotify)); +DEF_DLL_FN (RsvgHandle *, rsvg_handle_new_from_stream_sync, + (GInputStream *, GFile *, RsvgHandleFlags, GCancellable *, + GError **error)); +# else DEF_DLL_FN (RsvgHandle *, rsvg_handle_new, (void)); -DEF_DLL_FN (void, rsvg_handle_get_dimensions, - (RsvgHandle *, RsvgDimensionData *)); +DEF_DLL_FN (void, rsvg_handle_set_base_uri, (RsvgHandle *, const char *)); DEF_DLL_FN (gboolean, rsvg_handle_write, (RsvgHandle *, const guchar *, gsize, GError **)); DEF_DLL_FN (gboolean, rsvg_handle_close, (RsvgHandle *, GError **)); +#endif +DEF_DLL_FN (void, rsvg_handle_get_dimensions, + (RsvgHandle *, RsvgDimensionData *)); DEF_DLL_FN (GdkPixbuf *, rsvg_handle_get_pixbuf, (RsvgHandle *)); -DEF_DLL_FN (void, rsvg_handle_set_base_uri, (RsvgHandle *, const char *)); DEF_DLL_FN (int, gdk_pixbuf_get_width, (const GdkPixbuf *)); DEF_DLL_FN (int, gdk_pixbuf_get_height, (const GdkPixbuf *)); @@ -9340,12 +9349,18 @@ init_svg_functions (void) return 0; } +#if LIBRSVG_CHECK_VERSION (2, 32, 0) + LOAD_DLL_FN (glib, g_file_new_for_path); + LOAD_DLL_FN (glib, g_memory_input_stream_new_from_data); + LOAD_DLL_FN (library, rsvg_handle_new_from_stream_sync); +#else LOAD_DLL_FN (library, rsvg_handle_new); - LOAD_DLL_FN (library, rsvg_handle_get_dimensions); + LOAD_DLL_FN (library, rsvg_handle_set_base_uri); LOAD_DLL_FN (library, rsvg_handle_write); LOAD_DLL_FN (library, rsvg_handle_close); +#endif + LOAD_DLL_FN (library, rsvg_handle_get_dimensions); LOAD_DLL_FN (library, rsvg_handle_get_pixbuf); - LOAD_DLL_FN (library, rsvg_handle_set_base_uri); LOAD_DLL_FN (gdklib, gdk_pixbuf_get_width); LOAD_DLL_FN (gdklib, gdk_pixbuf_get_height); @@ -9379,12 +9394,18 @@ init_svg_functions (void) # undef g_clear_error # undef g_object_unref # undef g_type_init -# undef rsvg_handle_close # undef rsvg_handle_get_dimensions # undef rsvg_handle_get_pixbuf -# undef rsvg_handle_new -# undef rsvg_handle_set_base_uri -# undef rsvg_handle_write +# if LIBRSVG_CHECK_VERSION (2, 32, 0) +# undef g_file_new_for_path +# undef g_memory_input_stream_new_from_data +# undef rsvg_handle_new_from_stream_sync +# else +# undef rsvg_handle_close +# undef rsvg_handle_new +# undef rsvg_handle_set_base_uri +# undef rsvg_handle_write +# endif # define gdk_pixbuf_get_bits_per_sample fn_gdk_pixbuf_get_bits_per_sample # define gdk_pixbuf_get_colorspace fn_gdk_pixbuf_get_colorspace @@ -9399,12 +9420,19 @@ init_svg_functions (void) # if ! GLIB_CHECK_VERSION (2, 36, 0) # define g_type_init fn_g_type_init # endif -# define rsvg_handle_close fn_rsvg_handle_close # define rsvg_handle_get_dimensions fn_rsvg_handle_get_dimensions # define rsvg_handle_get_pixbuf fn_rsvg_handle_get_pixbuf -# define rsvg_handle_new fn_rsvg_handle_new -# define rsvg_handle_set_base_uri fn_rsvg_handle_set_base_uri -# define rsvg_handle_write fn_rsvg_handle_write +# if LIBRSVG_CHECK_VERSION (2, 32, 0) +# define g_file_new_for_path fn_g_file_new_for_path +# define g_memory_input_stream_new_from_data \ + fn_g_memory_input_stream_new_from_data +# define rsvg_handle_new_from_stream_sync fn_rsvg_handle_new_from_stream_sync +# else +# define rsvg_handle_close fn_rsvg_handle_close +# define rsvg_handle_new fn_rsvg_handle_new +# define rsvg_handle_set_base_uri fn_rsvg_handle_set_base_uri +# define rsvg_handle_write fn_rsvg_handle_write +# endif # endif /* !WINDOWSNT */ @@ -9489,6 +9517,18 @@ svg_load_image (struct frame *f, struct image *img, char *contents, g_type_init (); #endif +#if LIBRSVG_CHECK_VERSION (2, 32, 0) + GInputStream *input_stream + = g_memory_input_stream_new_from_data (contents, size, NULL); + GFile *base_file = filename ? g_file_new_for_path (filename) : NULL; + rsvg_handle = rsvg_handle_new_from_stream_sync (input_stream, base_file, + RSVG_HANDLE_FLAGS_NONE, + NULL, &err); + if (base_file) + g_object_unref (base_file); + g_object_unref (input_stream); + if (err) goto rsvg_error; +#else /* Make a handle to a new rsvg object. */ rsvg_handle = rsvg_handle_new (); @@ -9498,17 +9538,6 @@ svg_load_image (struct frame *f, struct image *img, char *contents, if (filename) rsvg_handle_set_base_uri (rsvg_handle, filename); - /* Suppress GCC deprecation warnings starting in librsvg 2.45.1 for - rsvg_handle_write and rsvg_handle_close. FIXME: Use functions - like rsvg_handle_new_from_gfile_sync on newer librsvg versions, - and remove this hack. */ - #if GNUC_PREREQ (4, 6, 0) - #pragma GCC diagnostic push - #endif - #if LIBRSVG_CHECK_VERSION (2, 45, 1) && GNUC_PREREQ (4, 2, 0) - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" - #endif - /* Parse the contents argument and fill in the rsvg_handle. */ rsvg_handle_write (rsvg_handle, (unsigned char *) contents, size, &err); if (err) goto rsvg_error; @@ -9517,10 +9546,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents, for further writes. */ rsvg_handle_close (rsvg_handle, &err); if (err) goto rsvg_error; - - #if GNUC_PREREQ (4, 6, 0) - #pragma GCC diagnostic pop - #endif +#endif rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); if (! check_image_size (f, dimension_data.width, dimension_data.height)) -- 2.17.1 --------------989D23AD741F96A9D69F59D3--