[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos
From: |
handa |
Subject: |
bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos |
Date: |
Sat, 27 Mar 2021 14:38:56 +0900 |
In article <83ft0obk7i.fsf@gnu.org>, Eli Zaretskii <eliz@gnu.org> writes:
> 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 ().
---
K. Handa
handa@gnu.org
diff --git a/src/coding.c b/src/coding.c
index 221a9cad89..a9d5a7ccdc 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -7799,7 +7799,14 @@ encode_coding (struct coding_system *coding)
coding_set_source (coding);
consume_chars (coding, translation_table, max_lookup);
coding_set_destination (coding);
+ /* If consume_chars did not consume all source chars, we call
+ coding->encoder again in the next iteration, and thus, for this
+ iteration, we must clear CODING_MODE_LAST_BLOCK flag. */
+ unsigned saved_mode = coding->mode;
+ if (coding->consumed_char < coding->src_chars)
+ coding->mode &= ~CODING_MODE_LAST_BLOCK;
(*(coding->encoder)) (coding);
+ coding->mode = saved_mode;
} while (coding->consumed_char < coding->src_chars);
if (BUFFERP (coding->dst_object) && coding->produced_char > 0)
- bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos, Gregory Heytings, 2021/03/04
- bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos, Eli Zaretskii, 2021/03/21
- bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos,
handa <=
- bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos, Eli Zaretskii, 2021/03/27
- bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos, handa, 2021/03/27
- bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos, Eli Zaretskii, 2021/03/27
- bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos, handa, 2021/03/28
- bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos, Eli Zaretskii, 2021/03/28
- bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos, Gregory Heytings, 2021/03/27