comparison src/coding.c @ 89279:1fd77c471ee6

(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.
author Kenichi Handa <handa@m17n.org>
date Wed, 06 Nov 2002 00:10:42 +0000
parents 101ee928c088
children 1892a75ffcac
comparison
equal deleted inserted replaced
89278:de07830a2cc4 89279:1fd77c471ee6
1124 if (c == '\r') 1124 if (c == '\r')
1125 { 1125 {
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 }
1133 else if (EQ (eol_type, Qmac)) 1136 else if (EQ (eol_type, Qmac))
1134 c = '\n'; 1137 c = '\n';
1915 if (c == '\r') 1918 if (c == '\r')
1916 { 1919 {
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 }
1924 else if (EQ (eol_type, Qmac)) 1930 else if (EQ (eol_type, Qmac))
1925 c = '\n'; 1931 c = '\n';
2782 if (charbuf >= charbuf_end) 2788 if (charbuf >= charbuf_end)
2783 break; 2789 break;
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:
2791 if (composition_state != COMPOSING_NO) 2797 if (composition_state != COMPOSING_NO)
2792 { 2798 {
2839 if (c1 == '\r') 2845 if (c1 == '\r')
2840 { 2846 {
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 }
2848 else if (EQ (eol_type, Qmac)) 2857 else if (EQ (eol_type, Qmac))
2849 c1 = '\n'; 2858 c1 = '\n';
3794 if (c == '\r') 3803 if (c == '\r')
3795 { 3804 {
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 }
3803 else if (EQ (eol_type, Qmac)) 3815 else if (EQ (eol_type, Qmac))
3804 c = '\n'; 3816 c = '\n';
3883 if (c == '\r') 3895 if (c == '\r')
3884 { 3896 {
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 }
3892 else if (EQ (eol_type, Qmac)) 3907 else if (EQ (eol_type, Qmac))
3893 c = '\n'; 3908 c = '\n';
4427 { 4442 {
4428 /* Here we assume that no charset maps '\r' to something 4443 /* Here we assume that no charset maps '\r' to something
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))
4437 c = '\n'; 4456 c = '\n';
4438 } 4457 }
5270 ONE_MORE_BYTE (c); 5289 ONE_MORE_BYTE (c);
5271 if (c == '\r') 5290 if (c == '\r')
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))
5280 c = '\n'; 5303 c = '\n';
5281 } 5304 }
5619 if (coding->mode & CODING_MODE_LAST_BLOCK) 5642 if (coding->mode & CODING_MODE_LAST_BLOCK)
5620 { 5643 {
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 }
5633 else 5655 else
5634 { 5656 {
5881 coding->src_multibyte = chars < bytes; 5903 coding->src_multibyte = chars < bytes;
5882 coding->dst_object = coding->src_object; 5904 coding->dst_object = coding->src_object;
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);
5889 5912
5890 decode_coding (coding); 5913 decode_coding (coding);