Mercurial > emacs
comparison src/coding.c @ 103762:e72df94a89ca
(detect_coding_sjis): Handle shift_jis-2004 correctly.
(encode_coding_sjis): Fix the code range check.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Wed, 08 Jul 2009 02:22:05 +0000 |
| parents | e2d67c929da2 |
| children | bc74846b9a54 |
comparison
equal
deleted
inserted
replaced
| 103761:1e43f752ee1c | 103762:e72df94a89ca |
|---|---|
| 4669 const unsigned char *src_end = coding->source + coding->src_bytes; | 4669 const unsigned char *src_end = coding->source + coding->src_bytes; |
| 4670 int multibytep = coding->src_multibyte; | 4670 int multibytep = coding->src_multibyte; |
| 4671 int consumed_chars = 0; | 4671 int consumed_chars = 0; |
| 4672 int found = 0; | 4672 int found = 0; |
| 4673 int c; | 4673 int c; |
| 4674 Lisp_Object attrs, charset_list; | |
| 4675 int max_first_byte_of_2_byte_code; | |
| 4676 | |
| 4677 CODING_GET_INFO (coding, attrs, charset_list); | |
| 4678 max_first_byte_of_2_byte_code | |
| 4679 = (XINT (Flength (charset_list)) > 3 ? 0xFC : 0xEF); | |
| 4674 | 4680 |
| 4675 detect_info->checked |= CATEGORY_MASK_SJIS; | 4681 detect_info->checked |= CATEGORY_MASK_SJIS; |
| 4676 /* A coding system of this category is always ASCII compatible. */ | 4682 /* A coding system of this category is always ASCII compatible. */ |
| 4677 src += coding->head_ascii; | 4683 src += coding->head_ascii; |
| 4678 | 4684 |
| 4680 { | 4686 { |
| 4681 src_base = src; | 4687 src_base = src; |
| 4682 ONE_MORE_BYTE (c); | 4688 ONE_MORE_BYTE (c); |
| 4683 if (c < 0x80) | 4689 if (c < 0x80) |
| 4684 continue; | 4690 continue; |
| 4685 if ((c >= 0x81 && c <= 0x9F) || (c >= 0xE0 && c <= 0xEF)) | 4691 if ((c >= 0x81 && c <= 0x9F) |
| 4692 || (c >= 0xE0 && c <= max_first_byte_of_2_byte_code)) | |
| 4686 { | 4693 { |
| 4687 ONE_MORE_BYTE (c); | 4694 ONE_MORE_BYTE (c); |
| 4688 if (c < 0x40 || c == 0x7F || c > 0xFC) | 4695 if (c < 0x40 || c == 0x7F || c > 0xFC) |
| 4689 break; | 4696 break; |
| 4690 found = CATEGORY_MASK_SJIS; | 4697 found = CATEGORY_MASK_SJIS; |
| 5053 else if (charset_kanji2 && charset == charset_kanji2) | 5060 else if (charset_kanji2 && charset == charset_kanji2) |
| 5054 { | 5061 { |
| 5055 int c1, c2; | 5062 int c1, c2; |
| 5056 | 5063 |
| 5057 c1 = code >> 8; | 5064 c1 = code >> 8; |
| 5058 if (c1 == 0x21 || (c1 >= 0x23 && c1 < 0x25) | 5065 if (c1 == 0x21 || (c1 >= 0x23 && c1 <= 0x25) |
| 5066 || c1 == 0x28 | |
| 5059 || (c1 >= 0x2C && c1 <= 0x2F) || c1 >= 0x6E) | 5067 || (c1 >= 0x2C && c1 <= 0x2F) || c1 >= 0x6E) |
| 5060 { | 5068 { |
| 5061 JIS_TO_SJIS2 (code); | 5069 JIS_TO_SJIS2 (code); |
| 5062 c1 = code >> 8, c2 = code & 0xFF; | 5070 c1 = code >> 8, c2 = code & 0xFF; |
| 5063 EMIT_TWO_BYTES (c1, c2); | 5071 EMIT_TWO_BYTES (c1, c2); |
