aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorJoakim Verona2012-08-15 21:49:40 +0200
committerJoakim Verona2012-08-15 21:49:40 +0200
commitb648c26ec642a1dc58c0bd7e59d6011b964dbe37 (patch)
treef0f3b38ffa9054702f475fc53622e28da14f97b1 /src/coding.c
parentc8b0fc1999006af5a4317b44068fac13d9592143 (diff)
parent94c9ece10275f8ca9323c38f93607f1046035c79 (diff)
downloademacs-b648c26ec642a1dc58c0bd7e59d6011b964dbe37.tar.gz
emacs-b648c26ec642a1dc58c0bd7e59d6011b964dbe37.zip
upstream
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c110
1 files changed, 60 insertions, 50 deletions
diff --git a/src/coding.c b/src/coding.c
index e4ed65079d9..c601a18b26e 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -2674,8 +2674,8 @@ encode_coding_emacs_mule (struct coding_system *coding)
2674 CODING_GET_INFO (coding, attrs, charset_list); 2674 CODING_GET_INFO (coding, attrs, charset_list);
2675 if (! EQ (charset_list, Vemacs_mule_charset_list)) 2675 if (! EQ (charset_list, Vemacs_mule_charset_list))
2676 { 2676 {
2677 CODING_ATTR_CHARSET_LIST (attrs) 2677 charset_list = Vemacs_mule_charset_list;
2678 = charset_list = Vemacs_mule_charset_list; 2678 ASET (attrs, coding_attr_charset_list, charset_list);
2679 } 2679 }
2680 2680
2681 while (charbuf < charbuf_end) 2681 while (charbuf < charbuf_end)
@@ -2967,8 +2967,8 @@ setup_iso_safe_charsets (Lisp_Object attrs)
2967 if ((flags & CODING_ISO_FLAG_FULL_SUPPORT) 2967 if ((flags & CODING_ISO_FLAG_FULL_SUPPORT)
2968 && ! EQ (charset_list, Viso_2022_charset_list)) 2968 && ! EQ (charset_list, Viso_2022_charset_list))
2969 { 2969 {
2970 CODING_ATTR_CHARSET_LIST (attrs) 2970 charset_list = Viso_2022_charset_list;
2971 = charset_list = Viso_2022_charset_list; 2971 ASET (attrs, coding_attr_charset_list, charset_list);
2972 ASET (attrs, coding_attr_safe_charsets, Qnil); 2972 ASET (attrs, coding_attr_safe_charsets, Qnil);
2973 } 2973 }
2974 2974
@@ -7102,8 +7102,17 @@ decode_coding (struct coding_system *coding)
7102 set_buffer_internal (XBUFFER (coding->dst_object)); 7102 set_buffer_internal (XBUFFER (coding->dst_object));
7103 if (GPT != PT) 7103 if (GPT != PT)
7104 move_gap_both (PT, PT_BYTE); 7104 move_gap_both (PT, PT_BYTE);
7105
7106 /* We must disable undo_list in order to record the whole insert
7107 transaction via record_insert at the end. But doing so also
7108 disables the recording of the first change to the undo_list.
7109 Therefore we check for first change here and record it via
7110 record_first_change if needed. */
7111 if (MODIFF <= SAVE_MODIFF)
7112 record_first_change ();
7113
7105 undo_list = BVAR (current_buffer, undo_list); 7114 undo_list = BVAR (current_buffer, undo_list);
7106 BVAR (current_buffer, undo_list) = Qt; 7115 BSET (current_buffer, undo_list, Qt);
7107 } 7116 }
7108 7117
7109 coding->consumed = coding->consumed_char = 0; 7118 coding->consumed = coding->consumed_char = 0;
@@ -7200,7 +7209,7 @@ decode_coding (struct coding_system *coding)
7200 decode_eol (coding); 7209 decode_eol (coding);
7201 if (BUFFERP (coding->dst_object)) 7210 if (BUFFERP (coding->dst_object))
7202 { 7211 {
7203 BVAR (current_buffer, undo_list) = undo_list; 7212 BSET (current_buffer, undo_list, undo_list);
7204 record_insert (coding->dst_pos, coding->produced_char); 7213 record_insert (coding->dst_pos, coding->produced_char);
7205 } 7214 }
7206 return coding->result; 7215 return coding->result;
@@ -7568,8 +7577,8 @@ make_conversion_work_buffer (int multibyte)
7568 doesn't compile new regexps. */ 7577 doesn't compile new regexps. */
7569 Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt); 7578 Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt);
7570 Ferase_buffer (); 7579 Ferase_buffer ();
7571 BVAR (current_buffer, undo_list) = Qt; 7580 BSET (current_buffer, undo_list, Qt);
7572 BVAR (current_buffer, enable_multibyte_characters) = multibyte ? Qt : Qnil; 7581 BSET (current_buffer, enable_multibyte_characters, multibyte ? Qt : Qnil);
7573 set_buffer_internal (current); 7582 set_buffer_internal (current);
7574 return workbuf; 7583 return workbuf;
7575} 7584}
@@ -9294,9 +9303,9 @@ DEFUN ("set-terminal-coding-system-internal", Fset_terminal_coding_system_intern
9294 terminal_coding->src_multibyte = 1; 9303 terminal_coding->src_multibyte = 1;
9295 terminal_coding->dst_multibyte = 0; 9304 terminal_coding->dst_multibyte = 0;
9296 if (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK) 9305 if (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK)
9297 term->charset_list = coding_charset_list (terminal_coding); 9306 TSET (term, charset_list, coding_charset_list (terminal_coding));
9298 else 9307 else
9299 term->charset_list = Fcons (make_number (charset_ascii), Qnil); 9308 TSET (term, charset_list, Fcons (make_number (charset_ascii), Qnil));
9300 return Qnil; 9309 return Qnil;
9301} 9310}
9302 9311
@@ -9603,16 +9612,16 @@ usage: (define-coding-system-internal ...) */)
9603 9612
9604 name = args[coding_arg_name]; 9613 name = args[coding_arg_name];
9605 CHECK_SYMBOL (name); 9614 CHECK_SYMBOL (name);
9606 CODING_ATTR_BASE_NAME (attrs) = name; 9615 ASET (attrs, coding_attr_base_name, name);
9607 9616
9608 val = args[coding_arg_mnemonic]; 9617 val = args[coding_arg_mnemonic];
9609 if (! STRINGP (val)) 9618 if (! STRINGP (val))
9610 CHECK_CHARACTER (val); 9619 CHECK_CHARACTER (val);
9611 CODING_ATTR_MNEMONIC (attrs) = val; 9620 ASET (attrs, coding_attr_mnemonic, val);
9612 9621
9613 coding_type = args[coding_arg_coding_type]; 9622 coding_type = args[coding_arg_coding_type];
9614 CHECK_SYMBOL (coding_type); 9623 CHECK_SYMBOL (coding_type);
9615 CODING_ATTR_TYPE (attrs) = coding_type; 9624 ASET (attrs, coding_attr_type, coding_type);
9616 9625
9617 charset_list = args[coding_arg_charset_list]; 9626 charset_list = args[coding_arg_charset_list];
9618 if (SYMBOLP (charset_list)) 9627 if (SYMBOLP (charset_list))
@@ -9659,49 +9668,49 @@ usage: (define-coding-system-internal ...) */)
9659 max_charset_id = charset->id; 9668 max_charset_id = charset->id;
9660 } 9669 }
9661 } 9670 }
9662 CODING_ATTR_CHARSET_LIST (attrs) = charset_list; 9671 ASET (attrs, coding_attr_charset_list, charset_list);
9663 9672
9664 safe_charsets = make_uninit_string (max_charset_id + 1); 9673 safe_charsets = make_uninit_string (max_charset_id + 1);
9665 memset (SDATA (safe_charsets), 255, max_charset_id + 1); 9674 memset (SDATA (safe_charsets), 255, max_charset_id + 1);
9666 for (tail = charset_list; CONSP (tail); tail = XCDR (tail)) 9675 for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
9667 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0); 9676 SSET (safe_charsets, XFASTINT (XCAR (tail)), 0);
9668 CODING_ATTR_SAFE_CHARSETS (attrs) = safe_charsets; 9677 ASET (attrs, coding_attr_safe_charsets, safe_charsets);
9669 9678
9670 CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p]; 9679 ASET (attrs, coding_attr_ascii_compat, args[coding_arg_ascii_compatible_p]);
9671 9680
9672 val = args[coding_arg_decode_translation_table]; 9681 val = args[coding_arg_decode_translation_table];
9673 if (! CHAR_TABLE_P (val) && ! CONSP (val)) 9682 if (! CHAR_TABLE_P (val) && ! CONSP (val))
9674 CHECK_SYMBOL (val); 9683 CHECK_SYMBOL (val);
9675 CODING_ATTR_DECODE_TBL (attrs) = val; 9684 ASET (attrs, coding_attr_decode_tbl, val);
9676 9685
9677 val = args[coding_arg_encode_translation_table]; 9686 val = args[coding_arg_encode_translation_table];
9678 if (! CHAR_TABLE_P (val) && ! CONSP (val)) 9687 if (! CHAR_TABLE_P (val) && ! CONSP (val))
9679 CHECK_SYMBOL (val); 9688 CHECK_SYMBOL (val);
9680 CODING_ATTR_ENCODE_TBL (attrs) = val; 9689 ASET (attrs, coding_attr_encode_tbl, val);
9681 9690
9682 val = args[coding_arg_post_read_conversion]; 9691 val = args[coding_arg_post_read_conversion];
9683 CHECK_SYMBOL (val); 9692 CHECK_SYMBOL (val);
9684 CODING_ATTR_POST_READ (attrs) = val; 9693 ASET (attrs, coding_attr_post_read, val);
9685 9694
9686 val = args[coding_arg_pre_write_conversion]; 9695 val = args[coding_arg_pre_write_conversion];
9687 CHECK_SYMBOL (val); 9696 CHECK_SYMBOL (val);
9688 CODING_ATTR_PRE_WRITE (attrs) = val; 9697 ASET (attrs, coding_attr_pre_write, val);
9689 9698
9690 val = args[coding_arg_default_char]; 9699 val = args[coding_arg_default_char];
9691 if (NILP (val)) 9700 if (NILP (val))
9692 CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' '); 9701 ASET (attrs, coding_attr_default_char, make_number (' '));
9693 else 9702 else
9694 { 9703 {
9695 CHECK_CHARACTER (val); 9704 CHECK_CHARACTER (val);
9696 CODING_ATTR_DEFAULT_CHAR (attrs) = val; 9705 ASET (attrs, coding_attr_default_char, val);
9697 } 9706 }
9698 9707
9699 val = args[coding_arg_for_unibyte]; 9708 val = args[coding_arg_for_unibyte];
9700 CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt; 9709 ASET (attrs, coding_attr_for_unibyte, NILP (val) ? Qnil : Qt);
9701 9710
9702 val = args[coding_arg_plist]; 9711 val = args[coding_arg_plist];
9703 CHECK_LIST (val); 9712 CHECK_LIST (val);
9704 CODING_ATTR_PLIST (attrs) = val; 9713 ASET (attrs, coding_attr_plist, val);
9705 9714
9706 if (EQ (coding_type, Qcharset)) 9715 if (EQ (coding_type, Qcharset))
9707 { 9716 {
@@ -9726,7 +9735,7 @@ usage: (define-coding-system-internal ...) */)
9726 int idx = (dim - 1) * 4; 9735 int idx = (dim - 1) * 4;
9727 9736
9728 if (CHARSET_ASCII_COMPATIBLE_P (charset)) 9737 if (CHARSET_ASCII_COMPATIBLE_P (charset))
9729 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; 9738 ASET (attrs, coding_attr_ascii_compat, Qt);
9730 9739
9731 for (i = charset->code_space[idx]; 9740 for (i = charset->code_space[idx];
9732 i <= charset->code_space[idx + 1]; i++) 9741 i <= charset->code_space[idx + 1]; i++)
@@ -9824,7 +9833,7 @@ usage: (define-coding-system-internal ...) */)
9824 { 9833 {
9825 Lisp_Object bom, endian; 9834 Lisp_Object bom, endian;
9826 9835
9827 CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; 9836 ASET (attrs, coding_attr_ascii_compat, Qnil);
9828 9837
9829 if (nargs < coding_arg_utf16_max) 9838 if (nargs < coding_arg_utf16_max)
9830 goto short_args; 9839 goto short_args;
@@ -9877,7 +9886,7 @@ usage: (define-coding-system-internal ...) */)
9877 CHECK_CHARSET_GET_CHARSET (val, charset); 9886 CHECK_CHARSET_GET_CHARSET (val, charset);
9878 ASET (initial, i, make_number (CHARSET_ID (charset))); 9887 ASET (initial, i, make_number (CHARSET_ID (charset)));
9879 if (i == 0 && CHARSET_ASCII_COMPATIBLE_P (charset)) 9888 if (i == 0 && CHARSET_ASCII_COMPATIBLE_P (charset))
9880 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; 9889 ASET (attrs, coding_attr_ascii_compat, Qt);
9881 } 9890 }
9882 else 9891 else
9883 ASET (initial, i, make_number (-1)); 9892 ASET (initial, i, make_number (-1));
@@ -9938,13 +9947,13 @@ usage: (define-coding-system-internal ...) */)
9938 } 9947 }
9939 if (category != coding_category_iso_8_1 9948 if (category != coding_category_iso_8_1
9940 && category != coding_category_iso_8_2) 9949 && category != coding_category_iso_8_2)
9941 CODING_ATTR_ASCII_COMPAT (attrs) = Qnil; 9950 ASET (attrs, coding_attr_ascii_compat, Qnil);
9942 } 9951 }
9943 else if (EQ (coding_type, Qemacs_mule)) 9952 else if (EQ (coding_type, Qemacs_mule))
9944 { 9953 {
9945 if (EQ (args[coding_arg_charset_list], Qemacs_mule)) 9954 if (EQ (args[coding_arg_charset_list], Qemacs_mule))
9946 ASET (attrs, coding_attr_emacs_mule_full, Qt); 9955 ASET (attrs, coding_attr_emacs_mule_full, Qt);
9947 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; 9956 ASET (attrs, coding_attr_ascii_compat, Qt);
9948 category = coding_category_emacs_mule; 9957 category = coding_category_emacs_mule;
9949 } 9958 }
9950 else if (EQ (coding_type, Qshift_jis)) 9959 else if (EQ (coding_type, Qshift_jis))
@@ -9961,7 +9970,7 @@ usage: (define-coding-system-internal ...) */)
9961 error ("Dimension of charset %s is not one", 9970 error ("Dimension of charset %s is not one",
9962 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); 9971 SDATA (SYMBOL_NAME (CHARSET_NAME (charset))));
9963 if (CHARSET_ASCII_COMPATIBLE_P (charset)) 9972 if (CHARSET_ASCII_COMPATIBLE_P (charset))
9964 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; 9973 ASET (attrs, coding_attr_ascii_compat, Qt);
9965 9974
9966 charset_list = XCDR (charset_list); 9975 charset_list = XCDR (charset_list);
9967 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); 9976 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));
@@ -9999,7 +10008,7 @@ usage: (define-coding-system-internal ...) */)
9999 error ("Dimension of charset %s is not one", 10008 error ("Dimension of charset %s is not one",
10000 SDATA (SYMBOL_NAME (CHARSET_NAME (charset)))); 10009 SDATA (SYMBOL_NAME (CHARSET_NAME (charset))));
10001 if (CHARSET_ASCII_COMPATIBLE_P (charset)) 10010 if (CHARSET_ASCII_COMPATIBLE_P (charset))
10002 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; 10011 ASET (attrs, coding_attr_ascii_compat, Qt);
10003 10012
10004 charset_list = XCDR (charset_list); 10013 charset_list = XCDR (charset_list);
10005 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list))); 10014 charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));
@@ -10013,7 +10022,7 @@ usage: (define-coding-system-internal ...) */)
10013 else if (EQ (coding_type, Qraw_text)) 10022 else if (EQ (coding_type, Qraw_text))
10014 { 10023 {
10015 category = coding_category_raw_text; 10024 category = coding_category_raw_text;
10016 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; 10025 ASET (attrs, coding_attr_ascii_compat, Qt);
10017 } 10026 }
10018 else if (EQ (coding_type, Qutf_8)) 10027 else if (EQ (coding_type, Qutf_8))
10019 { 10028 {
@@ -10033,7 +10042,7 @@ usage: (define-coding-system-internal ...) */)
10033 } 10042 }
10034 ASET (attrs, coding_attr_utf_bom, bom); 10043 ASET (attrs, coding_attr_utf_bom, bom);
10035 if (NILP (bom)) 10044 if (NILP (bom))
10036 CODING_ATTR_ASCII_COMPAT (attrs) = Qt; 10045 ASET (attrs, coding_attr_ascii_compat, Qt);
10037 10046
10038 category = (CONSP (bom) ? coding_category_utf_8_auto 10047 category = (CONSP (bom) ? coding_category_utf_8_auto
10039 : NILP (bom) ? coding_category_utf_8_nosig 10048 : NILP (bom) ? coding_category_utf_8_nosig
@@ -10045,14 +10054,15 @@ usage: (define-coding-system-internal ...) */)
10045 error ("Invalid coding system type: %s", 10054 error ("Invalid coding system type: %s",
10046 SDATA (SYMBOL_NAME (coding_type))); 10055 SDATA (SYMBOL_NAME (coding_type)));
10047 10056
10048 CODING_ATTR_CATEGORY (attrs) = make_number (category); 10057 ASET (attrs, coding_attr_category, make_number (category));
10049 CODING_ATTR_PLIST (attrs) 10058 ASET (attrs, coding_attr_plist,
10050 = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), 10059 Fcons (QCcategory,
10051 CODING_ATTR_PLIST (attrs))); 10060 Fcons (AREF (Vcoding_category_table, category),
10052 CODING_ATTR_PLIST (attrs) 10061 CODING_ATTR_PLIST (attrs))));
10053 = Fcons (QCascii_compatible_p, 10062 ASET (attrs, coding_attr_plist,
10054 Fcons (CODING_ATTR_ASCII_COMPAT (attrs), 10063 Fcons (QCascii_compatible_p,
10055 CODING_ATTR_PLIST (attrs))); 10064 Fcons (CODING_ATTR_ASCII_COMPAT (attrs),
10065 CODING_ATTR_PLIST (attrs))));
10056 10066
10057 eol_type = args[coding_arg_eol_type]; 10067 eol_type = args[coding_arg_eol_type];
10058 if (! NILP (eol_type) 10068 if (! NILP (eol_type)
@@ -10126,7 +10136,7 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put,
10126 { 10136 {
10127 if (! STRINGP (val)) 10137 if (! STRINGP (val))
10128 CHECK_CHARACTER (val); 10138 CHECK_CHARACTER (val);
10129 CODING_ATTR_MNEMONIC (attrs) = val; 10139 ASET (attrs, coding_attr_mnemonic, val);
10130 } 10140 }
10131 else if (EQ (prop, QCdefault_char)) 10141 else if (EQ (prop, QCdefault_char))
10132 { 10142 {
@@ -10134,37 +10144,37 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put,
10134 val = make_number (' '); 10144 val = make_number (' ');
10135 else 10145 else
10136 CHECK_CHARACTER (val); 10146 CHECK_CHARACTER (val);
10137 CODING_ATTR_DEFAULT_CHAR (attrs) = val; 10147 ASET (attrs, coding_attr_default_char, val);
10138 } 10148 }
10139 else if (EQ (prop, QCdecode_translation_table)) 10149 else if (EQ (prop, QCdecode_translation_table))
10140 { 10150 {
10141 if (! CHAR_TABLE_P (val) && ! CONSP (val)) 10151 if (! CHAR_TABLE_P (val) && ! CONSP (val))
10142 CHECK_SYMBOL (val); 10152 CHECK_SYMBOL (val);
10143 CODING_ATTR_DECODE_TBL (attrs) = val; 10153 ASET (attrs, coding_attr_decode_tbl, val);
10144 } 10154 }
10145 else if (EQ (prop, QCencode_translation_table)) 10155 else if (EQ (prop, QCencode_translation_table))
10146 { 10156 {
10147 if (! CHAR_TABLE_P (val) && ! CONSP (val)) 10157 if (! CHAR_TABLE_P (val) && ! CONSP (val))
10148 CHECK_SYMBOL (val); 10158 CHECK_SYMBOL (val);
10149 CODING_ATTR_ENCODE_TBL (attrs) = val; 10159 ASET (attrs, coding_attr_encode_tbl, val);
10150 } 10160 }
10151 else if (EQ (prop, QCpost_read_conversion)) 10161 else if (EQ (prop, QCpost_read_conversion))
10152 { 10162 {
10153 CHECK_SYMBOL (val); 10163 CHECK_SYMBOL (val);
10154 CODING_ATTR_POST_READ (attrs) = val; 10164 ASET (attrs, coding_attr_post_read, val);
10155 } 10165 }
10156 else if (EQ (prop, QCpre_write_conversion)) 10166 else if (EQ (prop, QCpre_write_conversion))
10157 { 10167 {
10158 CHECK_SYMBOL (val); 10168 CHECK_SYMBOL (val);
10159 CODING_ATTR_PRE_WRITE (attrs) = val; 10169 ASET (attrs, coding_attr_pre_write, val);
10160 } 10170 }
10161 else if (EQ (prop, QCascii_compatible_p)) 10171 else if (EQ (prop, QCascii_compatible_p))
10162 { 10172 {
10163 CODING_ATTR_ASCII_COMPAT (attrs) = val; 10173 ASET (attrs, coding_attr_ascii_compat, val);
10164 } 10174 }
10165 10175
10166 CODING_ATTR_PLIST (attrs) 10176 ASET (attrs, coding_attr_plist,
10167 = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); 10177 Fplist_put (CODING_ATTR_PLIST (attrs), prop, val));
10168 return val; 10178 return val;
10169} 10179}
10170 10180