diff options
| author | Tom Tromey | 2013-07-26 14:02:53 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-07-26 14:02:53 -0600 |
| commit | cc231cbe45d27a1906d268fb72d3b4105a2e9c65 (patch) | |
| tree | c011828e2a3a18e77eaa8849e3cccb805d798f42 /src/coding.c | |
| parent | b34a529f177a6ea32da5cb1254f91bf9d71838db (diff) | |
| parent | fec9206062b420aca84f53d05a72c3ee43244022 (diff) | |
| download | emacs-cc231cbe45d27a1906d268fb72d3b4105a2e9c65.tar.gz emacs-cc231cbe45d27a1906d268fb72d3b4105a2e9c65.zip | |
merge from trunk
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 94 |
1 files changed, 70 insertions, 24 deletions
diff --git a/src/coding.c b/src/coding.c index 1ab59294b98..0cdd8f9cd9e 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -493,6 +493,8 @@ enum iso_code_class_type | |||
| 493 | 493 | ||
| 494 | #define CODING_ISO_FLAG_USE_OLDJIS 0x10000 | 494 | #define CODING_ISO_FLAG_USE_OLDJIS 0x10000 |
| 495 | 495 | ||
| 496 | #define CODING_ISO_FLAG_LEVEL_4 0x20000 | ||
| 497 | |||
| 496 | #define CODING_ISO_FLAG_FULL_SUPPORT 0x100000 | 498 | #define CODING_ISO_FLAG_FULL_SUPPORT 0x100000 |
| 497 | 499 | ||
| 498 | /* A character to be produced on output if encoding of the original | 500 | /* A character to be produced on output if encoding of the original |
| @@ -1363,6 +1365,45 @@ decode_coding_utf_8 (struct coding_system *coding) | |||
| 1363 | break; | 1365 | break; |
| 1364 | } | 1366 | } |
| 1365 | 1367 | ||
| 1368 | /* In the simple case, rapidly handle ordinary characters */ | ||
| 1369 | if (multibytep && ! eol_dos | ||
| 1370 | && charbuf < charbuf_end - 6 && src < src_end - 6) | ||
| 1371 | { | ||
| 1372 | while (charbuf < charbuf_end - 6 && src < src_end - 6) | ||
| 1373 | { | ||
| 1374 | c1 = *src; | ||
| 1375 | if (c1 & 0x80) | ||
| 1376 | break; | ||
| 1377 | src++; | ||
| 1378 | consumed_chars++; | ||
| 1379 | *charbuf++ = c1; | ||
| 1380 | |||
| 1381 | c1 = *src; | ||
| 1382 | if (c1 & 0x80) | ||
| 1383 | break; | ||
| 1384 | src++; | ||
| 1385 | consumed_chars++; | ||
| 1386 | *charbuf++ = c1; | ||
| 1387 | |||
| 1388 | c1 = *src; | ||
| 1389 | if (c1 & 0x80) | ||
| 1390 | break; | ||
| 1391 | src++; | ||
| 1392 | consumed_chars++; | ||
| 1393 | *charbuf++ = c1; | ||
| 1394 | |||
| 1395 | c1 = *src; | ||
| 1396 | if (c1 & 0x80) | ||
| 1397 | break; | ||
| 1398 | src++; | ||
| 1399 | consumed_chars++; | ||
| 1400 | *charbuf++ = c1; | ||
| 1401 | } | ||
| 1402 | /* If we handled at least one character, restart the main loop. */ | ||
| 1403 | if (src != src_base) | ||
| 1404 | continue; | ||
| 1405 | } | ||
| 1406 | |||
| 1366 | if (byte_after_cr >= 0) | 1407 | if (byte_after_cr >= 0) |
| 1367 | c1 = byte_after_cr, byte_after_cr = -1; | 1408 | c1 = byte_after_cr, byte_after_cr = -1; |
| 1368 | else | 1409 | else |
| @@ -3733,7 +3774,10 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3733 | else | 3774 | else |
| 3734 | charset = CHARSET_FROM_ID (charset_id_2); | 3775 | charset = CHARSET_FROM_ID (charset_id_2); |
| 3735 | ONE_MORE_BYTE (c1); | 3776 | ONE_MORE_BYTE (c1); |
| 3736 | if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) | 3777 | if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0) |
| 3778 | || (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) | ||
| 3779 | && ((CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LEVEL_4) | ||
| 3780 | ? c1 >= 0x80 : c1 < 0x80))) | ||
| 3737 | goto invalid_code; | 3781 | goto invalid_code; |
| 3738 | break; | 3782 | break; |
| 3739 | 3783 | ||
| @@ -3747,7 +3791,10 @@ decode_coding_iso_2022 (struct coding_system *coding) | |||
| 3747 | else | 3791 | else |
| 3748 | charset = CHARSET_FROM_ID (charset_id_3); | 3792 | charset = CHARSET_FROM_ID (charset_id_3); |
| 3749 | ONE_MORE_BYTE (c1); | 3793 | ONE_MORE_BYTE (c1); |
| 3750 | if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0)) | 3794 | if (c1 < 0x20 || (c1 >= 0x80 && c1 < 0xA0) |
| 3795 | || (! (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_SEVEN_BITS) | ||
| 3796 | && ((CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_LEVEL_4) | ||
| 3797 | ? c1 >= 0x80 : c1 < 0x80))) | ||
| 3751 | goto invalid_code; | 3798 | goto invalid_code; |
| 3752 | break; | 3799 | break; |
| 3753 | 3800 | ||
| @@ -6864,11 +6911,9 @@ get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup) | |||
| 6864 | if (CHAR_TABLE_P (standard)) | 6911 | if (CHAR_TABLE_P (standard)) |
| 6865 | { | 6912 | { |
| 6866 | if (CONSP (translation_table)) | 6913 | if (CONSP (translation_table)) |
| 6867 | translation_table = nconc2 (translation_table, | 6914 | translation_table = nconc2 (translation_table, list1 (standard)); |
| 6868 | Fcons (standard, Qnil)); | ||
| 6869 | else | 6915 | else |
| 6870 | translation_table = Fcons (translation_table, | 6916 | translation_table = list2 (translation_table, standard); |
| 6871 | Fcons (standard, Qnil)); | ||
| 6872 | } | 6917 | } |
| 6873 | } | 6918 | } |
| 6874 | 6919 | ||
| @@ -7793,7 +7838,7 @@ make_conversion_work_buffer (bool multibyte) | |||
| 7793 | } | 7838 | } |
| 7794 | 7839 | ||
| 7795 | 7840 | ||
| 7796 | static Lisp_Object | 7841 | static void |
| 7797 | code_conversion_restore (Lisp_Object arg) | 7842 | code_conversion_restore (Lisp_Object arg) |
| 7798 | { | 7843 | { |
| 7799 | Lisp_Object current, workbuf; | 7844 | Lisp_Object current, workbuf; |
| @@ -7811,7 +7856,6 @@ code_conversion_restore (Lisp_Object arg) | |||
| 7811 | } | 7856 | } |
| 7812 | set_buffer_internal (XBUFFER (current)); | 7857 | set_buffer_internal (XBUFFER (current)); |
| 7813 | UNGCPRO; | 7858 | UNGCPRO; |
| 7814 | return Qnil; | ||
| 7815 | } | 7859 | } |
| 7816 | 7860 | ||
| 7817 | Lisp_Object | 7861 | Lisp_Object |
| @@ -8667,20 +8711,20 @@ detect_coding_system (const unsigned char *src, | |||
| 8667 | { | 8711 | { |
| 8668 | detect_info.found = CATEGORY_MASK_RAW_TEXT; | 8712 | detect_info.found = CATEGORY_MASK_RAW_TEXT; |
| 8669 | id = CODING_SYSTEM_ID (Qno_conversion); | 8713 | id = CODING_SYSTEM_ID (Qno_conversion); |
| 8670 | val = Fcons (make_number (id), Qnil); | 8714 | val = list1 (make_number (id)); |
| 8671 | } | 8715 | } |
| 8672 | else if (! detect_info.rejected && ! detect_info.found) | 8716 | else if (! detect_info.rejected && ! detect_info.found) |
| 8673 | { | 8717 | { |
| 8674 | detect_info.found = CATEGORY_MASK_ANY; | 8718 | detect_info.found = CATEGORY_MASK_ANY; |
| 8675 | id = coding_categories[coding_category_undecided].id; | 8719 | id = coding_categories[coding_category_undecided].id; |
| 8676 | val = Fcons (make_number (id), Qnil); | 8720 | val = list1 (make_number (id)); |
| 8677 | } | 8721 | } |
| 8678 | else if (highest) | 8722 | else if (highest) |
| 8679 | { | 8723 | { |
| 8680 | if (detect_info.found) | 8724 | if (detect_info.found) |
| 8681 | { | 8725 | { |
| 8682 | detect_info.found = 1 << category; | 8726 | detect_info.found = 1 << category; |
| 8683 | val = Fcons (make_number (this->id), Qnil); | 8727 | val = list1 (make_number (this->id)); |
| 8684 | } | 8728 | } |
| 8685 | else | 8729 | else |
| 8686 | for (i = 0; i < coding_category_raw_text; i++) | 8730 | for (i = 0; i < coding_category_raw_text; i++) |
| @@ -8688,7 +8732,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8688 | { | 8732 | { |
| 8689 | detect_info.found = 1 << coding_priorities[i]; | 8733 | detect_info.found = 1 << coding_priorities[i]; |
| 8690 | id = coding_categories[coding_priorities[i]].id; | 8734 | id = coding_categories[coding_priorities[i]].id; |
| 8691 | val = Fcons (make_number (id), Qnil); | 8735 | val = list1 (make_number (id)); |
| 8692 | break; | 8736 | break; |
| 8693 | } | 8737 | } |
| 8694 | } | 8738 | } |
| @@ -8705,7 +8749,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8705 | found |= 1 << category; | 8749 | found |= 1 << category; |
| 8706 | id = coding_categories[category].id; | 8750 | id = coding_categories[category].id; |
| 8707 | if (id >= 0) | 8751 | if (id >= 0) |
| 8708 | val = Fcons (make_number (id), val); | 8752 | val = list1 (make_number (id)); |
| 8709 | } | 8753 | } |
| 8710 | } | 8754 | } |
| 8711 | for (i = coding_category_raw_text - 1; i >= 0; i--) | 8755 | for (i = coding_category_raw_text - 1; i >= 0; i--) |
| @@ -8730,7 +8774,7 @@ detect_coding_system (const unsigned char *src, | |||
| 8730 | this = coding_categories + coding_category_utf_8_sig; | 8774 | this = coding_categories + coding_category_utf_8_sig; |
| 8731 | else | 8775 | else |
| 8732 | this = coding_categories + coding_category_utf_8_nosig; | 8776 | this = coding_categories + coding_category_utf_8_nosig; |
| 8733 | val = Fcons (make_number (this->id), Qnil); | 8777 | val = list1 (make_number (this->id)); |
| 8734 | } | 8778 | } |
| 8735 | } | 8779 | } |
| 8736 | else if (base_category == coding_category_utf_16_auto) | 8780 | else if (base_category == coding_category_utf_16_auto) |
| @@ -8747,13 +8791,13 @@ detect_coding_system (const unsigned char *src, | |||
| 8747 | this = coding_categories + coding_category_utf_16_be_nosig; | 8791 | this = coding_categories + coding_category_utf_16_be_nosig; |
| 8748 | else | 8792 | else |
| 8749 | this = coding_categories + coding_category_utf_16_le_nosig; | 8793 | this = coding_categories + coding_category_utf_16_le_nosig; |
| 8750 | val = Fcons (make_number (this->id), Qnil); | 8794 | val = list1 (make_number (this->id)); |
| 8751 | } | 8795 | } |
| 8752 | } | 8796 | } |
| 8753 | else | 8797 | else |
| 8754 | { | 8798 | { |
| 8755 | detect_info.found = 1 << XINT (CODING_ATTR_CATEGORY (attrs)); | 8799 | detect_info.found = 1 << XINT (CODING_ATTR_CATEGORY (attrs)); |
| 8756 | val = Fcons (make_number (coding.id), Qnil); | 8800 | val = list1 (make_number (coding.id)); |
| 8757 | } | 8801 | } |
| 8758 | 8802 | ||
| 8759 | /* Then, detect eol-format if necessary. */ | 8803 | /* Then, detect eol-format if necessary. */ |
| @@ -9224,7 +9268,7 @@ is nil. */) | |||
| 9224 | attrs = AREF (CODING_SYSTEM_SPEC (elt), 0); | 9268 | attrs = AREF (CODING_SYSTEM_SPEC (elt), 0); |
| 9225 | ASET (attrs, coding_attr_trans_tbl, | 9269 | ASET (attrs, coding_attr_trans_tbl, |
| 9226 | get_translation_table (attrs, 1, NULL)); | 9270 | get_translation_table (attrs, 1, NULL)); |
| 9227 | list = Fcons (Fcons (elt, Fcons (attrs, Qnil)), list); | 9271 | list = Fcons (list2 (elt, attrs), list); |
| 9228 | } | 9272 | } |
| 9229 | 9273 | ||
| 9230 | if (STRINGP (start)) | 9274 | if (STRINGP (start)) |
| @@ -9635,7 +9679,7 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern | |||
| 9635 | tset_charset_list | 9679 | tset_charset_list |
| 9636 | (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK | 9680 | (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK |
| 9637 | ? coding_charset_list (terminal_coding) | 9681 | ? coding_charset_list (terminal_coding) |
| 9638 | : Fcons (make_number (charset_ascii), Qnil))); | 9682 | : list1 (make_number (charset_ascii)))); |
| 9639 | return Qnil; | 9683 | return Qnil; |
| 9640 | } | 9684 | } |
| 9641 | 9685 | ||
| @@ -10080,9 +10124,9 @@ usage: (define-coding-system-internal ...) */) | |||
| 10080 | { | 10124 | { |
| 10081 | dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp))); | 10125 | dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp))); |
| 10082 | if (dim < dim2) | 10126 | if (dim < dim2) |
| 10083 | tmp = Fcons (XCAR (tail), Fcons (tmp, Qnil)); | 10127 | tmp = list2 (XCAR (tail), tmp); |
| 10084 | else | 10128 | else |
| 10085 | tmp = Fcons (tmp, Fcons (XCAR (tail), Qnil)); | 10129 | tmp = list2 (tmp, XCAR (tail)); |
| 10086 | } | 10130 | } |
| 10087 | else | 10131 | else |
| 10088 | { | 10132 | { |
| @@ -10093,7 +10137,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 10093 | break; | 10137 | break; |
| 10094 | } | 10138 | } |
| 10095 | if (NILP (tmp2)) | 10139 | if (NILP (tmp2)) |
| 10096 | tmp = nconc2 (tmp, Fcons (XCAR (tail), Qnil)); | 10140 | tmp = nconc2 (tmp, list1 (XCAR (tail))); |
| 10097 | else | 10141 | else |
| 10098 | { | 10142 | { |
| 10099 | XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2))); | 10143 | XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2))); |
| @@ -10411,7 +10455,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 10411 | && ! EQ (eol_type, Qmac)) | 10455 | && ! EQ (eol_type, Qmac)) |
| 10412 | error ("Invalid eol-type"); | 10456 | error ("Invalid eol-type"); |
| 10413 | 10457 | ||
| 10414 | aliases = Fcons (name, Qnil); | 10458 | aliases = list1 (name); |
| 10415 | 10459 | ||
| 10416 | if (NILP (eol_type)) | 10460 | if (NILP (eol_type)) |
| 10417 | { | 10461 | { |
| @@ -10421,7 +10465,7 @@ usage: (define-coding-system-internal ...) */) | |||
| 10421 | Lisp_Object this_spec, this_name, this_aliases, this_eol_type; | 10465 | Lisp_Object this_spec, this_name, this_aliases, this_eol_type; |
| 10422 | 10466 | ||
| 10423 | this_name = AREF (eol_type, i); | 10467 | this_name = AREF (eol_type, i); |
| 10424 | this_aliases = Fcons (this_name, Qnil); | 10468 | this_aliases = list1 (this_name); |
| 10425 | this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); | 10469 | this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); |
| 10426 | this_spec = make_uninit_vector (3); | 10470 | this_spec = make_uninit_vector (3); |
| 10427 | ASET (this_spec, 0, attrs); | 10471 | ASET (this_spec, 0, attrs); |
| @@ -10536,7 +10580,7 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, | |||
| 10536 | list. */ | 10580 | list. */ |
| 10537 | while (!NILP (XCDR (aliases))) | 10581 | while (!NILP (XCDR (aliases))) |
| 10538 | aliases = XCDR (aliases); | 10582 | aliases = XCDR (aliases); |
| 10539 | XSETCDR (aliases, Fcons (alias, Qnil)); | 10583 | XSETCDR (aliases, list1 (alias)); |
| 10540 | 10584 | ||
| 10541 | eol_type = AREF (spec, 2); | 10585 | eol_type = AREF (spec, 2); |
| 10542 | if (VECTORP (eol_type)) | 10586 | if (VECTORP (eol_type)) |
| @@ -11218,6 +11262,8 @@ character."); | |||
| 11218 | plist[13] = build_pure_c_string ("No conversion on encoding, automatic conversion on decoding."); | 11262 | plist[13] = build_pure_c_string ("No conversion on encoding, automatic conversion on decoding."); |
| 11219 | plist[15] = args[coding_arg_eol_type] = Qnil; | 11263 | plist[15] = args[coding_arg_eol_type] = Qnil; |
| 11220 | args[coding_arg_plist] = Flist (16, plist); | 11264 | args[coding_arg_plist] = Flist (16, plist); |
| 11265 | args[coding_arg_undecided_inhibit_null_byte_detection] = make_number (0); | ||
| 11266 | args[coding_arg_undecided_inhibit_iso_escape_detection] = make_number (0); | ||
| 11221 | Fdefine_coding_system_internal (coding_arg_undecided_max, args); | 11267 | Fdefine_coding_system_internal (coding_arg_undecided_max, args); |
| 11222 | } | 11268 | } |
| 11223 | 11269 | ||