]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix infloop in filepos-to-bufferpos
authorEli Zaretskii <eliz@gnu.org>
Tue, 16 Jun 2015 14:37:45 +0000 (17:37 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 16 Jun 2015 14:37:45 +0000 (17:37 +0300)
* lisp/international/mule-util.el (filepos-to-bufferpos): Fix EOL
offset calculation, and make it conditional on the eol-type of the
file's encoding.  (Bug#20825)

lisp/international/mule-util.el

index 92c540cea7d2536403d3eb00d5c400a551303e54..2b4638bb2c8e44d6702fd347f064370651524bf6 100644 (file)
@@ -335,9 +335,11 @@ QUALITY can be:
          (while
              (progn
                (setq pos (byte-to-position (+ pm byte (- eol-offset))))
-               (setq lines (1- (line-number-at-pos pos)))
-               (not (= lines eol-offset)))
-           (setq eol-offset (+ eol-offset lines)))
+              ;; Adjust POS for DOS EOL format.
+              (when (= eol 1)
+                (setq lines (1- (line-number-at-pos pos)))
+                (not (= lines eol-offset))))
+           (setq eol-offset lines))
          pos))
       ;; FIXME: What if it's a 2-byte charset?  Are there such beasts?
       (`charset (+ pm byte))