GNU bug report logs -
#46933
Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos
Previous Next
Full log
View this message in rfc822 format
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, gregory <at> heytings.org, 46933 <at> debbugs.gnu.org
> Date: Mon, 20 Jun 2022 02:59:52 +0200
>
> handa <handa <at> gnu.org> writes:
>
> > For the latter case, perhaps something like the following code works.
> >
> > ;; Return the buffer position correspoinding to the byte position
> > ;; FILEPOS in FILE provided that FILE is decoded by CODING-SYSTEM.
> > (defun temp (file filepos coding-system)
> > (with-temp-buffer
> > (set-buffer-multibyte nil)
> > (insert-file-contents-literally file)
> > (let ((full (decode-coding-region 1 (point-max) coding-system t))
> > partial)
> > (while (and (setq partial (decode-coding-region 1 (1+ filepos)
> > coding-system t))
> > (not (eq (compare-strings full 0 (length partial)
> > partial 0 (length partial))
> > t)))
> > (setq filepos (1+ filepos)))
> > (1+ (length partial)))))
> >
> > If it is too slow, there are a few ways to make it faster.
>
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)
>
> If I understand correctly, the suggestion here is to use this function
> in Info-find-node-2 instead of `filepos-to-bufferpos'?
"Unless it's too slow".
This bug report was last modified 3 years and 53 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.