From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: What's the right way to detect libxml2? Date: Mon, 30 Oct 2017 09:49:45 +0100 Message-ID: <87d155aul2.fsf@gmail.com> References: <7f80cde1944261b7ee29020ff953f14c.squirrel@cloud103.planethippo.com> <36e54d52-99b2-ae53-2b36-99d06eb53d15@gmail.com> <877evkfpe1.fsf@gmail.com> <873767fp1p.fsf@gmail.com> <83wp3f63jk.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1509353437 21574 195.159.176.226 (30 Oct 2017 08:50:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 30 Oct 2017 08:50:37 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cc: andrewjmoreton@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 30 09:50:32 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e95m7-0004Yf-Sj for ged-emacs-devel@m.gmane.org; Mon, 30 Oct 2017 09:50:28 +0100 Original-Received: from localhost ([::1]:39220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e95mD-0007q1-Pf for ged-emacs-devel@m.gmane.org; Mon, 30 Oct 2017 04:50:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e95lZ-0007pk-99 for emacs-devel@gnu.org; Mon, 30 Oct 2017 04:49:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e95lW-0007Zc-5U for emacs-devel@gnu.org; Mon, 30 Oct 2017 04:49:53 -0400 Original-Received: from mail-wm0-x22c.google.com ([2a00:1450:400c:c09::22c]:54874) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e95lV-0007ZF-Pa; Mon, 30 Oct 2017 04:49:50 -0400 Original-Received: by mail-wm0-x22c.google.com with SMTP id r68so14716072wmr.3; Mon, 30 Oct 2017 01:49:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:gmane-reply-to-list:date:in-reply-to :message-id:user-agent:mime-version; bh=cGrHGufoyH4/PHaVY4Cjkus2cRhLHAT4AcjGXZeuIdc=; b=l89HsVSR7fl23mT8iGkheUxatVoguRAD1pSsaj/33/SGa8THekPhBCllQTtHh5+7BX r+X6wVQ6A2m6PvxtCETpNk9z1xwartb+JgkDsJ9wg4Ahi221vI6O8tdSd5o/4L3D/mpw q22UcQkUonpZwdZ0UulaqrsVhFPW5gGSz3m6+JX8Uoo0XksARDBY/pO71JNDwos79xHr 7pnBFF/N7O/sEV7ghD2suDUVJw/wSZ9YdO9myYU7vbRgp55mC6Xu33JT9pBLqF9j/tpp qDDhW4tEskRdtYsIADT9OOnIFXIwre9aplYrxGPm7lYuOW0oROy5F/MztFvNsYCgavsA oilQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references :gmane-reply-to-list:date:in-reply-to:message-id:user-agent :mime-version; bh=cGrHGufoyH4/PHaVY4Cjkus2cRhLHAT4AcjGXZeuIdc=; b=eQQnQOtyAl8TWzO6jXmI5tNDGysnFQEIlEnMvGm3fZ9JR1BOT0IOE3TfRE9PY4XF2t USVGmOHKTNPH19fCY7TxfG1Ptmhor4KCFhKdqphWc7P6Fj+b8N2/Zw2WbeWXzqoTpQqm AQlau0RLO1h+I3KNRdmJMSJJykRYEWHAcwYDwmFxl1VqsKW5tY7L9p0vdTIypZ+3wLeC axJEgnOkQgp5iRXEb8vCgJ+gd8xmD6p0lEY6gKrkeT6nmRRqwSfG+xkYaEzVsneHbbAf Hrnf8G9A3uQx8X5xk3sf9+P8s4y5EwdzN1bewY3fpQf7KkOgbvAOmMqgFrfAEy6eMKap JvJQ== X-Gm-Message-State: AMCzsaU5wnLv0WEJzH79HkzED/z2YrFAoPZ3QCN2N4hhnj/fjyNd82By fFWY2ooT7DPFfXCJtX+u3UnO8QIb X-Google-Smtp-Source: ABhQp+QNT5uw9uFJVE9bTfgYZEbcx4WX0z2mfLFGBkefxB9hyHJMltnbR67sARqVkkLSXpWpYYBCdA== X-Received: by 10.80.180.187 with SMTP id w56mr10705450edd.15.1509353388003; Mon, 30 Oct 2017 01:49:48 -0700 (PDT) Original-Received: from rpluim-ubuntu ([149.5.228.1]) by smtp.gmail.com with ESMTPSA id j6sm9494325edj.58.2017.10.30.01.49.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Oct 2017 01:49:46 -0700 (PDT) Gmane-Reply-To-List: yes In-Reply-To: <83wp3f63jk.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 28 Oct 2017 12:10:39 +0300") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::22c X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:219826 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > This is okay for the master branch, but please also add a NEWS entry > about the new function, and the fact that from now on the detection of > libxml2 availability should use that. Attached, as I don't have commit privileges, and I don't know whether my copyright assignment has finished being processed yet. Regards Robert --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Provide-libxml-available-p.patch >From 7793e1feeac2714abee2bdf76ef7170e86821895 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 24 Oct 2017 19:01:28 +0200 Subject: [PATCH] Provide libxml-available-p * src/emacs.c (main): Call syms_of_xml unconditionally * src/lisp.h: Provide syms_of_xml prototype even when HAVE_LIBXML2 is not defined * src/xml.c (Flibxml_available_p): New function, cloned from Fgnutls_available_p (syms_of_xml): Provide Slibxml_available_p * doc/lispref/text.texi (Parsing HTML/XML): Document libxml-available-p * etc/NEWS (libxml-available-p): Document it --- doc/lispref/text.texi | 5 +++++ etc/NEWS | 5 +++++ src/emacs.c | 2 -- src/lisp.h | 2 +- src/xml.c | 37 ++++++++++++++++++++++++++++++++----- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index baa3c708e9..565d098069 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -4723,6 +4723,11 @@ Parsing HTML/XML @section Parsing HTML and XML @cindex parsing html +@defun libxml-available-p +This function returns non-@code{nil} if built-in libxml2 support is +available. +@end defun + When Emacs is compiled with libxml2 support, the following functions are available to parse HTML or XML text into Lisp object trees. diff --git a/etc/NEWS b/etc/NEWS index 9ae36bdb03..dfe1dcd0d9 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -39,6 +39,11 @@ text. +++ ** New function 'logcount' calculates an integer's Hamming weight. ++++ +** New function 'libxml-available-p' returns true if libxml support is + both compiled in and available. It is defined unconditionally and + can thus be used to detect libxml support. + * Editing Changes in Emacs 27.1 diff --git a/src/emacs.c b/src/emacs.c index 0fe7d9113b..808abcd9aa 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1542,9 +1542,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem #endif #endif /* HAVE_X_WINDOWS */ -#ifdef HAVE_LIBXML2 syms_of_xml (); -#endif #ifdef HAVE_LCMS2 syms_of_lcms2 (); diff --git a/src/lisp.h b/src/lisp.h index 266370333f..cc8d90cbf1 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4399,9 +4399,9 @@ extern void syms_of_xterm (void); extern char *x_get_keysym_name (int); #endif /* HAVE_WINDOW_SYSTEM */ -#ifdef HAVE_LIBXML2 /* Defined in xml.c. */ extern void syms_of_xml (void); +#ifdef HAVE_LIBXML2 extern void xml_cleanup_parser (void); #endif diff --git a/src/xml.c b/src/xml.c index d087a34a5e..7afaa63c42 100644 --- a/src/xml.c +++ b/src/xml.c @@ -18,15 +18,15 @@ along with GNU Emacs. If not, see . */ #include +#include "lisp.h" +#include "buffer.h" + #ifdef HAVE_LIBXML2 #include #include #include -#include "lisp.h" -#include "buffer.h" - #ifdef WINDOWSNT @@ -291,16 +291,43 @@ If DISCARD-COMMENTS is non-nil, all HTML comments are discarded. */) return parse_region (start, end, base_url, discard_comments, false); return Qnil; } +#endif /* HAVE_LIBXML2 */ + +DEFUN ("libxml-available-p", Flibxml_available_p, Slibxml_available_p, 0, 0, 0, + doc: /* Return t if libxml2 support is available in this instance of Emacs.*/) + (void) +{ +#ifdef HAVE_LIBXML2 +# ifdef WINDOWSNT + Lisp_Object found = Fassq (Qlibxml2, Vlibrary_cache); + if (CONSP (found)) + return XCDR (found); + else + { + Lisp_Object status; + status = init_libxml2_functions () ? Qt : Qnil; + Vlibrary_cache = Fcons (Fcons (Qlibxml2, status), Vlibrary_cache); + return status; + } +# else + return Qt; +# endif /* WINDOWSNT */ +#else + return Qnil; +#endif /* HAVE_LIBXML2 */ +} + /*********************************************************************** Initialization ***********************************************************************/ void syms_of_xml (void) { +#ifdef HAVE_LIBXML2 defsubr (&Slibxml_parse_html_region); defsubr (&Slibxml_parse_xml_region); +#endif + defsubr (&Slibxml_available_p); } - -#endif /* HAVE_LIBXML2 */ -- 2.15.0.rc1 --=-=-=--