comparison src/coding.c @ 19134:8fa6e23f8d22

(detect_coding_iso2022): Do not exclude posibility of 7-bit encoding when designation to G1 occurs. If CSI, SS2, or SS3 is found, return CODING_CATEGORY_MASK_ISO_8_ELSE. (Fdetect_coding_region): Doc-string modified.
author Kenichi Handa <handa@m17n.org>
date Mon, 04 Aug 1997 06:59:57 +0000
parents 16ef8c28e4e0
children 04ed7c3f5cee
comparison
equal deleted inserted replaced
19133:a5f15ed1907d 19134:8fa6e23f8d22
621 { 621 {
622 case ISO_CODE_ESC: 622 case ISO_CODE_ESC:
623 if (src >= src_end) 623 if (src >= src_end)
624 break; 624 break;
625 c = *src++; 625 c = *src++;
626 if (src < src_end 626 if ((c >= '(' && c <= '/'))
627 && ((c >= '(' && c <= '/')
628 || c == '$' && ((*src >= '(' && *src <= '/')
629 || (*src >= '@' && *src <= 'B'))))
630 { 627 {
631 /* Valid designation sequence. */ 628 /* Designation sequence for a charset of dimension 1. */
632 if (c == ')' || (c == '$' && *src == ')')) 629 if (src >= src_end)
630 break;
631 c = *src++;
632 if (c < ' ' || c >= 0x80)
633 /* Invalid designation sequence. */
634 return 0;
635 }
636 else if (c == '$')
637 {
638 /* Designation sequence for a charset of dimension 2. */
639 if (src >= src_end)
640 break;
641 c = *src++;
642 if (c >= '@' && c <= 'B')
643 /* Designation for JISX0208.1978, GB2312, or JISX0208. */
644 ;
645 else if (c >= '(' && c <= '/')
633 { 646 {
634 g1 = 1; 647 if (src >= src_end)
635 mask &= ~(CODING_CATEGORY_MASK_ISO_7 648 break;
636 | CODING_CATEGORY_MASK_ISO_7_ELSE); 649 c = *src++;
650 if (c < ' ' || c >= 0x80)
651 /* Invalid designation sequence. */
652 return 0;
637 } 653 }
638 src++; 654 else
639 break; 655 /* Invalid designation sequence. */
656 return 0;
640 } 657 }
641 else if (c == 'N' || c == 'O' || c == 'n' || c == 'o') 658 else if (c == 'N' || c == 'O' || c == 'n' || c == 'o')
659 /* Locking shift. */
642 mask &= (CODING_CATEGORY_MASK_ISO_7_ELSE 660 mask &= (CODING_CATEGORY_MASK_ISO_7_ELSE
643 | CODING_CATEGORY_MASK_ISO_8_ELSE); 661 | CODING_CATEGORY_MASK_ISO_8_ELSE);
662 else if (c == '0' || c == '1' || c == '2')
663 /* Start/end composition. */
664 ;
665 else
666 /* Invalid escape sequence. */
667 return 0;
644 break; 668 break;
645 669
646 case ISO_CODE_SO: 670 case ISO_CODE_SO:
647 if (g1) 671 mask &= (CODING_CATEGORY_MASK_ISO_7_ELSE
648 mask &= (CODING_CATEGORY_MASK_ISO_7_ELSE 672 | CODING_CATEGORY_MASK_ISO_8_ELSE);
649 | CODING_CATEGORY_MASK_ISO_8_ELSE);
650 break; 673 break;
651 674
652 case ISO_CODE_CSI: 675 case ISO_CODE_CSI:
653 case ISO_CODE_SS2: 676 case ISO_CODE_SS2:
654 case ISO_CODE_SS3: 677 case ISO_CODE_SS3:
655 mask &= ~(CODING_CATEGORY_MASK_ISO_7 678 return CODING_CATEGORY_MASK_ISO_8_ELSE;
656 | CODING_CATEGORY_MASK_ISO_7_ELSE);
657 break;
658 679
659 default: 680 default:
660 if (c < 0x80) 681 if (c < 0x80)
661 break; 682 break;
662 else if (c < 0xA0) 683 else if (c < 0xA0)
2999 Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil)); 3020 Fsignal (Qcoding_system_error, Fcons (coding_system, Qnil));
3000 } 3021 }
3001 3022
3002 DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region, 3023 DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region,
3003 2, 2, 0, 3024 2, 2, 0,
3004 "Detect coding-system of the text in the region between START and END.\n\ 3025 "Detect coding system of the text in the region between START and END.\n\
3005 Return a list of possible coding-systems ordered by priority.\n\ 3026 Return a list of possible coding systems ordered by priority.\n\
3006 If only ASCII characters are found, it returns `undecided'\n\ 3027 If only ASCII characters are found, it returns `undecided'\n\
3007 or its subsidiary coding-system according to a detected end-of-line format.") 3028 or its subsidiary coding system according to a detected end-of-line format.")
3008 (b, e) 3029 (b, e)
3009 Lisp_Object b, e; 3030 Lisp_Object b, e;
3010 { 3031 {
3011 int coding_mask, eol_type; 3032 int coding_mask, eol_type;
3012 Lisp_Object val; 3033 Lisp_Object val;