aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c61
1 files changed, 41 insertions, 20 deletions
diff --git a/src/coding.c b/src/coding.c
index 5bfcacc1e17..ee5fdf25fc2 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -623,38 +623,59 @@ detect_coding_iso2022 (src, src_end)
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)
@@ -3001,10 +3022,10 @@ The value of property should be a vector of length 5.")
3001 3022
3002DEFUN ("detect-coding-region", Fdetect_coding_region, Sdetect_coding_region, 3023DEFUN ("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\
3005Return a list of possible coding-systems ordered by priority.\n\ 3026Return a list of possible coding systems ordered by priority.\n\
3006If only ASCII characters are found, it returns `undecided'\n\ 3027If 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{