summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2015-06-16 17:37:45 +0300
committerEli Zaretskii <eliz@gnu.org>2015-06-16 17:37:45 +0300
commit34a43ba26a049bb966426022ffb2c41ab07841b8 (patch)
treec1fab06f16a965d03326c8e37f3c535f4024e389
parent93ae9f46e7947aeb2180e3b8a98b551fa143ba51 (diff)
downloademacs-34a43ba26a049bb966426022ffb2c41ab07841b8.tar.gz
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)
-rw-r--r--lisp/international/mule-util.el8
1 files 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))