aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c92
1 files changed, 43 insertions, 49 deletions
diff --git a/src/coding.c b/src/coding.c
index 29477c75e5b..e2c86bb3a26 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -367,18 +367,18 @@ char *coding_category_name[CODING_CATEGORY_IDX_MAX] = {
367 categories. */ 367 categories. */
368struct coding_system *coding_system_table[CODING_CATEGORY_IDX_MAX]; 368struct coding_system *coding_system_table[CODING_CATEGORY_IDX_MAX];
369 369
370/* Flag to tell if we look up character translation table on character 370/* Flag to tell if we look up translation table on character code
371 code conversion. */ 371 conversion. */
372Lisp_Object Venable_character_translation; 372Lisp_Object Venable_character_translation;
373/* Standard character translation table to look up on decoding (reading). */ 373/* Standard translation table to look up on decoding (reading). */
374Lisp_Object Vstandard_character_translation_table_for_decode; 374Lisp_Object Vstandard_translation_table_for_decode;
375/* Standard character translation table to look up on encoding (writing). */ 375/* Standard translation table to look up on encoding (writing). */
376Lisp_Object Vstandard_character_translation_table_for_encode; 376Lisp_Object Vstandard_translation_table_for_encode;
377 377
378Lisp_Object Qcharacter_translation_table; 378Lisp_Object Qtranslation_table;
379Lisp_Object Qcharacter_translation_table_id; 379Lisp_Object Qtranslation_table_id;
380Lisp_Object Qcharacter_translation_table_for_decode; 380Lisp_Object Qtranslation_table_for_decode;
381Lisp_Object Qcharacter_translation_table_for_encode; 381Lisp_Object Qtranslation_table_for_encode;
382 382
383/* Alist of charsets vs revision number. */ 383/* Alist of charsets vs revision number. */
384Lisp_Object Vcharset_revision_alist; 384Lisp_Object Vcharset_revision_alist;
@@ -1010,11 +1010,11 @@ decode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes)
1010 int charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0); 1010 int charset0 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 0);
1011 int charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1); 1011 int charset1 = CODING_SPEC_ISO_PLANE_CHARSET (coding, 1);
1012 Lisp_Object translation_table 1012 Lisp_Object translation_table
1013 = coding->character_translation_table_for_decode; 1013 = coding->translation_table_for_decode;
1014 int result = CODING_FINISH_NORMAL; 1014 int result = CODING_FINISH_NORMAL;
1015 1015
1016 if (!NILP (Venable_character_translation) && NILP (translation_table)) 1016 if (!NILP (Venable_character_translation) && NILP (translation_table))
1017 translation_table = Vstandard_character_translation_table_for_decode; 1017 translation_table = Vstandard_translation_table_for_decode;
1018 1018
1019 coding->produced_char = 0; 1019 coding->produced_char = 0;
1020 coding->fake_multibyte = 0; 1020 coding->fake_multibyte = 0;
@@ -1758,11 +1758,11 @@ encode_coding_iso2022 (coding, source, destination, src_bytes, dst_bytes)
1758 head of loop. */ 1758 head of loop. */
1759 unsigned char *adjusted_dst_end = dst_end - 19; 1759 unsigned char *adjusted_dst_end = dst_end - 19;
1760 Lisp_Object translation_table 1760 Lisp_Object translation_table
1761 = coding->character_translation_table_for_encode; 1761 = coding->translation_table_for_encode;
1762 int result = CODING_FINISH_NORMAL; 1762 int result = CODING_FINISH_NORMAL;
1763 1763
1764 if (!NILP (Venable_character_translation) && NILP (translation_table)) 1764 if (!NILP (Venable_character_translation) && NILP (translation_table))
1765 translation_table = Vstandard_character_translation_table_for_encode; 1765 translation_table = Vstandard_translation_table_for_encode;
1766 1766
1767 coding->consumed_char = 0; 1767 coding->consumed_char = 0;
1768 coding->fake_multibyte = 0; 1768 coding->fake_multibyte = 0;
@@ -2175,11 +2175,11 @@ decode_coding_sjis_big5 (coding, source, destination,
2175 head of loop. */ 2175 head of loop. */
2176 unsigned char *adjusted_dst_end = dst_end - 3; 2176 unsigned char *adjusted_dst_end = dst_end - 3;
2177 Lisp_Object translation_table 2177 Lisp_Object translation_table
2178 = coding->character_translation_table_for_decode; 2178 = coding->translation_table_for_decode;
2179 int result = CODING_FINISH_NORMAL; 2179 int result = CODING_FINISH_NORMAL;
2180 2180
2181 if (!NILP (Venable_character_translation) && NILP (translation_table)) 2181 if (!NILP (Venable_character_translation) && NILP (translation_table))
2182 translation_table = Vstandard_character_translation_table_for_decode; 2182 translation_table = Vstandard_translation_table_for_decode;
2183 2183
2184 coding->produced_char = 0; 2184 coding->produced_char = 0;
2185 coding->fake_multibyte = 0; 2185 coding->fake_multibyte = 0;
@@ -2364,11 +2364,11 @@ encode_coding_sjis_big5 (coding, source, destination,
2364 head of loop. */ 2364 head of loop. */
2365 unsigned char *adjusted_dst_end = dst_end - 1; 2365 unsigned char *adjusted_dst_end = dst_end - 1;
2366 Lisp_Object translation_table 2366 Lisp_Object translation_table
2367 = coding->character_translation_table_for_encode; 2367 = coding->translation_table_for_encode;
2368 int result = CODING_FINISH_NORMAL; 2368 int result = CODING_FINISH_NORMAL;
2369 2369
2370 if (!NILP (Venable_character_translation) && NILP (translation_table)) 2370 if (!NILP (Venable_character_translation) && NILP (translation_table))
2371 translation_table = Vstandard_character_translation_table_for_encode; 2371 translation_table = Vstandard_translation_table_for_encode;
2372 2372
2373 coding->consumed_char = 0; 2373 coding->consumed_char = 0;
2374 coding->fake_multibyte = 0; 2374 coding->fake_multibyte = 0;
@@ -2816,26 +2816,23 @@ setup_coding_system (coding_system, coding)
2816 2816
2817 /* Initialize remaining fields. */ 2817 /* Initialize remaining fields. */
2818 coding->composing = 0; 2818 coding->composing = 0;
2819 coding->character_translation_table_for_decode = Qnil; 2819 coding->translation_table_for_decode = Qnil;
2820 coding->character_translation_table_for_encode = Qnil; 2820 coding->translation_table_for_encode = Qnil;
2821 2821
2822 /* Get values of coding system properties: 2822 /* Get values of coding system properties:
2823 `post-read-conversion', `pre-write-conversion', 2823 `post-read-conversion', `pre-write-conversion',
2824 `character-translation-table-for-decode', 2824 `translation-table-for-decode', `translation-table-for-encode'. */
2825 `character-translation-table-for-encode'. */
2826 plist = XVECTOR (coding_spec)->contents[3]; 2825 plist = XVECTOR (coding_spec)->contents[3];
2827 coding->post_read_conversion = Fplist_get (plist, Qpost_read_conversion); 2826 coding->post_read_conversion = Fplist_get (plist, Qpost_read_conversion);
2828 coding->pre_write_conversion = Fplist_get (plist, Qpre_write_conversion); 2827 coding->pre_write_conversion = Fplist_get (plist, Qpre_write_conversion);
2829 val = Fplist_get (plist, Qcharacter_translation_table_for_decode); 2828 val = Fplist_get (plist, Qtranslation_table_for_decode);
2830 if (SYMBOLP (val)) 2829 if (SYMBOLP (val))
2831 val = Fget (val, Qcharacter_translation_table_for_decode); 2830 val = Fget (val, Qtranslation_table_for_decode);
2832 coding->character_translation_table_for_decode 2831 coding->translation_table_for_decode = CHAR_TABLE_P (val) ? val : Qnil;
2833 = CHAR_TABLE_P (val) ? val : Qnil; 2832 val = Fplist_get (plist, Qtranslation_table_for_encode);
2834 val = Fplist_get (plist, Qcharacter_translation_table_for_encode);
2835 if (SYMBOLP (val)) 2833 if (SYMBOLP (val))
2836 val = Fget (val, Qcharacter_translation_table_for_encode); 2834 val = Fget (val, Qtranslation_table_for_encode);
2837 coding->character_translation_table_for_encode 2835 coding->translation_table_for_encode = CHAR_TABLE_P (val) ? val : Qnil;
2838 = CHAR_TABLE_P (val) ? val : Qnil;
2839 val = Fplist_get (plist, Qcoding_category); 2836 val = Fplist_get (plist, Qcoding_category);
2840 if (!NILP (val)) 2837 if (!NILP (val))
2841 { 2838 {
@@ -5140,21 +5137,18 @@ syms_of_coding ()
5140 } 5137 }
5141 } 5138 }
5142 5139
5143 Qcharacter_translation_table = intern ("character-translation-table"); 5140 Qtranslation_table = intern ("translation-table");
5144 staticpro (&Qcharacter_translation_table); 5141 staticpro (&Qtranslation_table);
5145 Fput (Qcharacter_translation_table, Qchar_table_extra_slots, 5142 Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (0));
5146 make_number (0));
5147 5143
5148 Qcharacter_translation_table_id = intern ("character-translation-table-id"); 5144 Qtranslation_table_id = intern ("translation-table-id");
5149 staticpro (&Qcharacter_translation_table_id); 5145 staticpro (&Qtranslation_table_id);
5150 5146
5151 Qcharacter_translation_table_for_decode 5147 Qtranslation_table_for_decode = intern ("translation-table-for-decode");
5152 = intern ("character-translation-table-for-decode"); 5148 staticpro (&Qtranslation_table_for_decode);
5153 staticpro (&Qcharacter_translation_table_for_decode);
5154 5149
5155 Qcharacter_translation_table_for_encode 5150 Qtranslation_table_for_encode = intern ("translation-table-for-encode");
5156 = intern ("character-translation-table-for-encode"); 5151 staticpro (&Qtranslation_table_for_encode);
5157 staticpro (&Qcharacter_translation_table_for_encode);
5158 5152
5159 Qsafe_charsets = intern ("safe-charsets"); 5153 Qsafe_charsets = intern ("safe-charsets");
5160 staticpro (&Qsafe_charsets); 5154 staticpro (&Qsafe_charsets);
@@ -5312,18 +5306,18 @@ See also the function `find-operation-coding-system'.");
5312 eol_mnemonic_undecided = ':'; 5306 eol_mnemonic_undecided = ':';
5313 5307
5314 DEFVAR_LISP ("enable-character-translation", &Venable_character_translation, 5308 DEFVAR_LISP ("enable-character-translation", &Venable_character_translation,
5315 "Non-nil means ISO 2022 encoder/decoder do character translation."); 5309 "*Non-nil enables character translation while encoding and decoding.");
5316 Venable_character_translation = Qt; 5310 Venable_character_translation = Qt;
5317 5311
5318 DEFVAR_LISP ("standard-character-translation-table-for-decode", 5312 DEFVAR_LISP ("standard-translation-table-for-decode",
5319 &Vstandard_character_translation_table_for_decode, 5313 &Vstandard_translation_table_for_decode,
5320 "Table for translating characters while decoding."); 5314 "Table for translating characters while decoding.");
5321 Vstandard_character_translation_table_for_decode = Qnil; 5315 Vstandard_translation_table_for_decode = Qnil;
5322 5316
5323 DEFVAR_LISP ("standard-character-translation-table-for-encode", 5317 DEFVAR_LISP ("standard-translation-table-for-encode",
5324 &Vstandard_character_translation_table_for_encode, 5318 &Vstandard_translation_table_for_encode,
5325 "Table for translationg characters while encoding."); 5319 "Table for translationg characters while encoding.");
5326 Vstandard_character_translation_table_for_encode = Qnil; 5320 Vstandard_translation_table_for_encode = Qnil;
5327 5321
5328 DEFVAR_LISP ("charset-revision-table", &Vcharset_revision_alist, 5322 DEFVAR_LISP ("charset-revision-table", &Vcharset_revision_alist,
5329 "Alist of charsets vs revision numbers.\n\ 5323 "Alist of charsets vs revision numbers.\n\