diff options
| author | Kenichi Handa | 2004-01-27 02:21:37 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-01-27 02:21:37 +0000 |
| commit | a6f87d34c87c16072f46cb377a0bd8f13f57d021 (patch) | |
| tree | 9cf523e6efa2b5093aeed49139633bc2cfa76eb0 /src/coding.c | |
| parent | 111daccfb57e6598f3364d1d1c6ee74edabc709d (diff) | |
| download | emacs-a6f87d34c87c16072f46cb377a0bd8f13f57d021.tar.gz emacs-a6f87d34c87c16072f46cb377a0bd8f13f57d021.zip | |
(QCmnemonic, QCdefalut_char)
(QCdecode_translation_table, QCencode_translation_table)
(QCpost_read_conversion, QCpre_write_conversion): New variables.
(get_translation_table): Return a list of translation tables if
necessary.
(decode_coding): Call get_translation_table with ENCODEP 0.
(char_encodable_p): If translation_table is non-nil, always call
translate_char.
(Fdefine_coding_system_internal): Accept list of translation
tables as :encode-translation-table and :decode-translation-table.
(Fcoding_system_put): New function.
(syms_of_coding): Declare new symbols. Defsubr
Scoding_system_put.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 101 |
1 files changed, 89 insertions, 12 deletions
diff --git a/src/coding.c b/src/coding.c index e32859aed14..4fcc48e3533 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -311,7 +311,9 @@ Lisp_Object Qcharset, Qiso_2022, Qutf_8, Qutf_16, Qshift_jis, Qbig5; | |||
| 311 | Lisp_Object Qbig, Qlittle; | 311 | Lisp_Object Qbig, Qlittle; |
| 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; | 314 | Lisp_Object QCcategory, QCmnemonic, QCdefalut_char; |
| 315 | Lisp_Object QCdecode_translation_table, QCencode_translation_table; | ||
| 316 | Lisp_Object QCpost_read_conversion, QCpre_write_conversion; | ||
| 315 | 317 | ||
| 316 | extern Lisp_Object Qinsert_file_contents, Qwrite_region; | 318 | extern Lisp_Object Qinsert_file_contents, Qwrite_region; |
| 317 | Lisp_Object Qcall_process, Qcall_process_region, Qprocess_argument; | 319 | Lisp_Object Qcall_process, Qcall_process_region, Qprocess_argument; |
| @@ -5484,8 +5486,9 @@ decode_eol (coding) | |||
| 5484 | } | 5486 | } |
| 5485 | 5487 | ||
| 5486 | 5488 | ||
| 5487 | /* Return a translation table from coding system attribute vector ATTRS | 5489 | /* Return a translation table (or list of them) from coding system |
| 5488 | for encoding (ENCODEP is nonzero) or decoding (ENCODEP is zeor). */ | 5490 | attribute vector ATTRS for encoding (ENCODEP is nonzero) or |
| 5491 | decoding (ENCODEP is zero). */ | ||
| 5489 | 5492 | ||
| 5490 | static INLINE | 5493 | static INLINE |
| 5491 | get_translation_table (attrs, encodep) | 5494 | get_translation_table (attrs, encodep) |
| @@ -5498,12 +5501,26 @@ get_translation_table (attrs, encodep) | |||
| 5498 | else | 5501 | else |
| 5499 | translation_table = CODING_ATTR_DECODE_TBL (attrs), | 5502 | translation_table = CODING_ATTR_DECODE_TBL (attrs), |
| 5500 | standard = Vstandard_translation_table_for_decode; | 5503 | standard = Vstandard_translation_table_for_decode; |
| 5501 | if (! NILP (translation_table) && SYMBOLP (translation_table)) | ||
| 5502 | translation_table = Fget (translation_table, Qtranslation_table); | ||
| 5503 | if (NILP (translation_table)) | 5504 | if (NILP (translation_table)) |
| 5504 | translation_table = standard; | 5505 | return standard; |
| 5505 | if (! CHAR_TABLE_P (translation_table)) | 5506 | if (SYMBOLP (translation_table)) |
| 5506 | translation_table = Qnil; | 5507 | translation_table = Fget (translation_table, Qtranslation_table); |
| 5508 | else if (CONSP (translation_table)) | ||
| 5509 | { | ||
| 5510 | Lisp_Object val; | ||
| 5511 | |||
| 5512 | translation_table = Fcopy_sequence (translation_table); | ||
| 5513 | for (val = translation_table; CONSP (val); val = XCDR (val)) | ||
| 5514 | if (SYMBOLP (XCAR (val))) | ||
| 5515 | XSETCAR (val, Fget (XCAR (val), Qtranslation_table)); | ||
| 5516 | } | ||
| 5517 | if (! NILP (standard)) | ||
| 5518 | { | ||
| 5519 | if (CONSP (translation_table)) | ||
| 5520 | translation_table = nconc2 (translation_table, Fcons (standard, Qnil)); | ||
| 5521 | else | ||
| 5522 | translation_table = Fcons (translation_table, Fcons (standard, Qnil)); | ||
| 5523 | } | ||
| 5507 | return translation_table; | 5524 | return translation_table; |
| 5508 | } | 5525 | } |
| 5509 | 5526 | ||
| @@ -5892,7 +5909,7 @@ decode_coding (coding) | |||
| 5892 | ALLOC_CONVERSION_WORK_AREA (coding); | 5909 | ALLOC_CONVERSION_WORK_AREA (coding); |
| 5893 | 5910 | ||
| 5894 | attrs = CODING_ID_ATTRS (coding->id); | 5911 | attrs = CODING_ID_ATTRS (coding->id); |
| 5895 | translation_table = get_translation_table (attrs, 1); | 5912 | translation_table = get_translation_table (attrs, 0); |
| 5896 | 5913 | ||
| 5897 | do | 5914 | do |
| 5898 | { | 5915 | { |
| @@ -7099,7 +7116,7 @@ char_encodable_p (c, attrs) | |||
| 7099 | Lisp_Object translation_table; | 7116 | Lisp_Object translation_table; |
| 7100 | 7117 | ||
| 7101 | translation_table = CODING_ATTR_TRANS_TBL (attrs); | 7118 | translation_table = CODING_ATTR_TRANS_TBL (attrs); |
| 7102 | if (CHAR_TABLE_P (translation_table)) | 7119 | if (! NILP (translation_table)) |
| 7103 | c = translate_char (translation_table, c); | 7120 | c = translate_char (translation_table, c); |
| 7104 | for (tail = CODING_ATTR_CHARSET_LIST (attrs); | 7121 | for (tail = CODING_ATTR_CHARSET_LIST (attrs); |
| 7105 | CONSP (tail); tail = XCDR (tail)) | 7122 | CONSP (tail); tail = XCDR (tail)) |
| @@ -8166,12 +8183,12 @@ usage: (define-coding-system-internal ...) */) | |||
| 8166 | CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p]; | 8183 | CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p]; |
| 8167 | 8184 | ||
| 8168 | val = args[coding_arg_decode_translation_table]; | 8185 | val = args[coding_arg_decode_translation_table]; |
| 8169 | if (! CHAR_TABLE_P (val)) | 8186 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
| 8170 | CHECK_SYMBOL (val); | 8187 | CHECK_SYMBOL (val); |
| 8171 | CODING_ATTR_DECODE_TBL (attrs) = val; | 8188 | CODING_ATTR_DECODE_TBL (attrs) = val; |
| 8172 | 8189 | ||
| 8173 | val = args[coding_arg_encode_translation_table]; | 8190 | val = args[coding_arg_encode_translation_table]; |
| 8174 | if (! CHAR_TABLE_P (val)) | 8191 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) |
| 8175 | CHECK_SYMBOL (val); | 8192 | CHECK_SYMBOL (val); |
| 8176 | CODING_ATTR_ENCODE_TBL (attrs) = val; | 8193 | CODING_ATTR_ENCODE_TBL (attrs) = val; |
| 8177 | 8194 | ||
| @@ -8581,6 +8598,59 @@ usage: (define-coding-system-internal ...) */) | |||
| 8581 | } | 8598 | } |
| 8582 | 8599 | ||
| 8583 | 8600 | ||
| 8601 | DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, | ||
| 8602 | 3, 3, 0, | ||
| 8603 | doc: /* Change value in CODING-SYSTEM's property list PROP to VAL. */) | ||
| 8604 | (coding_system, prop, val) | ||
| 8605 | Lisp_Object coding_system, prop, val; | ||
| 8606 | { | ||
| 8607 | Lisp_Object spec, attrs, plist; | ||
| 8608 | |||
| 8609 | CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec); | ||
| 8610 | attrs = AREF (spec, 0); | ||
| 8611 | if (EQ (prop, QCmnemonic)) | ||
| 8612 | { | ||
| 8613 | if (! STRINGP (val)) | ||
| 8614 | CHECK_CHARACTER (val); | ||
| 8615 | CODING_ATTR_MNEMONIC (attrs) = val; | ||
| 8616 | } | ||
| 8617 | else if (EQ (prop, QCdefalut_char)) | ||
| 8618 | { | ||
| 8619 | if (NILP (val)) | ||
| 8620 | val = make_number (' '); | ||
| 8621 | else | ||
| 8622 | CHECK_CHARACTER (val); | ||
| 8623 | CODING_ATTR_DEFAULT_CHAR (attrs) = val; | ||
| 8624 | } | ||
| 8625 | else if (EQ (prop, QCdecode_translation_table)) | ||
| 8626 | { | ||
| 8627 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) | ||
| 8628 | CHECK_SYMBOL (val); | ||
| 8629 | CODING_ATTR_DECODE_TBL (attrs) = val; | ||
| 8630 | } | ||
| 8631 | else if (EQ (prop, QCencode_translation_table)) | ||
| 8632 | { | ||
| 8633 | if (! CHAR_TABLE_P (val) && ! CONSP (val)) | ||
| 8634 | CHECK_SYMBOL (val); | ||
| 8635 | CODING_ATTR_ENCODE_TBL (attrs) = val; | ||
| 8636 | } | ||
| 8637 | else if (EQ (prop, QCpost_read_conversion)) | ||
| 8638 | { | ||
| 8639 | CHECK_SYMBOL (val); | ||
| 8640 | CODING_ATTR_POST_READ (attrs) = val; | ||
| 8641 | } | ||
| 8642 | else if (EQ (prop, QCpre_write_conversion)) | ||
| 8643 | { | ||
| 8644 | CHECK_SYMBOL (val); | ||
| 8645 | CODING_ATTR_PRE_WRITE (attrs) = val; | ||
| 8646 | } | ||
| 8647 | |||
| 8648 | CODING_ATTR_PLIST (attrs) | ||
| 8649 | = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); | ||
| 8650 | return val; | ||
| 8651 | } | ||
| 8652 | |||
| 8653 | |||
| 8584 | DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, | 8654 | DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias, |
| 8585 | Sdefine_coding_system_alias, 2, 2, 0, | 8655 | Sdefine_coding_system_alias, 2, 2, 0, |
| 8586 | doc: /* Define ALIAS as an alias for CODING-SYSTEM. */) | 8656 | doc: /* Define ALIAS as an alias for CODING-SYSTEM. */) |
| @@ -8843,6 +8913,12 @@ syms_of_coding () | |||
| 8843 | DEFSYM (Qemacs_mule, "emacs-mule"); | 8913 | DEFSYM (Qemacs_mule, "emacs-mule"); |
| 8844 | 8914 | ||
| 8845 | DEFSYM (QCcategory, ":category"); | 8915 | DEFSYM (QCcategory, ":category"); |
| 8916 | DEFSYM (QCmnemonic, ":mnemonic"); | ||
| 8917 | DEFSYM (QCdefalut_char, ":default-char"); | ||
| 8918 | DEFSYM (QCdecode_translation_table, ":decode-translation-table"); | ||
| 8919 | DEFSYM (QCencode_translation_table, ":encode-translation-table"); | ||
| 8920 | DEFSYM (QCpost_read_conversion, ":post-read-conversion"); | ||
| 8921 | DEFSYM (QCpre_write_conversion, ":pre-write-conversion"); | ||
| 8846 | 8922 | ||
| 8847 | Vcoding_category_table | 8923 | Vcoding_category_table |
| 8848 | = Fmake_vector (make_number (coding_category_max), Qnil); | 8924 | = Fmake_vector (make_number (coding_category_max), Qnil); |
| @@ -8920,6 +8996,7 @@ syms_of_coding () | |||
| 8920 | defsubr (&Sset_coding_system_priority); | 8996 | defsubr (&Sset_coding_system_priority); |
| 8921 | defsubr (&Sdefine_coding_system_internal); | 8997 | defsubr (&Sdefine_coding_system_internal); |
| 8922 | defsubr (&Sdefine_coding_system_alias); | 8998 | defsubr (&Sdefine_coding_system_alias); |
| 8999 | defsubr (&Scoding_system_put); | ||
| 8923 | defsubr (&Scoding_system_base); | 9000 | defsubr (&Scoding_system_base); |
| 8924 | defsubr (&Scoding_system_plist); | 9001 | defsubr (&Scoding_system_plist); |
| 8925 | defsubr (&Scoding_system_aliases); | 9002 | defsubr (&Scoding_system_aliases); |