aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c80
1 files changed, 58 insertions, 22 deletions
diff --git a/src/coding.c b/src/coding.c
index a1494ad38aa..385a22a188d 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1363,6 +1363,45 @@ decode_coding_utf_8 (struct coding_system *coding)
1363 break; 1363 break;
1364 } 1364 }
1365 1365
1366 /* In the simple case, rapidly handle ordinary characters */
1367 if (multibytep && ! eol_dos
1368 && charbuf < charbuf_end - 6 && src < src_end - 6)
1369 {
1370 while (charbuf < charbuf_end - 6 && src < src_end - 6)
1371 {
1372 c1 = *src;
1373 if (c1 & 0x80)
1374 break;
1375 src++;
1376 consumed_chars++;
1377 *charbuf++ = c1;
1378
1379 c1 = *src;
1380 if (c1 & 0x80)
1381 break;
1382 src++;
1383 consumed_chars++;
1384 *charbuf++ = c1;
1385
1386 c1 = *src;
1387 if (c1 & 0x80)
1388 break;
1389 src++;
1390 consumed_chars++;
1391 *charbuf++ = c1;
1392
1393 c1 = *src;
1394 if (c1 & 0x80)
1395 break;
1396 src++;
1397 consumed_chars++;
1398 *charbuf++ = c1;
1399 }
1400 /* If we handled at least one character, restart the main loop. */
1401 if (src != src_base)
1402 continue;
1403 }
1404
1366 if (byte_after_cr >= 0) 1405 if (byte_after_cr >= 0)
1367 c1 = byte_after_cr, byte_after_cr = -1; 1406 c1 = byte_after_cr, byte_after_cr = -1;
1368 else 1407 else
@@ -6864,11 +6903,9 @@ get_translation_table (Lisp_Object attrs, bool encodep, int *max_lookup)
6864 if (CHAR_TABLE_P (standard)) 6903 if (CHAR_TABLE_P (standard))
6865 { 6904 {
6866 if (CONSP (translation_table)) 6905 if (CONSP (translation_table))
6867 translation_table = nconc2 (translation_table, 6906 translation_table = nconc2 (translation_table, list1 (standard));
6868 Fcons (standard, Qnil));
6869 else 6907 else
6870 translation_table = Fcons (translation_table, 6908 translation_table = list2 (translation_table, standard);
6871 Fcons (standard, Qnil));
6872 } 6909 }
6873 } 6910 }
6874 6911
@@ -7793,7 +7830,7 @@ make_conversion_work_buffer (bool multibyte)
7793} 7830}
7794 7831
7795 7832
7796static Lisp_Object 7833static void
7797code_conversion_restore (Lisp_Object arg) 7834code_conversion_restore (Lisp_Object arg)
7798{ 7835{
7799 Lisp_Object current, workbuf; 7836 Lisp_Object current, workbuf;
@@ -7811,7 +7848,6 @@ code_conversion_restore (Lisp_Object arg)
7811 } 7848 }
7812 set_buffer_internal (XBUFFER (current)); 7849 set_buffer_internal (XBUFFER (current));
7813 UNGCPRO; 7850 UNGCPRO;
7814 return Qnil;
7815} 7851}
7816 7852
7817Lisp_Object 7853Lisp_Object
@@ -8667,20 +8703,20 @@ detect_coding_system (const unsigned char *src,
8667 { 8703 {
8668 detect_info.found = CATEGORY_MASK_RAW_TEXT; 8704 detect_info.found = CATEGORY_MASK_RAW_TEXT;
8669 id = CODING_SYSTEM_ID (Qno_conversion); 8705 id = CODING_SYSTEM_ID (Qno_conversion);
8670 val = Fcons (make_number (id), Qnil); 8706 val = list1 (make_number (id));
8671 } 8707 }
8672 else if (! detect_info.rejected && ! detect_info.found) 8708 else if (! detect_info.rejected && ! detect_info.found)
8673 { 8709 {
8674 detect_info.found = CATEGORY_MASK_ANY; 8710 detect_info.found = CATEGORY_MASK_ANY;
8675 id = coding_categories[coding_category_undecided].id; 8711 id = coding_categories[coding_category_undecided].id;
8676 val = Fcons (make_number (id), Qnil); 8712 val = list1 (make_number (id));
8677 } 8713 }
8678 else if (highest) 8714 else if (highest)
8679 { 8715 {
8680 if (detect_info.found) 8716 if (detect_info.found)
8681 { 8717 {
8682 detect_info.found = 1 << category; 8718 detect_info.found = 1 << category;
8683 val = Fcons (make_number (this->id), Qnil); 8719 val = list1 (make_number (this->id));
8684 } 8720 }
8685 else 8721 else
8686 for (i = 0; i < coding_category_raw_text; i++) 8722 for (i = 0; i < coding_category_raw_text; i++)
@@ -8688,7 +8724,7 @@ detect_coding_system (const unsigned char *src,
8688 { 8724 {
8689 detect_info.found = 1 << coding_priorities[i]; 8725 detect_info.found = 1 << coding_priorities[i];
8690 id = coding_categories[coding_priorities[i]].id; 8726 id = coding_categories[coding_priorities[i]].id;
8691 val = Fcons (make_number (id), Qnil); 8727 val = list1 (make_number (id));
8692 break; 8728 break;
8693 } 8729 }
8694 } 8730 }
@@ -8705,7 +8741,7 @@ detect_coding_system (const unsigned char *src,
8705 found |= 1 << category; 8741 found |= 1 << category;
8706 id = coding_categories[category].id; 8742 id = coding_categories[category].id;
8707 if (id >= 0) 8743 if (id >= 0)
8708 val = Fcons (make_number (id), val); 8744 val = list1 (make_number (id));
8709 } 8745 }
8710 } 8746 }
8711 for (i = coding_category_raw_text - 1; i >= 0; i--) 8747 for (i = coding_category_raw_text - 1; i >= 0; i--)
@@ -8730,7 +8766,7 @@ detect_coding_system (const unsigned char *src,
8730 this = coding_categories + coding_category_utf_8_sig; 8766 this = coding_categories + coding_category_utf_8_sig;
8731 else 8767 else
8732 this = coding_categories + coding_category_utf_8_nosig; 8768 this = coding_categories + coding_category_utf_8_nosig;
8733 val = Fcons (make_number (this->id), Qnil); 8769 val = list1 (make_number (this->id));
8734 } 8770 }
8735 } 8771 }
8736 else if (base_category == coding_category_utf_16_auto) 8772 else if (base_category == coding_category_utf_16_auto)
@@ -8747,13 +8783,13 @@ detect_coding_system (const unsigned char *src,
8747 this = coding_categories + coding_category_utf_16_be_nosig; 8783 this = coding_categories + coding_category_utf_16_be_nosig;
8748 else 8784 else
8749 this = coding_categories + coding_category_utf_16_le_nosig; 8785 this = coding_categories + coding_category_utf_16_le_nosig;
8750 val = Fcons (make_number (this->id), Qnil); 8786 val = list1 (make_number (this->id));
8751 } 8787 }
8752 } 8788 }
8753 else 8789 else
8754 { 8790 {
8755 detect_info.found = 1 << XINT (CODING_ATTR_CATEGORY (attrs)); 8791 detect_info.found = 1 << XINT (CODING_ATTR_CATEGORY (attrs));
8756 val = Fcons (make_number (coding.id), Qnil); 8792 val = list1 (make_number (coding.id));
8757 } 8793 }
8758 8794
8759 /* Then, detect eol-format if necessary. */ 8795 /* Then, detect eol-format if necessary. */
@@ -9224,7 +9260,7 @@ is nil. */)
9224 attrs = AREF (CODING_SYSTEM_SPEC (elt), 0); 9260 attrs = AREF (CODING_SYSTEM_SPEC (elt), 0);
9225 ASET (attrs, coding_attr_trans_tbl, 9261 ASET (attrs, coding_attr_trans_tbl,
9226 get_translation_table (attrs, 1, NULL)); 9262 get_translation_table (attrs, 1, NULL));
9227 list = Fcons (Fcons (elt, Fcons (attrs, Qnil)), list); 9263 list = Fcons (list2 (elt, attrs), list);
9228 } 9264 }
9229 9265
9230 if (STRINGP (start)) 9266 if (STRINGP (start))
@@ -9635,7 +9671,7 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern
9635 tset_charset_list 9671 tset_charset_list
9636 (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK 9672 (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK
9637 ? coding_charset_list (terminal_coding) 9673 ? coding_charset_list (terminal_coding)
9638 : Fcons (make_number (charset_ascii), Qnil))); 9674 : list1 (make_number (charset_ascii))));
9639 return Qnil; 9675 return Qnil;
9640} 9676}
9641 9677
@@ -10080,9 +10116,9 @@ usage: (define-coding-system-internal ...) */)
10080 { 10116 {
10081 dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp))); 10117 dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp)));
10082 if (dim < dim2) 10118 if (dim < dim2)
10083 tmp = Fcons (XCAR (tail), Fcons (tmp, Qnil)); 10119 tmp = list2 (XCAR (tail), tmp);
10084 else 10120 else
10085 tmp = Fcons (tmp, Fcons (XCAR (tail), Qnil)); 10121 tmp = list2 (tmp, XCAR (tail));
10086 } 10122 }
10087 else 10123 else
10088 { 10124 {
@@ -10093,7 +10129,7 @@ usage: (define-coding-system-internal ...) */)
10093 break; 10129 break;
10094 } 10130 }
10095 if (NILP (tmp2)) 10131 if (NILP (tmp2))
10096 tmp = nconc2 (tmp, Fcons (XCAR (tail), Qnil)); 10132 tmp = nconc2 (tmp, list1 (XCAR (tail)));
10097 else 10133 else
10098 { 10134 {
10099 XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2))); 10135 XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2)));
@@ -10411,7 +10447,7 @@ usage: (define-coding-system-internal ...) */)
10411 && ! EQ (eol_type, Qmac)) 10447 && ! EQ (eol_type, Qmac))
10412 error ("Invalid eol-type"); 10448 error ("Invalid eol-type");
10413 10449
10414 aliases = Fcons (name, Qnil); 10450 aliases = list1 (name);
10415 10451
10416 if (NILP (eol_type)) 10452 if (NILP (eol_type))
10417 { 10453 {
@@ -10421,7 +10457,7 @@ usage: (define-coding-system-internal ...) */)
10421 Lisp_Object this_spec, this_name, this_aliases, this_eol_type; 10457 Lisp_Object this_spec, this_name, this_aliases, this_eol_type;
10422 10458
10423 this_name = AREF (eol_type, i); 10459 this_name = AREF (eol_type, i);
10424 this_aliases = Fcons (this_name, Qnil); 10460 this_aliases = list1 (this_name);
10425 this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac); 10461 this_eol_type = (i == 0 ? Qunix : i == 1 ? Qdos : Qmac);
10426 this_spec = make_uninit_vector (3); 10462 this_spec = make_uninit_vector (3);
10427 ASET (this_spec, 0, attrs); 10463 ASET (this_spec, 0, attrs);
@@ -10536,7 +10572,7 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias,
10536 list. */ 10572 list. */
10537 while (!NILP (XCDR (aliases))) 10573 while (!NILP (XCDR (aliases)))
10538 aliases = XCDR (aliases); 10574 aliases = XCDR (aliases);
10539 XSETCDR (aliases, Fcons (alias, Qnil)); 10575 XSETCDR (aliases, list1 (alias));
10540 10576
10541 eol_type = AREF (spec, 2); 10577 eol_type = AREF (spec, 2);
10542 if (VECTORP (eol_type)) 10578 if (VECTORP (eol_type))