aboutsummaryrefslogtreecommitdiffstats
path: root/src/xml.c
diff options
context:
space:
mode:
authorRobert Pluim2017-11-03 11:33:06 +0200
committerEli Zaretskii2017-11-03 11:33:06 +0200
commit620247ac205b80ceb142ee70500ab2c3ffa46fe2 (patch)
treedeb29eb58c456575d69b51f92decb8faab550c45 /src/xml.c
parent92b2cedec60f47faa896963b51bfd370eb3e71cb (diff)
downloademacs-620247ac205b80ceb142ee70500ab2c3ffa46fe2.tar.gz
emacs-620247ac205b80ceb142ee70500ab2c3ffa46fe2.zip
New function '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. (GnuTLS Cryptography, Format of GnuTLS Cryptography Inputs) (Document Object Model): Fix indentation of the first paragraph. * etc/NEWS (libxml-available-p): Mention libxml-available-p.
Diffstat (limited to 'src/xml.c')
-rw-r--r--src/xml.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/xml.c b/src/xml.c
index d087a34a5e0..7afaa63c421 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -18,15 +18,15 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
18 18
19#include <config.h> 19#include <config.h>
20 20
21#include "lisp.h"
22#include "buffer.h"
23
21#ifdef HAVE_LIBXML2 24#ifdef HAVE_LIBXML2
22 25
23#include <libxml/tree.h> 26#include <libxml/tree.h>
24#include <libxml/parser.h> 27#include <libxml/parser.h>
25#include <libxml/HTMLparser.h> 28#include <libxml/HTMLparser.h>
26 29
27#include "lisp.h"
28#include "buffer.h"
29
30 30
31#ifdef WINDOWSNT 31#ifdef WINDOWSNT
32 32
@@ -291,16 +291,43 @@ If DISCARD-COMMENTS is non-nil, all HTML comments are discarded. */)
291 return parse_region (start, end, base_url, discard_comments, false); 291 return parse_region (start, end, base_url, discard_comments, false);
292 return Qnil; 292 return Qnil;
293} 293}
294#endif /* HAVE_LIBXML2 */
294 295
295 296
297
298DEFUN ("libxml-available-p", Flibxml_available_p, Slibxml_available_p, 0, 0, 0,
299 doc: /* Return t if libxml2 support is available in this instance of Emacs.*/)
300 (void)
301{
302#ifdef HAVE_LIBXML2
303# ifdef WINDOWSNT
304 Lisp_Object found = Fassq (Qlibxml2, Vlibrary_cache);
305 if (CONSP (found))
306 return XCDR (found);
307 else
308 {
309 Lisp_Object status;
310 status = init_libxml2_functions () ? Qt : Qnil;
311 Vlibrary_cache = Fcons (Fcons (Qlibxml2, status), Vlibrary_cache);
312 return status;
313 }
314# else
315 return Qt;
316# endif /* WINDOWSNT */
317#else
318 return Qnil;
319#endif /* HAVE_LIBXML2 */
320}
321
296/*********************************************************************** 322/***********************************************************************
297 Initialization 323 Initialization
298 ***********************************************************************/ 324 ***********************************************************************/
299void 325void
300syms_of_xml (void) 326syms_of_xml (void)
301{ 327{
328#ifdef HAVE_LIBXML2
302 defsubr (&Slibxml_parse_html_region); 329 defsubr (&Slibxml_parse_html_region);
303 defsubr (&Slibxml_parse_xml_region); 330 defsubr (&Slibxml_parse_xml_region);
331#endif
332 defsubr (&Slibxml_available_p);
304} 333}
305
306#endif /* HAVE_LIBXML2 */