From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#27178: 26.0.50; libxml-parse-*-region functions ignore discard-comments argument Date: Sat, 14 Apr 2018 00:54:09 +0200 Message-ID: <87bmemn2em.fsf@mouse.gnus.org> References: <877f0jx2oh.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1523660101 11663 195.159.176.226 (13 Apr 2018 22:55:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 13 Apr 2018 22:55:01 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 27178@debbugs.gnu.org, Sean McAfee To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 14 00:54:56 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f77aq-0002v4-03 for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Apr 2018 00:54:56 +0200 Original-Received: from localhost ([::1]:33732 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f77cw-0003u2-Ld for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Apr 2018 18:57:06 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:38016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f77bw-0003fp-JG for bug-gnu-emacs@gnu.org; Fri, 13 Apr 2018 18:56:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f77aw-0004gB-AV for bug-gnu-emacs@gnu.org; Fri, 13 Apr 2018 18:56:04 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43185) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f77aw-0004g3-4h for bug-gnu-emacs@gnu.org; Fri, 13 Apr 2018 18:55:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f77av-0002FE-Sy for bug-gnu-emacs@gnu.org; Fri, 13 Apr 2018 18:55:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Apr 2018 22:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27178 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 27178-submit@debbugs.gnu.org id=B27178.15236600628572 (code B ref 27178); Fri, 13 Apr 2018 22:55:01 +0000 Original-Received: (at 27178) by debbugs.gnu.org; 13 Apr 2018 22:54:22 +0000 Original-Received: from localhost ([127.0.0.1]:51081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f77aH-0002EC-W5 for submit@debbugs.gnu.org; Fri, 13 Apr 2018 18:54:22 -0400 Original-Received: from hermes.netfonds.no ([80.91.224.195]:47096) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f77aG-0002E2-1b for 27178@debbugs.gnu.org; Fri, 13 Apr 2018 18:54:20 -0400 Original-Received: from 46.67.12.60.tmi.telenormobil.no ([46.67.12.60] helo=corrigan) by hermes.netfonds.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1f77aA-00082K-VB; Sat, 14 Apr 2018 00:54:17 +0200 Original-Received: from larsi by corrigan with local (Exim 4.89) (envelope-from ) id 1f77a5-0003lS-F5; Sat, 14 Apr 2018 00:54:09 +0200 In-Reply-To: <877f0jx2oh.fsf@users.sourceforge.net> (npostavs's message of "Sat, 10 Jun 2017 11:50:06 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:145315 Archived-At: 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