1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-23 10:34:07 +00:00

Rename libxml2 functions, and make parse tree format consistent with xml.el.

* xml.c: Switch to GNU indentation.
(make_dom): Change parse tree format to match xml.el.
(Fxml_parse_html_string_internal): Rename from html-parse-string.
(Fxml_parse_string_internal): Rename from xml-parse-string.

* configure.in: Announce whether libxml2 is linked to.
This commit is contained in:
Chong Yidong 2010-09-21 23:10:16 -04:00
parent 1114abdb3d
commit 4b9832a6f2
6 changed files with 296 additions and 265 deletions

View File

@ -1,3 +1,7 @@
2010-09-22 Chong Yidong <cyd@stupidchicken.com>
* configure.in: Announce whether libxml2 is linked to.
2010-09-20 Dan Nicolaescu <dann@ics.uci.edu>
* configure.in (LINKER): Rename to LD_FIRSTFLAG, do not include $(CC).

412
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -3696,10 +3696,12 @@ echo " Does Emacs use a gif library? ${HAVE_GIF} $LIB
echo " Does Emacs use -lpng? ${HAVE_PNG}"
echo " Does Emacs use -lrsvg-2? ${HAVE_RSVG}"
echo " Does Emacs use imagemagick? ${HAVE_IMAGEMAGICK}"
echo " Does Emacs use -lgpm? ${HAVE_GPM}"
echo " Does Emacs use -ldbus? ${HAVE_DBUS}"
echo " Does Emacs use -lgconf? ${HAVE_GCONF}"
echo " Does Emacs use -lselinux? ${HAVE_LIBSELINUX}"
echo " Does Emacs use -lxml2? ${HAVE_LIBXML2}"
echo " Does Emacs use -lfreetype? ${HAVE_FREETYPE}"
echo " Does Emacs use -lm17n-flt? ${HAVE_M17N_FLT}"

View File

@ -561,10 +561,13 @@ by the Graphic Control Extension of the image.
** XML and HTML parsing
*** If Emacs is compiled with libxml2 support (which is the default),
two new Emacs Lisp-level functions are defined: `html-parse-string'
(which will parse "real world" HTML) and `xml-parse-string' (which
parses XML). Both return an Emacs Lisp parse tree. See the Emacs
Lisp Reference Manual for details.
two new Emacs Lisp-level functions are defined:
`xml-parse-html-string-internal' (which will parse "real world" HTML)
and `xml-parse-string-internal' (which parses XML). Both return an
Emacs Lisp parse tree.
FIXME: These should be front-ended by xml.el.
** Isearch

View File

@ -1,3 +1,10 @@
2010-09-22 Chong Yidong <cyd@stupidchicken.com>
* xml.c: Switch to GNU indentation.
(make_dom): Change parse tree format to match xml.el.
(Fxml_parse_html_string_internal): Rename from html-parse-string.
(Fxml_parse_string_internal): Rename from xml-parse-string.
2010-09-22 Kenichi Handa <handa@m17n.org>
* xdisp.c (compute_stop_pos): Call composition_compute_stop_pos

125
src/xml.c
View File

@ -30,41 +30,46 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
Lisp_Object make_dom (xmlNode *node)
{
if (node->type == XML_ELEMENT_NODE) {
Lisp_Object result = Fcons (intern (node->name), Qnil);
xmlNode *child;
xmlAttr *property;
if (node->type == XML_ELEMENT_NODE)
{
Lisp_Object result = Fcons (intern (node->name), Qnil);
xmlNode *child;
xmlAttr *property;
Lisp_Object plist = Qnil;
/* First add the attributes. */
property = node->properties;
while (property != NULL) {
if (property->children &&
property->children->content) {
char *pname = xmalloc (strlen (property->name) + 2);
*pname = ':';
strcpy(pname + 1, property->name);
result = Fcons (Fcons (intern (pname),
build_string(property->children->content)),
result);
xfree (pname);
}
property = property->next;
/* First add the attributes. */
property = node->properties;
while (property != NULL)
{
if (property->children &&
property->children->content)
{
plist = Fcons (Fcons (intern (property->name),
build_string (property->children->content)),
plist);
}
property = property->next;
}
result = Fcons (Fnreverse (plist), result);
/* Then add the children of the node. */
child = node->children;
while (child != NULL)
{
result = Fcons (make_dom (child), result);
child = child->next;
}
return Fnreverse (result);
}
/* Then add the children of the node. */
child = node->children;
while (child != NULL) {
result = Fcons (make_dom (child), result);
child = child->next;
else if (node->type == XML_TEXT_NODE)
{
if (node->content)
return build_string (node->content);
else
return Qnil;
}
return Fnreverse (result);
} else if (node->type == XML_TEXT_NODE) {
Lisp_Object content = Qnil;
if (node->content)
content = build_string (node->content);
return Fcons (intern (node->name), content);
} else
else
return Qnil;
}
@ -81,47 +86,47 @@ parse_string (Lisp_Object string, Lisp_Object base_url, int htmlp)
CHECK_STRING (string);
if (! NILP (base_url)) {
CHECK_STRING (base_url);
burl = SDATA (base_url);
}
if (! NILP (base_url))
{
CHECK_STRING (base_url);
burl = SDATA (base_url);
}
if (htmlp)
doc = htmlReadMemory (SDATA (string), SBYTES (string), burl, "utf-8",
HTML_PARSE_RECOVER|HTML_PARSE_NONET|
HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR);
else
doc = xmlReadMemory (SDATA (string), SBYTES (string), burl, "utf-8",
XML_PARSE_NONET|XML_PARSE_NOWARNING|
XML_PARSE_NOERROR);
doc = htmlp
? htmlReadMemory (SDATA (string), SBYTES (string), burl, "utf-8",
HTML_PARSE_RECOVER|HTML_PARSE_NONET|
HTML_PARSE_NOWARNING|HTML_PARSE_NOERROR)
: xmlReadMemory (SDATA (string), SBYTES (string), burl, "utf-8",
XML_PARSE_NONET|XML_PARSE_NOWARNING|
XML_PARSE_NOERROR);
if (doc != NULL) {
node = xmlDocGetRootElement (doc);
if (node != NULL)
result = make_dom (node);
xmlFreeDoc (doc);
xmlCleanupParser ();
}
if (doc != NULL)
{
node = xmlDocGetRootElement (doc);
if (node != NULL)
result = make_dom (node);
xmlFreeDoc (doc);
xmlCleanupParser ();
}
return result;
}
DEFUN ("html-parse-string", Fhtml_parse_string, Shtml_parse_string,
DEFUN ("xml-parse-html-string-internal", Fxml_parse_html_string_internal,
Sxml_parse_html_string_internal,
1, 2, 0,
doc: /* Parse STRING as an HTML document and return the parse tree.
If BASE-URL is non-nil, it will be used to expand relative URLs in
the HTML document. */)
If BASE-URL is non-nil, it is used to expand relative URLs. */)
(Lisp_Object string, Lisp_Object base_url)
{
return parse_string (string, base_url, 1);
}
DEFUN ("xml-parse-string", Fxml_parse_string, Sxml_parse_string,
DEFUN ("xml-parse-string-internal", Fxml_parse_string_internal,
Sxml_parse_string_internal,
1, 2, 0,
doc: /* Parse STRING as an XML document and return the parse tree.
If BASE-URL is non-nil, it will be used to expand relative URLs in
the XML document. */)
If BASE-URL is non-nil, it is used to expand relative URLs. */)
(Lisp_Object string, Lisp_Object base_url)
{
return parse_string (string, base_url, 0);
@ -134,8 +139,8 @@ the XML document. */)
void
syms_of_xml (void)
{
defsubr (&Shtml_parse_string);
defsubr (&Sxml_parse_string);
defsubr (&Sxml_parse_html_string_internal);
defsubr (&Sxml_parse_string_internal);
}
#endif /* HAVE_LIBXML2 */