Commit 98725083 authored by Kenichi Handa's avatar Kenichi Handa
Browse files

(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.
parent a2309271
...@@ -1126,7 +1126,10 @@ decode_coding_utf_8 (coding) ...@@ -1126,7 +1126,10 @@ decode_coding_utf_8 (coding)
if (EQ (eol_type, Qdos)) if (EQ (eol_type, Qdos))
{ {
if (src == src_end) if (src == src_end)
goto no_more_source; {
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n') if (*src == '\n')
ONE_MORE_BYTE (c); ONE_MORE_BYTE (c);
} }
...@@ -1917,7 +1920,10 @@ decode_coding_emacs_mule (coding) ...@@ -1917,7 +1920,10 @@ decode_coding_emacs_mule (coding)
if (EQ (eol_type, Qdos)) if (EQ (eol_type, Qdos))
{ {
if (src == src_end) if (src == src_end)
goto no_more_source; {
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n') if (*src == '\n')
ONE_MORE_BYTE (c); ONE_MORE_BYTE (c);
} }
...@@ -2784,7 +2790,7 @@ decode_coding_iso_2022 (coding) ...@@ -2784,7 +2790,7 @@ decode_coding_iso_2022 (coding)
ONE_MORE_BYTE (c1); ONE_MORE_BYTE (c1);
/* We produce no character or one character. */ /* We produce at most one character. */
switch (iso_code_class [c1]) switch (iso_code_class [c1])
{ {
case ISO_0x20_or_0x7F: case ISO_0x20_or_0x7F:
...@@ -2841,7 +2847,10 @@ decode_coding_iso_2022 (coding) ...@@ -2841,7 +2847,10 @@ decode_coding_iso_2022 (coding)
if (EQ (eol_type, Qdos)) if (EQ (eol_type, Qdos))
{ {
if (src == src_end) if (src == src_end)
goto no_more_source; {
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n') if (*src == '\n')
ONE_MORE_BYTE (c1); ONE_MORE_BYTE (c1);
} }
...@@ -3796,7 +3805,10 @@ decode_coding_sjis (coding) ...@@ -3796,7 +3805,10 @@ decode_coding_sjis (coding)
if (EQ (eol_type, Qdos)) if (EQ (eol_type, Qdos))
{ {
if (src == src_end) if (src == src_end)
goto no_more_source; {
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n') if (*src == '\n')
ONE_MORE_BYTE (c); ONE_MORE_BYTE (c);
} }
...@@ -3885,7 +3897,10 @@ decode_coding_big5 (coding) ...@@ -3885,7 +3897,10 @@ decode_coding_big5 (coding)
if (EQ (eol_type, Qdos)) if (EQ (eol_type, Qdos))
{ {
if (src == src_end) if (src == src_end)
goto no_more_source; {
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n') if (*src == '\n')
ONE_MORE_BYTE (c); ONE_MORE_BYTE (c);
} }
...@@ -4429,8 +4444,12 @@ decode_coding_charset (coding) ...@@ -4429,8 +4444,12 @@ decode_coding_charset (coding)
else. */ else. */
if (EQ (eol_type, Qdos)) if (EQ (eol_type, Qdos))
{ {
if (src < src_end if (src == src_end)
&& *src == '\n') {
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n')
ONE_MORE_BYTE (c); ONE_MORE_BYTE (c);
} }
else if (EQ (eol_type, Qmac)) else if (EQ (eol_type, Qmac))
...@@ -5272,8 +5291,12 @@ produce_chars (coding) ...@@ -5272,8 +5291,12 @@ produce_chars (coding)
{ {
if (EQ (eol_type, Qdos)) if (EQ (eol_type, Qdos))
{ {
if (src < src_end if (src == src_end)
&& *src == '\n') {
coding->result = CODING_RESULT_INSUFFICIENT_SRC;
goto no_more_source;
}
if (*src == '\n')
c = *src++; c = *src++;
} }
else if (EQ (eol_type, Qmac)) else if (EQ (eol_type, Qmac))
...@@ -5621,12 +5644,11 @@ decode_coding (coding) ...@@ -5621,12 +5644,11 @@ decode_coding (coding)
/* Flush out unprocessed data as binary chars. We are sure /* Flush out unprocessed data as binary chars. We are sure
that the number of data is less than the size of that the number of data is less than the size of
coding->charbuf. */ coding->charbuf. */
int *charbuf = coding->charbuf;
while (nbytes-- > 0) while (nbytes-- > 0)
{ {
int c = *src++; int c = *src++;
*charbuf++ = (c & 0x80 ? - c : c);
coding->charbuf[coding->charbuf_used++] = (c & 0x80 ? - c : c);
} }
produce_chars (coding); produce_chars (coding);
} }
...@@ -5883,6 +5905,7 @@ decode_coding_gap (coding, chars, bytes) ...@@ -5883,6 +5905,7 @@ decode_coding_gap (coding, chars, bytes)
coding->dst_pos = PT; coding->dst_pos = PT;
coding->dst_pos_byte = PT_BYTE; coding->dst_pos_byte = PT_BYTE;
coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters); coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters);
coding->mode |= CODING_MODE_LAST_BLOCK;
if (CODING_REQUIRE_DETECTION (coding)) if (CODING_REQUIRE_DETECTION (coding))
detect_coding (coding); detect_coding (coding);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment