aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c44
1 files changed, 12 insertions, 32 deletions
diff --git a/src/coding.c b/src/coding.c
index 9e28a1c9f9b..b7e8154107c 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1296,13 +1296,10 @@ decode_coding_utf_8 (struct coding_system *coding)
1296 int consumed_chars = 0, consumed_chars_base = 0; 1296 int consumed_chars = 0, consumed_chars_base = 0;
1297 int multibytep = coding->src_multibyte; 1297 int multibytep = coding->src_multibyte;
1298 enum utf_bom_type bom = CODING_UTF_8_BOM (coding); 1298 enum utf_bom_type bom = CODING_UTF_8_BOM (coding);
1299 Lisp_Object attr, charset_list;
1300 int eol_dos = 1299 int eol_dos =
1301 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 1300 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
1302 int byte_after_cr = -1; 1301 int byte_after_cr = -1;
1303 1302
1304 CODING_GET_INFO (coding, attr, charset_list);
1305
1306 if (bom != utf_without_bom) 1303 if (bom != utf_without_bom)
1307 { 1304 {
1308 int c1, c2, c3; 1305 int c1, c2, c3;
@@ -1610,13 +1607,10 @@ decode_coding_utf_16 (struct coding_system *coding)
1610 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); 1607 enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
1611 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); 1608 enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding);
1612 int surrogate = CODING_UTF_16_SURROGATE (coding); 1609 int surrogate = CODING_UTF_16_SURROGATE (coding);
1613 Lisp_Object attr, charset_list;
1614 int eol_dos = 1610 int eol_dos =
1615 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 1611 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
1616 int byte_after_cr1 = -1, byte_after_cr2 = -1; 1612 int byte_after_cr1 = -1, byte_after_cr2 = -1;
1617 1613
1618 CODING_GET_INFO (coding, attr, charset_list);
1619
1620 if (bom == utf_with_bom) 1614 if (bom == utf_with_bom)
1621 { 1615 {
1622 int c, c1, c2; 1616 int c, c1, c2;
@@ -1736,11 +1730,8 @@ encode_coding_utf_16 (struct coding_system *coding)
1736 enum utf_bom_type bom = CODING_UTF_16_BOM (coding); 1730 enum utf_bom_type bom = CODING_UTF_16_BOM (coding);
1737 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; 1731 int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian;
1738 int produced_chars = 0; 1732 int produced_chars = 0;
1739 Lisp_Object attrs, charset_list;
1740 int c; 1733 int c;
1741 1734
1742 CODING_GET_INFO (coding, attrs, charset_list);
1743
1744 if (bom != utf_without_bom) 1735 if (bom != utf_without_bom)
1745 { 1736 {
1746 ASSURE_DESTINATION (safe_room); 1737 ASSURE_DESTINATION (safe_room);
@@ -2342,7 +2333,6 @@ decode_coding_emacs_mule (struct coding_system *coding)
2342 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); 2333 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3);
2343 int consumed_chars = 0, consumed_chars_base; 2334 int consumed_chars = 0, consumed_chars_base;
2344 int multibytep = coding->src_multibyte; 2335 int multibytep = coding->src_multibyte;
2345 Lisp_Object attrs, charset_list;
2346 int char_offset = coding->produced_char; 2336 int char_offset = coding->produced_char;
2347 int last_offset = char_offset; 2337 int last_offset = char_offset;
2348 int last_id = charset_ascii; 2338 int last_id = charset_ascii;
@@ -2351,8 +2341,6 @@ decode_coding_emacs_mule (struct coding_system *coding)
2351 int byte_after_cr = -1; 2341 int byte_after_cr = -1;
2352 struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status; 2342 struct composition_status *cmp_status = &coding->spec.emacs_mule.cmp_status;
2353 2343
2354 CODING_GET_INFO (coding, attrs, charset_list);
2355
2356 if (cmp_status->state != COMPOSING_NO) 2344 if (cmp_status->state != COMPOSING_NO)
2357 { 2345 {
2358 int i; 2346 int i;
@@ -3265,11 +3253,10 @@ detect_coding_iso_2022 (struct coding_system *coding,
3265*/ 3253*/
3266 3254
3267/* Decode a composition rule C1 and maybe one more byte from the 3255/* Decode a composition rule C1 and maybe one more byte from the
3268 source, and set RULE to the encoded composition rule, NBYTES to the 3256 source, and set RULE to the encoded composition rule. If the rule
3269 length of the composition rule. If the rule is invalid, set RULE 3257 is invalid, set RULE to some negative value. */
3270 to some negative value. */
3271 3258
3272#define DECODE_COMPOSITION_RULE(rule, nbytes) \ 3259#define DECODE_COMPOSITION_RULE(rule) \
3273 do { \ 3260 do { \
3274 rule = c1 - 32; \ 3261 rule = c1 - 32; \
3275 if (rule < 0) \ 3262 if (rule < 0) \
@@ -3281,7 +3268,6 @@ detect_coding_iso_2022 (struct coding_system *coding,
3281 if (gref == 4) gref = 10; \ 3268 if (gref == 4) gref = 10; \
3282 if (nref == 4) nref = 10; \ 3269 if (nref == 4) nref = 10; \
3283 rule = COMPOSITION_ENCODE_RULE (gref, nref); \ 3270 rule = COMPOSITION_ENCODE_RULE (gref, nref); \
3284 nbytes = 1; \
3285 } \ 3271 } \
3286 else /* new format (after ver.21) */ \ 3272 else /* new format (after ver.21) */ \
3287 { \ 3273 { \
@@ -3291,7 +3277,6 @@ detect_coding_iso_2022 (struct coding_system *coding,
3291 rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \ 3277 rule = COMPOSITION_ENCODE_RULE (rule - 81, b - 32); \
3292 if (rule >= 0) \ 3278 if (rule >= 0) \
3293 rule += 0x100; /* to destinguish it from the old format */ \ 3279 rule += 0x100; /* to destinguish it from the old format */ \
3294 nbytes = 2; \
3295 } \ 3280 } \
3296 } while (0) 3281 } while (0)
3297 3282
@@ -3476,7 +3461,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
3476 struct charset *charset; 3461 struct charset *charset;
3477 int c; 3462 int c;
3478 struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); 3463 struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding);
3479 Lisp_Object attrs, charset_list; 3464 Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
3480 int char_offset = coding->produced_char; 3465 int char_offset = coding->produced_char;
3481 int last_offset = char_offset; 3466 int last_offset = char_offset;
3482 int last_id = charset_ascii; 3467 int last_id = charset_ascii;
@@ -3485,10 +3470,7 @@ decode_coding_iso_2022 (struct coding_system *coding)
3485 int byte_after_cr = -1; 3470 int byte_after_cr = -1;
3486 int i; 3471 int i;
3487 3472
3488 CODING_GET_INFO (coding, attrs, charset_list);
3489 setup_iso_safe_charsets (attrs); 3473 setup_iso_safe_charsets (attrs);
3490 /* Charset list may have been changed. */
3491 charset_list = CODING_ATTR_CHARSET_LIST (attrs);
3492 coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs)); 3474 coding->safe_charsets = SDATA (CODING_ATTR_SAFE_CHARSETS (attrs));
3493 3475
3494 if (cmp_status->state != COMPOSING_NO) 3476 if (cmp_status->state != COMPOSING_NO)
@@ -3558,9 +3540,9 @@ decode_coding_iso_2022 (struct coding_system *coding)
3558 || cmp_status->state == COMPOSING_COMPONENT_RULE) 3540 || cmp_status->state == COMPOSING_COMPONENT_RULE)
3559 && c1 != ISO_CODE_ESC) 3541 && c1 != ISO_CODE_ESC)
3560 { 3542 {
3561 int rule, nbytes; 3543 int rule;
3562 3544
3563 DECODE_COMPOSITION_RULE (rule, nbytes); 3545 DECODE_COMPOSITION_RULE (rule);
3564 if (rule < 0) 3546 if (rule < 0)
3565 goto invalid_code; 3547 goto invalid_code;
3566 STORE_COMPOSITION_RULE (rule); 3548 STORE_COMPOSITION_RULE (rule);
@@ -4878,13 +4860,12 @@ encode_coding_sjis (struct coding_system *coding)
4878 int produced_chars = 0; 4860 int produced_chars = 0;
4879 Lisp_Object attrs, charset_list, val; 4861 Lisp_Object attrs, charset_list, val;
4880 int ascii_compatible; 4862 int ascii_compatible;
4881 struct charset *charset_roman, *charset_kanji, *charset_kana; 4863 struct charset *charset_kanji, *charset_kana;
4882 struct charset *charset_kanji2; 4864 struct charset *charset_kanji2;
4883 int c; 4865 int c;
4884 4866
4885 CODING_GET_INFO (coding, attrs, charset_list); 4867 CODING_GET_INFO (coding, attrs, charset_list);
4886 val = charset_list; 4868 val = XCDR (charset_list);
4887 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
4888 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); 4869 charset_kana = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
4889 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val); 4870 charset_kanji = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
4890 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val))); 4871 charset_kanji2 = NILP (val) ? NULL : CHARSET_FROM_ID (XINT (XCAR (val)));
@@ -4970,12 +4951,11 @@ encode_coding_big5 (struct coding_system *coding)
4970 int produced_chars = 0; 4951 int produced_chars = 0;
4971 Lisp_Object attrs, charset_list, val; 4952 Lisp_Object attrs, charset_list, val;
4972 int ascii_compatible; 4953 int ascii_compatible;
4973 struct charset *charset_roman, *charset_big5; 4954 struct charset *charset_big5;
4974 int c; 4955 int c;
4975 4956
4976 CODING_GET_INFO (coding, attrs, charset_list); 4957 CODING_GET_INFO (coding, attrs, charset_list);
4977 val = charset_list; 4958 val = XCDR (charset_list);
4978 charset_roman = CHARSET_FROM_ID (XINT (XCAR (val))), val = XCDR (val);
4979 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val))); 4959 charset_big5 = CHARSET_FROM_ID (XINT (XCAR (val)));
4980 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); 4960 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs));
4981 4961
@@ -5433,7 +5413,8 @@ decode_coding_charset (struct coding_system *coding)
5433 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); 5413 = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2);
5434 int consumed_chars = 0, consumed_chars_base; 5414 int consumed_chars = 0, consumed_chars_base;
5435 int multibytep = coding->src_multibyte; 5415 int multibytep = coding->src_multibyte;
5436 Lisp_Object attrs, charset_list, valids; 5416 Lisp_Object attrs = CODING_ID_ATTRS (coding->id);
5417 Lisp_Object valids;
5437 int char_offset = coding->produced_char; 5418 int char_offset = coding->produced_char;
5438 int last_offset = char_offset; 5419 int last_offset = char_offset;
5439 int last_id = charset_ascii; 5420 int last_id = charset_ascii;
@@ -5441,7 +5422,6 @@ decode_coding_charset (struct coding_system *coding)
5441 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); 5422 !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos);
5442 int byte_after_cr = -1; 5423 int byte_after_cr = -1;
5443 5424
5444 CODING_GET_INFO (coding, attrs, charset_list);
5445 valids = AREF (attrs, coding_attr_charset_valids); 5425 valids = AREF (attrs, coding_attr_charset_valids);
5446 5426
5447 while (1) 5427 while (1)