From: Gregory Heytings <gregory@heytings.org>
To: handa <handa@gnu.org>
Cc: 46933@debbugs.gnu.org
Subject: bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos
Date: Sat, 27 Mar 2021 14:24:58 +0000 [thread overview]
Message-ID: <b2996462741af4c4cb0a@heytings.org> (raw)
In-Reply-To: <874kgxtatr.fsf@gnu.org>
>> Kenichi, why are these 6 bytes inserted by encode-coding-region, but
>> not when we encode the same text as part of saving the buffer to its
>> file? And why does it happen near the end of the text, between those 2
>> particular letters?
>
> There surely exists a bug. Could you please try the attached patch?
>
> The reason why that bug did not happen on file writing is that the code
> in write_region calls encoding routine repeatedly without
> CODING_MODE_LAST_BLOCK flag, and only in the case that flushing is
> required (e.g. the case of iso-2022-jp), just for flushing, it calls
> enoding routine again with CODING_MODE_LAST_BLOCK flag. In that case,
> carryover does not happen in encode_coding ().
>
Thank you. I tried the patch, and it seems to fix the
bufferpos-to-filepos bug, but not the filepos-to-bufferpos one. On the
example file,
(bufferpos-to-filepos (- (point-max) POS) 'exact)
gives the expected results:
POS = 0: 2997
POS = 1: 2995
POS = 2: 2993
POS = 3 (IDEOGRAPHIC FULL STOP): 2991
POS = 4 (HIRAGANA LETTER RU): 2989
But (goto-char (filepos-to-bufferpos POS 'exact)) gives:
POS = 2985, 2986: last but one visible character (HIRAGANA LETTER RU)
POS = 2987, 2988: last visible character (IDEOGRAPHIC FULL STOP)
POS = 2989, 2990: first CRLF
POS = 2991: second CRLF
POS = 2992: point-max
POS = 2993: first CRLF
POS = 2994, 2995: second CRLF
POS >= 2996: point-max
where I would have expected:
POS = 2989, 2990: last but one visible character (HIRAGANA LETTER RU)
POS = 2991, 2992: last visible character (IDEOGRAPHIC FULL STOP)
POS = 2993, 2994: first CRLF
POS = 2995, 2996: second CRLF
POS >= 2997: point-max
prev parent reply other threads:[~2021-03-27 14:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 21:21 bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos Gregory Heytings
2021-03-21 15:27 ` Eli Zaretskii
2021-03-27 5:38 ` handa
2021-03-27 7:54 ` Eli Zaretskii
2021-03-27 13:23 ` handa
2021-03-27 13:54 ` Eli Zaretskii
2021-03-28 14:29 ` handa
2021-03-28 14:51 ` Eli Zaretskii
2021-04-01 15:14 ` handa
2021-04-01 15:25 ` Eli Zaretskii
2021-04-01 15:32 ` Eli Zaretskii
2021-04-03 16:12 ` handa
2022-06-20 0:59 ` Lars Ingebrigtsen
2022-06-20 11:52 ` Eli Zaretskii
2022-06-21 10:40 ` Lars Ingebrigtsen
2022-06-21 12:14 ` Eli Zaretskii
2022-06-22 4:17 ` Lars Ingebrigtsen
2022-06-22 13:11 ` Eli Zaretskii
2021-03-27 14:24 ` Gregory Heytings [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b2996462741af4c4cb0a@heytings.org \
--to=gregory@heytings.org \
--cc=46933@debbugs.gnu.org \
--cc=handa@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).