aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c63
1 files changed, 46 insertions, 17 deletions
diff --git a/src/coding.c b/src/coding.c
index 1649dae6854..e46a1289ba2 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -279,8 +279,8 @@ Lisp_Object Vcoding_system_for_write;
279Lisp_Object Vlast_coding_system_used; 279Lisp_Object Vlast_coding_system_used;
280 280
281/* A vector of length 256 which contains information about special 281/* A vector of length 256 which contains information about special
282 Microsoft codes. */ 282 Latin codes (espepcially for dealing with Microsoft code). */
283Lisp_Object Vmicrosoft_code_table; 283Lisp_Object Vlatin_extra_code_table;
284 284
285/* Flag to inhibit code conversion of end-of-line format. */ 285/* Flag to inhibit code conversion of end-of-line format. */
286int inhibit_eol_conversion; 286int inhibit_eol_conversion;
@@ -621,8 +621,17 @@ detect_coding_iso2022 (src, src_end)
621 ); 621 );
622 int g1 = 0; /* 1 iff designating to G1. */ 622 int g1 = 0; /* 1 iff designating to G1. */
623 int c, i; 623 int c, i;
624 struct coding_system coding_iso_8_1, coding_iso_8_2;
624 625
625 while (src < src_end) 626 /* Coding systems of these categories may accept latin extra codes. */
627 setup_coding_system
628 (XSYMBOL (coding_category_table[CODING_CATEGORY_IDX_ISO_8_1])->value,
629 &coding_iso_8_1);
630 setup_coding_system
631 (XSYMBOL (coding_category_table[CODING_CATEGORY_IDX_ISO_8_2])->value,
632 &coding_iso_8_2);
633
634 while (mask && src < src_end)
626 { 635 {
627 c = *src++; 636 c = *src++;
628 switch (c) 637 switch (c)
@@ -683,21 +692,39 @@ detect_coding_iso2022 (src, src_end)
683 case ISO_CODE_CSI: 692 case ISO_CODE_CSI:
684 case ISO_CODE_SS2: 693 case ISO_CODE_SS2:
685 case ISO_CODE_SS3: 694 case ISO_CODE_SS3:
686 return CODING_CATEGORY_MASK_ISO_8_ELSE; 695 {
696 int newmask = CODING_CATEGORY_MASK_ISO_8_ELSE;
697
698 if (VECTORP (Vlatin_extra_code_table)
699 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))
700 {
701 if (coding_iso_8_1.flags & CODING_FLAG_ISO_LATIN_EXTRA)
702 newmask |= CODING_CATEGORY_MASK_ISO_8_1;
703 if (coding_iso_8_2.flags & CODING_FLAG_ISO_LATIN_EXTRA)
704 newmask |= CODING_CATEGORY_MASK_ISO_8_2;
705 }
706 mask &= newmask;
707 }
708 break;
687 709
688 default: 710 default:
689 if (c < 0x80) 711 if (c < 0x80)
690 break; 712 break;
691 else if (c < 0xA0) 713 else if (c < 0xA0)
692 { 714 {
693 if (VECTORP (Vmicrosoft_code_table) 715 if (VECTORP (Vlatin_extra_code_table)
694 && !NILP (XVECTOR (Vmicrosoft_code_table)->contents[c])) 716 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))
695 { 717 {
696 mask &= ~(CODING_CATEGORY_MASK_ISO_7 718 int newmask = 0;
697 | CODING_CATEGORY_MASK_ISO_7_ELSE); 719
698 break; 720 if (coding_iso_8_1.flags & CODING_FLAG_ISO_LATIN_EXTRA)
721 newmask |= CODING_CATEGORY_MASK_ISO_8_1;
722 if (coding_iso_8_2.flags & CODING_FLAG_ISO_LATIN_EXTRA)
723 newmask |= CODING_CATEGORY_MASK_ISO_8_2;
724 mask &= newmask;
699 } 725 }
700 return 0; 726 else
727 return 0;
701 } 728 }
702 else 729 else
703 { 730 {
@@ -2370,6 +2397,7 @@ setup_coding_system (coding_system, coding)
2370 | (NILP (flags[13]) ? 0 : CODING_FLAG_ISO_INIT_AT_BOL) 2397 | (NILP (flags[13]) ? 0 : CODING_FLAG_ISO_INIT_AT_BOL)
2371 | (NILP (flags[14]) ? 0 : CODING_FLAG_ISO_DESIGNATE_AT_BOL) 2398 | (NILP (flags[14]) ? 0 : CODING_FLAG_ISO_DESIGNATE_AT_BOL)
2372 | (NILP (flags[15]) ? 0 : CODING_FLAG_ISO_SAFE) 2399 | (NILP (flags[15]) ? 0 : CODING_FLAG_ISO_SAFE)
2400 | (NILP (flags[16]) ? 0 : CODING_FLAG_ISO_LATIN_EXTRA)
2373 ); 2401 );
2374 2402
2375 /* Invoke graphic register 0 to plane 0. */ 2403 /* Invoke graphic register 0 to plane 0. */
@@ -2656,12 +2684,12 @@ detect_coding_mask (src, src_bytes)
2656 } 2684 }
2657 else if (c < 0xA0) 2685 else if (c < 0xA0)
2658 { 2686 {
2659 /* If C is a special Microsoft code, 2687 /* If C is a special latin extra code,
2660 or is an ISO2022 specific control code of C1 (SS2 or SS3), 2688 or is an ISO2022 specific control code of C1 (SS2 or SS3),
2661 or is an ISO2022 control-sequence-introducer (CSI), 2689 or is an ISO2022 control-sequence-introducer (CSI),
2662 we should also consider the possibility of someof ISO2022 codings. */ 2690 we should also consider the possibility of someof ISO2022 codings. */
2663 if ((VECTORP (Vmicrosoft_code_table) 2691 if ((VECTORP (Vlatin_extra_code_table)
2664 && !NILP (XVECTOR (Vmicrosoft_code_table)->contents[c])) 2692 && !NILP (XVECTOR (Vlatin_extra_code_table)->contents[c]))
2665 || (c == ISO_CODE_SS2 || c == ISO_CODE_SS3) 2693 || (c == ISO_CODE_SS2 || c == ISO_CODE_SS3)
2666 || (c == ISO_CODE_CSI 2694 || (c == ISO_CODE_CSI
2667 && (src < src_end 2695 && (src < src_end
@@ -4017,15 +4045,16 @@ The car part is used for decoding a process output,\n\
4017the cdr part is used for encoding a text to be sent to a process."); 4045the cdr part is used for encoding a text to be sent to a process.");
4018 Vdefault_process_coding_system = Qnil; 4046 Vdefault_process_coding_system = Qnil;
4019 4047
4020 DEFVAR_LISP ("special-microsoft-code-table", &Vmicrosoft_code_table, 4048 DEFVAR_LISP ("latin-extra-code-table", &Vlatin_extra_code_table,
4021 "Table of special Microsoft codes in the range 128..159 (inclusive).\n\ 4049 "Table of extra Latin codes in the range 128..159 (inclusive).\n\
4022This is a vector of length 256.\n\ 4050This is a vector of length 256.\n\
4023If Nth element is non-nil, the existence of code N in a file\n\ 4051If Nth element is non-nil, the existence of code N in a file\n\
4024(or output of subprocess) doesn't prevent it to be detected as\n\ 4052(or output of subprocess) doesn't prevent it to be detected as\n\
4025a coding system of ISO 2022 variant (e.g. iso-latin-1) on reading a file\n\ 4053a coding system of ISO 2022 variant which has a flag\n\
4054`accept-latin-extra-code' t (e.g. iso-latin-1) on reading a file\n\
4026or reading output of a subprocess.\n\ 4055or reading output of a subprocess.\n\
4027Only 128th through 159th elements has a meaning."); 4056Only 128th through 159th elements has a meaning.");
4028 Vmicrosoft_code_table = Fmake_vector (make_number (256), Qnil); 4057 Vlatin_extra_code_table = Fmake_vector (make_number (256), Qnil);
4029} 4058}
4030 4059
4031#endif /* emacs */ 4060#endif /* emacs */