From: Lars Ingebrigtsen <larsi@gnus.org>
To: npostavs@users.sourceforge.net
Cc: 27178@debbugs.gnu.org, Sean McAfee <eefacm@gmail.com>
Subject: bug#27178: 26.0.50; libxml-parse-*-region functions ignore discard-comments argument
Date: Sat, 14 Apr 2018 00:54:09 +0200 [thread overview]
Message-ID: <87bmemn2em.fsf@mouse.gnus.org> (raw)
In-Reply-To: <877f0jx2oh.fsf@users.sourceforge.net> (npostavs's message of "Sat, 10 Jun 2017 11:50:06 -0400")
I tried the following, but it's not correct, since it resulted in
(html nil (body nil (p nil "This " nil " that")))
But what should the result be here?
(html nil (body nil (p nil "This that")))
or
(html nil (body nil (p nil "This " " that")))
?
I think the former... Which means that you'd have to do some major
doctoring of the structures, I think?
diff --git a/src/xml.c b/src/xml.c
index 42059d7713..bf416407da 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -119,7 +119,7 @@ init_libxml2_functions (void)
}
static Lisp_Object
-make_dom (xmlNode *node)
+make_dom (xmlNode *node, bool discard_comments)
{
if (node->type == XML_ELEMENT_NODE)
{
@@ -148,7 +148,7 @@ make_dom (xmlNode *node)
child = node->children;
while (child != NULL)
{
- result = Fcons (make_dom (child), result);
+ result = Fcons (make_dom (child, discard_comments), result);
child = child->next;
}
@@ -163,7 +163,7 @@ make_dom (xmlNode *node)
}
else if (node->type == XML_COMMENT_NODE)
{
- if (node->content)
+ if (node->content && ! discard_comments)
return list3 (intern ("comment"), Qnil,
build_string ((char *) node->content));
else
@@ -239,7 +239,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url,
while (n) {
if (!NILP (r))
result = Fcons (r, result);
- r = make_dom (n);
+ r = make_dom (n, false);
n = n->next;
}
}
@@ -249,7 +249,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url,
them. Get the tree the proper way. */
xmlNode *node = xmlDocGetRootElement (doc);
if (node != NULL)
- result = make_dom (node);
+ result = make_dom (node, !NILP(discard_comments));
} else
result = Fcons (Qtop, Fcons (Qnil, Fnreverse (Fcons (r, result))));
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2018-04-13 22:54 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 0:07 bug#27178: 26.0.50; libxml-parse-*-region functions ignore discard-comments argument Sean McAfee
2017-06-10 15:50 ` npostavs
2018-04-13 22:54 ` Lars Ingebrigtsen [this message]
2018-04-14 6:49 ` Eli Zaretskii
2018-04-14 13:11 ` Lars Ingebrigtsen
2018-04-14 13:28 ` Eli Zaretskii
2018-04-14 13:54 ` Lars Ingebrigtsen
2018-04-14 15:00 ` Eli Zaretskii
2018-04-14 15:14 ` Lars Ingebrigtsen
2018-04-14 15:17 ` Noam Postavsky
2018-04-14 15:21 ` Lars Ingebrigtsen
2018-04-14 15:35 ` Eli Zaretskii
2018-04-14 15:43 ` Lars Ingebrigtsen
2018-04-14 16:24 ` Eli Zaretskii
2018-04-14 15:35 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bmemn2em.fsf@mouse.gnus.org \
--to=larsi@gnus.org \
--cc=27178@debbugs.gnu.org \
--cc=eefacm@gmail.com \
--cc=npostavs@users.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).