Subject: bug#21293: 24.5; libxml-xml-parse-region and comments at end of file

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 01 Mar 2016 17:09:47 +1100

patrick mc allister <[email-masked]> writes:

> It seems something goes wrong with `libxml-parse-xml-region' when
> there are comments at the end of the file:
>
> emacs -Q
>
> then run this function to see the problem:
>
> (defun setup-problem ()
>   (let ((testBuffer (get-buffer-create "*a libxml parse problem")))
>     (with-current-buffer testBuffer
>       (erase-buffer)
>       (insert "<something />
> <!-- a comment -->
> <!-- another comment -->")
>       (goto-char (point-min))
>       (libxml-parse-xml-region (point-min) (point-max)))))
>
> (setup-problem) ;; (top nil (comment nil " a comment ") (comment nil " another comment "))

I'm unable to reproduce this problem with the current Emacs trunk.  I get:

(top nil (something nil) (comment nil " a comment ") (comment nil " another comment "))

> So it seems the "something" element does not make it into the list?
> The problem only appears if there are more than two comments at the
> end. If there's only one, the region gets parsed as expected, and the
> last comment gets lost:
>
> (defun setup-problem-b ()
>   (let ((testBuffer (get-buffer-create "*a libxml parse problem")))
>     (with-current-buffer testBuffer
>       (erase-buffer)
>       (insert "<something />
> <!-- only one comment -->")
>       (goto-char (point-min))
>       (libxml-parse-xml-region (point-min) (point-max)))))
>
> (setup-problem-b) ;; (something nil)

And this seems to work, too.

This looks like it was fixed by Ulf Jasper a while ago, according to the
git log, so I'm closing this bug report.  If you're still seeing this,
please reopen.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no