Function: filepos-to-bufferpos--dos

filepos-to-bufferpos--dos is a byte-compiled function defined in mule-util.el.gz.

Signature

(filepos-to-bufferpos--dos BYTE F)

Source Code

;; Defined in /usr/src/emacs/lisp/international/mule-util.el.gz
(defun filepos-to-bufferpos--dos (byte f)
  (let ((eol-offset 0)
        ;; Make sure we terminate, even if BYTE falls right in the middle
        ;; of a CRLF or some other weird corner case.
        (omin 0) omax
        pos lines)
    (while
        (progn
          (setq pos (funcall f (- byte eol-offset)))
          ;; Protect against accidental values of BYTE outside of the
          ;; valid region.
          (when (null pos)
            (if (<= byte eol-offset)
                (setq pos (point-min))
              (setq pos (point-max))))
          ;; Adjust POS for DOS EOL format.
          (setq lines (1- (line-number-at-pos pos)))
          (and (not (= lines eol-offset)) (or (not omax) (> omax omin))))
      (if (> lines eol-offset)
          (setq omax (if omax (min (1- omax) lines) lines)
                eol-offset omax)
        (setq omin (max (1+ omin) lines)
              eol-offset omin)))
    pos))