emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in lisp/xml.el


From: Ari Roponen
Subject: Bug in lisp/xml.el
Date: Tue, 31 Jan 2006 21:33:46 +0200 (EET)

Hi,

there seems to be a bug in lisp/xml.el.

If I execute the following expression, it fails with error
`args-out-of-range':


(progn
  (require 'xml)
  (with-temp-buffer
    (insert "<a>first</a>\n<b>second</b>\n")
    (goto-char (point-min))
    (forward-line)

    (let ((buf (current-buffer))
          (beg (point))
          (end (line-end-position)))

      (princ (xml-parse-region beg end buf))    ; This works.

      (with-temp-buffer                 ; This doesn't work.
        (princ (xml-parse-region beg end buf))))))


I think that this happens because `xml-parse-region' uses
narrow-to-region before the given buffer is set current.

The following patch should fix it. It moves save-restriction and
narrow-to-region after the possible call to set-buffer.

-
Ari Roponen


*** xml.el.orig 2005-11-03 17:27:02.000000000 +0200
--- xml.el      2006-01-31 20:53:08.000000000 +0200
***************
*** 306,321 ****
  If PARSE-DTD is non-nil, the DTD is parsed rather than skipped,
  and returned as the first element of the list.
  If PARSE-NS is non-nil, then QNAMES are expanded."
!   (save-restriction
!     (narrow-to-region beg end)
!     ;; Use fixed syntax table to ensure regexp char classes and syntax
!     ;; specs DTRT.
!     (with-syntax-table (standard-syntax-table)
!       (let ((case-fold-search nil)    ; XML is case-sensitive.
!           xml result dtd)
!       (save-excursion
!         (if buffer
!             (set-buffer buffer))
          (goto-char (point-min))
          (while (not (eobp))
            (if (search-forward "<" nil t)
--- 306,321 ----
  If PARSE-DTD is non-nil, the DTD is parsed rather than skipped,
  and returned as the first element of the list.
  If PARSE-NS is non-nil, then QNAMES are expanded."
!   ;; Use fixed syntax table to ensure regexp char classes and syntax
!   ;; specs DTRT.
!   (with-syntax-table (standard-syntax-table)
!     (let ((case-fold-search nil)      ; XML is case-sensitive.
!         xml result dtd)
!       (save-excursion
!       (if buffer
!           (set-buffer buffer))
!       (save-restriction
!         (narrow-to-region beg end)
          (goto-char (point-min))
          (while (not (eobp))
            (if (search-forward "<" nil t)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]