Mercurial > emacs
comparison src/coding.c @ 90214:460ee00505d5
(QCascii_compatible_p): New variable.
(syms_of_coding): Initialize it.
(ONE_MORE_BYTE): Decrement `src' before calling string_char.
(ONE_MORE_BYTE_NO_CHECK): Likewise.
(record_conversion_result): Add `default:' case.
(coding_charset_list): Delete unused variable `coding_type'.
(Fdefine_coding_system_internal): Add `ascii-compatible-p'
property in the plist of the coding system.
(Fcoding_system_put): Check QCascii_compatible_p.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Fri, 29 Jul 2005 06:20:30 +0000 |
| parents | fbb2bea03df9 |
| children | 2d92f5c9d6ae |
comparison
equal
deleted
inserted
replaced
| 90213:90706d6433c9 | 90214:460ee00505d5 |
|---|---|
| 312 Lisp_Object Qcoding_system_history; | 312 Lisp_Object Qcoding_system_history; |
| 313 Lisp_Object Qvalid_codes; | 313 Lisp_Object Qvalid_codes; |
| 314 Lisp_Object QCcategory, QCmnemonic, QCdefalut_char; | 314 Lisp_Object QCcategory, QCmnemonic, QCdefalut_char; |
| 315 Lisp_Object QCdecode_translation_table, QCencode_translation_table; | 315 Lisp_Object QCdecode_translation_table, QCencode_translation_table; |
| 316 Lisp_Object QCpost_read_conversion, QCpre_write_conversion; | 316 Lisp_Object QCpost_read_conversion, QCpre_write_conversion; |
| 317 Lisp_Object QCascii_compatible_p; | |
| 317 | 318 |
| 318 extern Lisp_Object Qinsert_file_contents, Qwrite_region; | 319 extern Lisp_Object Qinsert_file_contents, Qwrite_region; |
| 319 Lisp_Object Qcall_process, Qcall_process_region; | 320 Lisp_Object Qcall_process, Qcall_process_region; |
| 320 Lisp_Object Qstart_process, Qopen_network_stream; | 321 Lisp_Object Qstart_process, Qopen_network_stream; |
| 321 Lisp_Object Qtarget_idx; | 322 Lisp_Object Qtarget_idx; |
| 704 { \ | 705 { \ |
| 705 if ((c & 0xFE) == 0xC0) \ | 706 if ((c & 0xFE) == 0xC0) \ |
| 706 c = ((c & 1) << 6) | *src++; \ | 707 c = ((c & 1) << 6) | *src++; \ |
| 707 else \ | 708 else \ |
| 708 { \ | 709 { \ |
| 709 c = - string_char (--src, &src, NULL); \ | 710 src--; \ |
| 711 c = - string_char (src, &src, NULL); \ | |
| 710 record_conversion_result \ | 712 record_conversion_result \ |
| 711 (coding, CODING_RESULT_INVALID_SRC); \ | 713 (coding, CODING_RESULT_INVALID_SRC); \ |
| 712 } \ | 714 } \ |
| 713 } \ | 715 } \ |
| 714 consumed_chars++; \ | 716 consumed_chars++; \ |
| 722 { \ | 724 { \ |
| 723 if ((c & 0xFE) == 0xC0) \ | 725 if ((c & 0xFE) == 0xC0) \ |
| 724 c = ((c & 1) << 6) | *src++; \ | 726 c = ((c & 1) << 6) | *src++; \ |
| 725 else \ | 727 else \ |
| 726 { \ | 728 { \ |
| 727 c = - string_char (--src, &src, NULL); \ | 729 src--; \ |
| 730 c = - string_char (src, &src, NULL); \ | |
| 728 record_conversion_result \ | 731 record_conversion_result \ |
| 729 (coding, CODING_RESULT_INVALID_SRC); \ | 732 (coding, CODING_RESULT_INVALID_SRC); \ |
| 730 } \ | 733 } \ |
| 731 } \ | 734 } \ |
| 732 consumed_chars++; \ | 735 consumed_chars++; \ |
| 916 Vlast_code_conversion_error = Qinterrupted; | 919 Vlast_code_conversion_error = Qinterrupted; |
| 917 break; | 920 break; |
| 918 case CODING_RESULT_INSUFFICIENT_MEM: | 921 case CODING_RESULT_INSUFFICIENT_MEM: |
| 919 Vlast_code_conversion_error = Qinsufficient_memory; | 922 Vlast_code_conversion_error = Qinsufficient_memory; |
| 920 break; | 923 break; |
| 924 default: | |
| 925 Vlast_code_conversion_error = intern ("Unknown error"); | |
| 921 } | 926 } |
| 922 } | 927 } |
| 923 | 928 |
| 924 #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ | 929 #define CODING_DECODE_CHAR(coding, src, src_base, src_end, charset, code, c) \ |
| 925 do { \ | 930 do { \ |
| 5089 | 5094 |
| 5090 Lisp_Object | 5095 Lisp_Object |
| 5091 coding_charset_list (coding) | 5096 coding_charset_list (coding) |
| 5092 struct coding_system *coding; | 5097 struct coding_system *coding; |
| 5093 { | 5098 { |
| 5094 Lisp_Object attrs, charset_list, coding_type; | 5099 Lisp_Object attrs, charset_list; |
| 5095 | 5100 |
| 5096 CODING_GET_INFO (coding, attrs, charset_list); | 5101 CODING_GET_INFO (coding, attrs, charset_list); |
| 5097 if (EQ (CODING_ATTR_TYPE (attrs), Qiso_2022)) | 5102 if (EQ (CODING_ATTR_TYPE (attrs), Qiso_2022)) |
| 5098 { | 5103 { |
| 5099 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); | 5104 int flags = XINT (AREF (attrs, coding_attr_iso_flags)); |
| 8869 | 8874 |
| 8870 CODING_ATTR_CATEGORY (attrs) = make_number (category); | 8875 CODING_ATTR_CATEGORY (attrs) = make_number (category); |
| 8871 CODING_ATTR_PLIST (attrs) | 8876 CODING_ATTR_PLIST (attrs) |
| 8872 = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), | 8877 = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), |
| 8873 CODING_ATTR_PLIST (attrs))); | 8878 CODING_ATTR_PLIST (attrs))); |
| 8879 CODING_ATTR_PLIST (attrs) | |
| 8880 = Fcons (QCascii_compatible_p, | |
| 8881 Fcons (CODING_ATTR_ASCII_COMPAT (attrs), | |
| 8882 CODING_ATTR_PLIST (attrs))); | |
| 8874 | 8883 |
| 8875 eol_type = args[coding_arg_eol_type]; | 8884 eol_type = args[coding_arg_eol_type]; |
| 8876 if (! NILP (eol_type) | 8885 if (! NILP (eol_type) |
| 8877 && ! EQ (eol_type, Qunix) | 8886 && ! EQ (eol_type, Qunix) |
| 8878 && ! EQ (eol_type, Qdos) | 8887 && ! EQ (eol_type, Qdos) |
| 8969 } | 8978 } |
| 8970 else if (EQ (prop, QCpre_write_conversion)) | 8979 else if (EQ (prop, QCpre_write_conversion)) |
| 8971 { | 8980 { |
| 8972 CHECK_SYMBOL (val); | 8981 CHECK_SYMBOL (val); |
| 8973 CODING_ATTR_PRE_WRITE (attrs) = val; | 8982 CODING_ATTR_PRE_WRITE (attrs) = val; |
| 8983 } | |
| 8984 else if (EQ (prop, QCascii_compatible_p)) | |
| 8985 { | |
| 8986 CODING_ATTR_ASCII_COMPAT (attrs) = val; | |
| 8974 } | 8987 } |
| 8975 | 8988 |
| 8976 CODING_ATTR_PLIST (attrs) | 8989 CODING_ATTR_PLIST (attrs) |
| 8977 = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); | 8990 = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); |
| 8978 return val; | 8991 return val; |
| 9245 DEFSYM (QCdefalut_char, ":default-char"); | 9258 DEFSYM (QCdefalut_char, ":default-char"); |
| 9246 DEFSYM (QCdecode_translation_table, ":decode-translation-table"); | 9259 DEFSYM (QCdecode_translation_table, ":decode-translation-table"); |
| 9247 DEFSYM (QCencode_translation_table, ":encode-translation-table"); | 9260 DEFSYM (QCencode_translation_table, ":encode-translation-table"); |
| 9248 DEFSYM (QCpost_read_conversion, ":post-read-conversion"); | 9261 DEFSYM (QCpost_read_conversion, ":post-read-conversion"); |
| 9249 DEFSYM (QCpre_write_conversion, ":pre-write-conversion"); | 9262 DEFSYM (QCpre_write_conversion, ":pre-write-conversion"); |
| 9263 DEFSYM (QCascii_compatible_p, ":ascii-compatible-p"); | |
| 9250 | 9264 |
| 9251 Vcoding_category_table | 9265 Vcoding_category_table |
| 9252 = Fmake_vector (make_number (coding_category_max), Qnil); | 9266 = Fmake_vector (make_number (coding_category_max), Qnil); |
| 9253 staticpro (&Vcoding_category_table); | 9267 staticpro (&Vcoding_category_table); |
| 9254 /* Followings are target of code detection. */ | 9268 /* Followings are target of code detection. */ |
| 9633 | 9647 |
| 9634 plist[1] = args[coding_arg_name] = Qundecided; | 9648 plist[1] = args[coding_arg_name] = Qundecided; |
| 9635 plist[3] = args[coding_arg_mnemonic] = make_number ('-'); | 9649 plist[3] = args[coding_arg_mnemonic] = make_number ('-'); |
| 9636 plist[5] = args[coding_arg_coding_type] = Qundecided; | 9650 plist[5] = args[coding_arg_coding_type] = Qundecided; |
| 9637 /* This is already set. | 9651 /* This is already set. |
| 9638 /*plist[7] = args[coding_arg_ascii_compatible_p] = Qt;*/ | 9652 plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */ |
| 9639 plist[8] = intern (":charset-list"); | 9653 plist[8] = intern (":charset-list"); |
| 9640 plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); | 9654 plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); |
| 9641 plist[11] = args[coding_arg_for_unibyte] = Qnil; | 9655 plist[11] = args[coding_arg_for_unibyte] = Qnil; |
| 9642 plist[13] = build_string ("No conversion on encoding, automatic conversion on decoding."); | 9656 plist[13] = build_string ("No conversion on encoding, automatic conversion on decoding."); |
| 9643 plist[15] = args[coding_arg_eol_type] = Qnil; | 9657 plist[15] = args[coding_arg_eol_type] = Qnil; |
