From: Eli Zaretskii Date: Tue, 16 Jun 2015 14:37:45 +0000 (+0300) Subject: Fix infloop in filepos-to-bufferpos X-Git-Tag: emacs-25.0.90~1744 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=34a43ba26a049bb966426022ffb2c41ab07841b8;p=emacs.git Fix infloop in filepos-to-bufferpos * 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) --- diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el index 92c540cea7d..2b4638bb2c8 100644 --- a/lisp/international/mule-util.el +++ b/lisp/international/mule-util.el @@ -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))