From ca65341ea8fd2488586ddde61380022e5b125551 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Sat, 20 Jun 1998 03:01:00 +0000 Subject: [PATCH] (read_process_output): Handle carryover correctly. --- src/process.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/process.c b/src/process.c index 305a6780e4..a935596859 100644 --- a/src/process.c +++ b/src/process.c @@ -2833,6 +2833,8 @@ read_process_output (proc, channel) chars = buf; #endif /* not VMS */ + XSETINT (p->decoding_carryover, 0); + /* At this point, NBYTES holds number of characters just received (including the one in proc_buffered_char[channel]). */ if (nbytes <= 0) return nbytes; @@ -2851,6 +2853,18 @@ read_process_output (proc, channel) result = decode_coding (coding, chars, XSTRING (p->decoding_buf)->data, nbytes, STRING_BYTES (XSTRING (p->decoding_buf))); carryover = nbytes - coding->consumed; + if (carryover > 0) + { + /* We must move the data carried over to the tail of + decoding buffer. We are sure that the size of decoding + buffer (decided by decoding_buffer_size) is large enough + to contain them. */ + bcopy (chars + nbytes - carryover, + (XSTRING (p->decoding_buf)->data + + STRING_BYTES (XSTRING (p->decoding_buf)) - carryover), + carryover); + XSETINT (p->decoding_carryover, carryover); + } /* A new coding system might be found by `decode_coding'. */ if (!EQ (p->decode_coding_system, coding->symbol)) @@ -2904,11 +2918,9 @@ read_process_output (proc, channel) chars = XSTRING (p->decoding_buf)->data; nchars = multibyte_chars_in_text (chars, nbytes); chars_in_decoding_buf = 1; - carryover = 0; } #endif - XSETINT (p->decoding_carryover, carryover); Vlast_coding_system_used = coding->symbol; /* If the caller required, let the process associated buffer -- 2.20.1