summaryrefslogtreecommitdiff
path: root/src/xml.c
diff options
context:
space:
mode:
authorRobert Pluim <rpluim@gmail.com>2017-11-03 11:33:06 +0200
committerEli Zaretskii <eliz@gnu.org>2017-11-03 11:33:06 +0200
commit620247ac205b80ceb142ee70500ab2c3ffa46fe2 (patch)
treedeb29eb58c456575d69b51f92decb8faab550c45 /src/xml.c
parent92b2cedec60f47faa896963b51bfd370eb3e71cb (diff)
downloademacs-620247ac205b80ceb142ee70500ab2c3ffa46fe2.tar.gz
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/>. */
#include <config.h>
+#include "lisp.h"
+#include "buffer.h"
+
#ifdef HAVE_LIBXML2
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/HTMLparser.h>
-#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 */