From 34a43ba26a049bb966426022ffb2c41ab07841b8 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 16 Jun 2015 17:37:45 +0300 Subject: [PATCH] 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) --- lisp/international/mule-util.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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)) -- 2.39.5