From 98725083321eff9380c9b4a1516a14a444c05d81 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Wed, 6 Nov 2002 00:10:42 +0000 Subject: [PATCH] (decode_coding_utf_8): When eol_type is Qdos, handle the case that the last byte is '\r' correctly. (decode_coding_emacs_mule): Likewise. (decode_coding_iso_2022): Likewise. (decode_coding_sjis): Likewise. (decode_coding_big5): Likewise. (decode_coding_charset): Likewise. (produce_chars): Likewise. (decode_coding): Flushing out the unprocessed data correctly. (decode_coding_gap): Set CODING_MODE_LAST_BLOCK bit of coding->mode. --- src/coding.c | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/src/coding.c b/src/coding.c index c4f927459ff..6c898b878f4 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1126,7 +1126,10 @@ decode_coding_utf_8 (coding) if (EQ (eol_type, Qdos)) { if (src == src_end) - goto no_more_source; + { + coding->result = CODING_RESULT_INSUFFICIENT_SRC; + goto no_more_source; + } if (*src == '\n') ONE_MORE_BYTE (c); } @@ -1917,7 +1920,10 @@ decode_coding_emacs_mule (coding) if (EQ (eol_type, Qdos)) { if (src == src_end) - goto no_more_source; + { + coding->result = CODING_RESULT_INSUFFICIENT_SRC; + goto no_more_source; + } if (*src == '\n') ONE_MORE_BYTE (c); } @@ -2784,7 +2790,7 @@ decode_coding_iso_2022 (coding) ONE_MORE_BYTE (c1); - /* We produce no character or one character. */ + /* We produce at most one character. */ switch (iso_code_class [c1]) { case ISO_0x20_or_0x7F: @@ -2841,7 +2847,10 @@ decode_coding_iso_2022 (coding) if (EQ (eol_type, Qdos)) { if (src == src_end) - goto no_more_source; + { + coding->result = CODING_RESULT_INSUFFICIENT_SRC; + goto no_more_source; + } if (*src == '\n') ONE_MORE_BYTE (c1); } @@ -3796,7 +3805,10 @@ decode_coding_sjis (coding) if (EQ (eol_type, Qdos)) { if (src == src_end) - goto no_more_source; + { + coding->result = CODING_RESULT_INSUFFICIENT_SRC; + goto no_more_source; + } if (*src == '\n') ONE_MORE_BYTE (c); } @@ -3885,7 +3897,10 @@ decode_coding_big5 (coding) if (EQ (eol_type, Qdos)) { if (src == src_end) - goto no_more_source; + { + coding->result = CODING_RESULT_INSUFFICIENT_SRC; + goto no_more_source; + } if (*src == '\n') ONE_MORE_BYTE (c); } @@ -4429,8 +4444,12 @@ decode_coding_charset (coding) else. */ if (EQ (eol_type, Qdos)) { - if (src < src_end - && *src == '\n') + if (src == src_end) + { + coding->result = CODING_RESULT_INSUFFICIENT_SRC; + goto no_more_source; + } + if (*src == '\n') ONE_MORE_BYTE (c); } else if (EQ (eol_type, Qmac)) @@ -5272,8 +5291,12 @@ produce_chars (coding) { if (EQ (eol_type, Qdos)) { - if (src < src_end - && *src == '\n') + if (src == src_end) + { + coding->result = CODING_RESULT_INSUFFICIENT_SRC; + goto no_more_source; + } + if (*src == '\n') c = *src++; } else if (EQ (eol_type, Qmac)) @@ -5621,12 +5644,11 @@ decode_coding (coding) /* Flush out unprocessed data as binary chars. We are sure that the number of data is less than the size of coding->charbuf. */ - int *charbuf = coding->charbuf; - while (nbytes-- > 0) { int c = *src++; - *charbuf++ = (c & 0x80 ? - c : c); + + coding->charbuf[coding->charbuf_used++] = (c & 0x80 ? - c : c); } produce_chars (coding); } @@ -5883,6 +5905,7 @@ decode_coding_gap (coding, chars, bytes) coding->dst_pos = PT; coding->dst_pos_byte = PT_BYTE; coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters); + coding->mode |= CODING_MODE_LAST_BLOCK; if (CODING_REQUIRE_DETECTION (coding)) detect_coding (coding); -- 2.39.2