aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/emacs.c2
-rw-r--r--src/lisp.h2
-rw-r--r--src/xml.c37
3 files changed, 33 insertions, 8 deletions
diff --git a/src/emacs.c b/src/emacs.c
index 0fe7d9113b4..808abcd9aa2 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
1542#endif 1542#endif
1543#endif /* HAVE_X_WINDOWS */ 1543#endif /* HAVE_X_WINDOWS */
1544 1544
1545#ifdef HAVE_LIBXML2
1546 syms_of_xml (); 1545 syms_of_xml ();
1547#endif
1548 1546
1549#ifdef HAVE_LCMS2 1547#ifdef HAVE_LCMS2
1550 syms_of_lcms2 (); 1548 syms_of_lcms2 ();
diff --git a/src/lisp.h b/src/lisp.h
index 78843483edc..1ce32f33420 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4391,9 +4391,9 @@ extern void syms_of_xterm (void);
4391extern char *x_get_keysym_name (int); 4391extern char *x_get_keysym_name (int);
4392#endif /* HAVE_WINDOW_SYSTEM */ 4392#endif /* HAVE_WINDOW_SYSTEM */
4393 4393
4394#ifdef HAVE_LIBXML2
4395/* Defined in xml.c. */ 4394/* Defined in xml.c. */
4396extern void syms_of_xml (void); 4395extern void syms_of_xml (void);
4396#ifdef HAVE_LIBXML2
4397extern void xml_cleanup_parser (void); 4397extern void xml_cleanup_parser (void);
4398#endif 4398#endif
4399 4399
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 */