From b897bbc8135901c8edc24fc608a92d9deedeec60 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Sat, 27 Mar 2021 14:38:56 +0900 Subject: [PATCH] Fix encoding by ISO-2022-JP * src/coding.c (encode_coding): Reset the CODING_MODE_LAST_BLOCK flag for all iterations but the last one. (Bug#46933) --- src/coding.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/coding.c b/src/coding.c index 739dd6adcb5..46e7fca0f43 100644 --- a/src/coding.c +++ b/src/coding.c @@ -7799,7 +7799,13 @@ encode_coding (struct coding_system *coding) coding_set_source (coding); consume_chars (coding, translation_table, max_lookup); coding_set_destination (coding); + /* The CODING_MODE_LAST_BLOCK flag should be set only for the last + iteration of the encoding. */ + 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) -- 2.39.2