diff options
| author | Kenichi Handa | 2002-11-06 00:10:42 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-11-06 00:10:42 +0000 |
| commit | 98725083321eff9380c9b4a1516a14a444c05d81 (patch) | |
| tree | a142e669e41f1e0963153d639be9200b4830ab30 /src/coding.c | |
| parent | a2309271049df204d449bd5498faba50835abebd (diff) | |
| download | emacs-98725083321eff9380c9b4a1516a14a444c05d81.tar.gz emacs-98725083321eff9380c9b4a1516a14a444c05d81.zip | |
(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.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 49 |
1 files 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) | |||
| 1126 | if (EQ (eol_type, Qdos)) | 1126 | if (EQ (eol_type, Qdos)) |
| 1127 | { | 1127 | { |
| 1128 | if (src == src_end) | 1128 | if (src == src_end) |
| 1129 | goto no_more_source; | 1129 | { |
| 1130 | coding->result = CODING_RESULT_INSUFFICIENT_SRC; | ||
| 1131 | goto no_more_source; | ||
| 1132 | } | ||
| 1130 | if (*src == '\n') | 1133 | if (*src == '\n') |
| 1131 | ONE_MORE_BYTE (c); | 1134 | ONE_MORE_BYTE (c); |
| 1132 | } | 1135 | } |
| @@ -1917,7 +1920,10 @@ decode_coding_emacs_mule (coding) | |||
| 1917 | if (EQ (eol_type, Qdos)) | 1920 | if (EQ (eol_type, Qdos)) |
| 1918 | { | 1921 | { |
| 1919 | if (src == src_end) | 1922 | if (src == src_end) |
| 1920 | goto no_more_source; | 1923 | { |
| 1924 | coding->result = CODING_RESULT_INSUFFICIENT_SRC; | ||
| 1925 | goto no_more_source; | ||
| 1926 | } | ||
| 1921 | if (*src == '\n') | 1927 | if (*src == '\n') |
| 1922 | ONE_MORE_BYTE (c); | 1928 | ONE_MORE_BYTE (c); |
| 1923 | } | 1929 | } |
| @@ -2784,7 +2790,7 @@ decode_coding_iso_2022 (coding) | |||
| 2784 | 2790 | ||
| 2785 | ONE_MORE_BYTE (c1); | 2791 | ONE_MORE_BYTE (c1); |
| 2786 | 2792 | ||
| 2787 | /* We produce no character or one character. */ | 2793 | /* We produce at most one character. */ |
| 2788 | switch (iso_code_class [c1]) | 2794 | switch (iso_code_class [c1]) |
| 2789 | { | 2795 | { |
| 2790 | case ISO_0x20_or_0x7F: | 2796 | case ISO_0x20_or_0x7F: |
| @@ -2841,7 +2847,10 @@ decode_coding_iso_2022 (coding) | |||
| 2841 | if (EQ (eol_type, Qdos)) | 2847 | if (EQ (eol_type, Qdos)) |
| 2842 | { | 2848 | { |
| 2843 | if (src == src_end) | 2849 | if (src == src_end) |
| 2844 | goto no_more_source; | 2850 | { |
| 2851 | coding->result = CODING_RESULT_INSUFFICIENT_SRC; | ||
| 2852 | goto no_more_source; | ||
| 2853 | } | ||
| 2845 | if (*src == '\n') | 2854 | if (*src == '\n') |
| 2846 | ONE_MORE_BYTE (c1); | 2855 | ONE_MORE_BYTE (c1); |
| 2847 | } | 2856 | } |
| @@ -3796,7 +3805,10 @@ decode_coding_sjis (coding) | |||
| 3796 | if (EQ (eol_type, Qdos)) | 3805 | if (EQ (eol_type, Qdos)) |
| 3797 | { | 3806 | { |
| 3798 | if (src == src_end) | 3807 | if (src == src_end) |
| 3799 | goto no_more_source; | 3808 | { |
| 3809 | coding->result = CODING_RESULT_INSUFFICIENT_SRC; | ||
| 3810 | goto no_more_source; | ||
| 3811 | } | ||
| 3800 | if (*src == '\n') | 3812 | if (*src == '\n') |
| 3801 | ONE_MORE_BYTE (c); | 3813 | ONE_MORE_BYTE (c); |
| 3802 | } | 3814 | } |
| @@ -3885,7 +3897,10 @@ decode_coding_big5 (coding) | |||
| 3885 | if (EQ (eol_type, Qdos)) | 3897 | if (EQ (eol_type, Qdos)) |
| 3886 | { | 3898 | { |
| 3887 | if (src == src_end) | 3899 | if (src == src_end) |
| 3888 | goto no_more_source; | 3900 | { |
| 3901 | coding->result = CODING_RESULT_INSUFFICIENT_SRC; | ||
| 3902 | goto no_more_source; | ||
| 3903 | } | ||
| 3889 | if (*src == '\n') | 3904 | if (*src == '\n') |
| 3890 | ONE_MORE_BYTE (c); | 3905 | ONE_MORE_BYTE (c); |
| 3891 | } | 3906 | } |
| @@ -4429,8 +4444,12 @@ decode_coding_charset (coding) | |||
| 4429 | else. */ | 4444 | else. */ |
| 4430 | if (EQ (eol_type, Qdos)) | 4445 | if (EQ (eol_type, Qdos)) |
| 4431 | { | 4446 | { |
| 4432 | if (src < src_end | 4447 | if (src == src_end) |
| 4433 | && *src == '\n') | 4448 | { |
| 4449 | coding->result = CODING_RESULT_INSUFFICIENT_SRC; | ||
| 4450 | goto no_more_source; | ||
| 4451 | } | ||
| 4452 | if (*src == '\n') | ||
| 4434 | ONE_MORE_BYTE (c); | 4453 | ONE_MORE_BYTE (c); |
| 4435 | } | 4454 | } |
| 4436 | else if (EQ (eol_type, Qmac)) | 4455 | else if (EQ (eol_type, Qmac)) |
| @@ -5272,8 +5291,12 @@ produce_chars (coding) | |||
| 5272 | { | 5291 | { |
| 5273 | if (EQ (eol_type, Qdos)) | 5292 | if (EQ (eol_type, Qdos)) |
| 5274 | { | 5293 | { |
| 5275 | if (src < src_end | 5294 | if (src == src_end) |
| 5276 | && *src == '\n') | 5295 | { |
| 5296 | coding->result = CODING_RESULT_INSUFFICIENT_SRC; | ||
| 5297 | goto no_more_source; | ||
| 5298 | } | ||
| 5299 | if (*src == '\n') | ||
| 5277 | c = *src++; | 5300 | c = *src++; |
| 5278 | } | 5301 | } |
| 5279 | else if (EQ (eol_type, Qmac)) | 5302 | else if (EQ (eol_type, Qmac)) |
| @@ -5621,12 +5644,11 @@ decode_coding (coding) | |||
| 5621 | /* Flush out unprocessed data as binary chars. We are sure | 5644 | /* Flush out unprocessed data as binary chars. We are sure |
| 5622 | that the number of data is less than the size of | 5645 | that the number of data is less than the size of |
| 5623 | coding->charbuf. */ | 5646 | coding->charbuf. */ |
| 5624 | int *charbuf = coding->charbuf; | ||
| 5625 | |||
| 5626 | while (nbytes-- > 0) | 5647 | while (nbytes-- > 0) |
| 5627 | { | 5648 | { |
| 5628 | int c = *src++; | 5649 | int c = *src++; |
| 5629 | *charbuf++ = (c & 0x80 ? - c : c); | 5650 | |
| 5651 | coding->charbuf[coding->charbuf_used++] = (c & 0x80 ? - c : c); | ||
| 5630 | } | 5652 | } |
| 5631 | produce_chars (coding); | 5653 | produce_chars (coding); |
| 5632 | } | 5654 | } |
| @@ -5883,6 +5905,7 @@ decode_coding_gap (coding, chars, bytes) | |||
| 5883 | coding->dst_pos = PT; | 5905 | coding->dst_pos = PT; |
| 5884 | coding->dst_pos_byte = PT_BYTE; | 5906 | coding->dst_pos_byte = PT_BYTE; |
| 5885 | coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters); | 5907 | coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
| 5908 | coding->mode |= CODING_MODE_LAST_BLOCK; | ||
| 5886 | 5909 | ||
| 5887 | if (CODING_REQUIRE_DETECTION (coding)) | 5910 | if (CODING_REQUIRE_DETECTION (coding)) |
| 5888 | detect_coding (coding); | 5911 | detect_coding (coding); |