diff options
| author | Kenichi Handa | 1997-07-07 00:59:44 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1997-07-07 00:59:44 +0000 |
| commit | 9ce27fde6aa0eb078153dd5ac37992bf1722a669 (patch) | |
| tree | 9eebb9b8fa3b6e294d66d53b173371ac954413de | |
| parent | 3f356e65a03477633a87644d1c3efcb2cfd76905 (diff) | |
| download | emacs-9ce27fde6aa0eb078153dd5ac37992bf1722a669.tar.gz emacs-9ce27fde6aa0eb078153dd5ac37992bf1722a669.zip | |
(Qemacs_mule, inhibit_eol_conversion): New variables.
(setup_coding_system): If inhibit_eol_conversion is 0, set
coding->eol_type to CODING_EOL_LF.
(syms_of_coding): Initialize and staticpro Qemacs_mule. Change
error-message property of coding-system-error. Declare
inhibit-eol-conversion as Lisp variable.
(system_eol_type): New variable.
(init_coding_once): Initialize it.
(ENCODE_SJIS_BIG5_CHARACTER): Bug in encoding a BIG5 character
fixed.
| -rw-r--r-- | src/coding.c | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/src/coding.c b/src/coding.c index 75e4980ec1b..1e618044ccd 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -260,10 +260,17 @@ int eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac; | |||
| 260 | decided. */ | 260 | decided. */ |
| 261 | int eol_mnemonic_undecided; | 261 | int eol_mnemonic_undecided; |
| 262 | 262 | ||
| 263 | /* Format of end-of-line decided by system. This is CODING_EOL_LF on | ||
| 264 | Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac. */ | ||
| 265 | int system_eol_type; | ||
| 266 | |||
| 263 | #ifdef emacs | 267 | #ifdef emacs |
| 264 | 268 | ||
| 265 | Lisp_Object Qcoding_system_spec, Qcoding_system_p, Qcoding_system_error; | 269 | Lisp_Object Qcoding_system_spec, Qcoding_system_p, Qcoding_system_error; |
| 266 | 270 | ||
| 271 | /* Coding system emacs-mule is for converting only end-of-line format. */ | ||
| 272 | Lisp_Object Qemacs_mule; | ||
| 273 | |||
| 267 | /* Coding-systems are handed between Emacs Lisp programs and C internal | 274 | /* Coding-systems are handed between Emacs Lisp programs and C internal |
| 268 | routines by the following three variables. */ | 275 | routines by the following three variables. */ |
| 269 | /* Coding-system for reading files and receiving data from process. */ | 276 | /* Coding-system for reading files and receiving data from process. */ |
| @@ -273,6 +280,9 @@ Lisp_Object Vcoding_system_for_write; | |||
| 273 | /* Coding-system actually used in the latest I/O. */ | 280 | /* Coding-system actually used in the latest I/O. */ |
| 274 | Lisp_Object Vlast_coding_system_used; | 281 | Lisp_Object Vlast_coding_system_used; |
| 275 | 282 | ||
| 283 | /* Flag to inhibit code conversion of end-of-line format. */ | ||
| 284 | int inhibit_eol_conversion; | ||
| 285 | |||
| 276 | /* Coding-system of what terminal accept for displaying. */ | 286 | /* Coding-system of what terminal accept for displaying. */ |
| 277 | struct coding_system terminal_coding; | 287 | struct coding_system terminal_coding; |
| 278 | 288 | ||
| @@ -1663,7 +1673,7 @@ encode_coding_iso2022 (coding, source, destination, | |||
| 1663 | { \ | 1673 | { \ |
| 1664 | unsigned char b1, b2; \ | 1674 | unsigned char b1, b2; \ |
| 1665 | \ | 1675 | \ |
| 1666 | ENCODE_BIG5 (c1, c2, c3, b1, b2); \ | 1676 | ENCODE_BIG5 (charset_alt, c1, c2, b1, b2); \ |
| 1667 | *dst++ = b1, *dst++ = b2; \ | 1677 | *dst++ = b1, *dst++ = b2; \ |
| 1668 | } \ | 1678 | } \ |
| 1669 | else \ | 1679 | else \ |
| @@ -2183,7 +2193,7 @@ setup_coding_system (coding_system, coding) | |||
| 2183 | if (NILP (coding->pre_write_conversion)) | 2193 | if (NILP (coding->pre_write_conversion)) |
| 2184 | coding->pre_write_conversion = Fget (coding_system, | 2194 | coding->pre_write_conversion = Fget (coding_system, |
| 2185 | Qpre_write_conversion); | 2195 | Qpre_write_conversion); |
| 2186 | if (NILP (eol_type)) | 2196 | if (!inhibit_eol_conversion && NILP (eol_type)) |
| 2187 | eol_type = Fget (coding_system, Qeol_type); | 2197 | eol_type = Fget (coding_system, Qeol_type); |
| 2188 | 2198 | ||
| 2189 | if (NILP (coding->character_unification_table_for_decode)) | 2199 | if (NILP (coding->character_unification_table_for_decode)) |
| @@ -3469,10 +3479,10 @@ DEFUN ("keyboard-coding-system", | |||
| 3469 | DEFUN ("find-operation-coding-system", Ffind_operation_coding_system, | 3479 | DEFUN ("find-operation-coding-system", Ffind_operation_coding_system, |
| 3470 | Sfind_operation_coding_system, 1, MANY, 0, | 3480 | Sfind_operation_coding_system, 1, MANY, 0, |
| 3471 | "Choose a coding system for an operation based on the target name.\n\ | 3481 | "Choose a coding system for an operation based on the target name.\n\ |
| 3472 | The value names a pair of coding systems: (ENCODING-SYSTEM DECODING-SYSTEM).\n\ | 3482 | The value names a pair of coding systems: (DECODING-SYSTEM ENCODING-SYSTEM).\n\ |
| 3473 | ENCODING-SYSTEM is the coding system to use for encoding\n\ | 3483 | DECODING-SYSTEM is the coding system to use for decoding\n\ |
| 3474 | \(in case OPERATION does encoding), and DECODING-SYSTEM is the coding system\n\ | 3484 | \(in case OPERATION does decoding), and ENCODING-SYSTEM is the coding system\n\ |
| 3475 | for decoding (in case OPERATION does decoding).\n\ | 3485 | for encoding (in case OPERATION does encoding).\n\ |
| 3476 | \n\ | 3486 | \n\ |
| 3477 | The first argument OPERATION specifies an I/O primitive:\n\ | 3487 | The first argument OPERATION specifies an I/O primitive:\n\ |
| 3478 | For file I/O, `insert-file-contents' or `write-region'.\n\ | 3488 | For file I/O, `insert-file-contents' or `write-region'.\n\ |
| @@ -3495,7 +3505,7 @@ or `network-coding-system-alist' depending on OPERATION.\n\ | |||
| 3495 | They may specify a coding system, a cons of coding systems,\n\ | 3505 | They may specify a coding system, a cons of coding systems,\n\ |
| 3496 | or a function symbol to call.\n\ | 3506 | or a function symbol to call.\n\ |
| 3497 | In the last case, we call the function with one argument,\n\ | 3507 | In the last case, we call the function with one argument,\n\ |
| 3498 | which is a list of all the arguments given to `find-coding-system'.") | 3508 | which is a list of all the arguments given to this function.") |
| 3499 | (nargs, args) | 3509 | (nargs, args) |
| 3500 | int nargs; | 3510 | int nargs; |
| 3501 | Lisp_Object *args; | 3511 | Lisp_Object *args; |
| @@ -3601,6 +3611,12 @@ init_coding_once () | |||
| 3601 | 3611 | ||
| 3602 | setup_coding_system (Qnil, &keyboard_coding); | 3612 | setup_coding_system (Qnil, &keyboard_coding); |
| 3603 | setup_coding_system (Qnil, &terminal_coding); | 3613 | setup_coding_system (Qnil, &terminal_coding); |
| 3614 | |||
| 3615 | #if defined (MSDOS) || defined (WINDOWSNT) | ||
| 3616 | system_eol_type = CODING_EOL_CRLF; | ||
| 3617 | #else | ||
| 3618 | system_eol_type = CODING_EOL_LF; | ||
| 3619 | #endif | ||
| 3604 | } | 3620 | } |
| 3605 | 3621 | ||
| 3606 | #ifdef emacs | 3622 | #ifdef emacs |
| @@ -3610,23 +3626,29 @@ syms_of_coding () | |||
| 3610 | Qtarget_idx = intern ("target-idx"); | 3626 | Qtarget_idx = intern ("target-idx"); |
| 3611 | staticpro (&Qtarget_idx); | 3627 | staticpro (&Qtarget_idx); |
| 3612 | 3628 | ||
| 3629 | /* Target FILENAME is the first argument. */ | ||
| 3613 | Fput (Qinsert_file_contents, Qtarget_idx, make_number (0)); | 3630 | Fput (Qinsert_file_contents, Qtarget_idx, make_number (0)); |
| 3631 | /* Target FILENAME is the third argument. */ | ||
| 3614 | Fput (Qwrite_region, Qtarget_idx, make_number (2)); | 3632 | Fput (Qwrite_region, Qtarget_idx, make_number (2)); |
| 3615 | 3633 | ||
| 3616 | Qcall_process = intern ("call-process"); | 3634 | Qcall_process = intern ("call-process"); |
| 3617 | staticpro (&Qcall_process); | 3635 | staticpro (&Qcall_process); |
| 3636 | /* Target PROGRAM is the first argument. */ | ||
| 3618 | Fput (Qcall_process, Qtarget_idx, make_number (0)); | 3637 | Fput (Qcall_process, Qtarget_idx, make_number (0)); |
| 3619 | 3638 | ||
| 3620 | Qcall_process_region = intern ("call-process-region"); | 3639 | Qcall_process_region = intern ("call-process-region"); |
| 3621 | staticpro (&Qcall_process_region); | 3640 | staticpro (&Qcall_process_region); |
| 3641 | /* Target PROGRAM is the third argument. */ | ||
| 3622 | Fput (Qcall_process_region, Qtarget_idx, make_number (2)); | 3642 | Fput (Qcall_process_region, Qtarget_idx, make_number (2)); |
| 3623 | 3643 | ||
| 3624 | Qstart_process = intern ("start-process"); | 3644 | Qstart_process = intern ("start-process"); |
| 3625 | staticpro (&Qstart_process); | 3645 | staticpro (&Qstart_process); |
| 3646 | /* Target PROGRAM is the third argument. */ | ||
| 3626 | Fput (Qstart_process, Qtarget_idx, make_number (2)); | 3647 | Fput (Qstart_process, Qtarget_idx, make_number (2)); |
| 3627 | 3648 | ||
| 3628 | Qopen_network_stream = intern ("open-network-stream"); | 3649 | Qopen_network_stream = intern ("open-network-stream"); |
| 3629 | staticpro (&Qopen_network_stream); | 3650 | staticpro (&Qopen_network_stream); |
| 3651 | /* Target SERVICE is the fourth argument. */ | ||
| 3630 | Fput (Qopen_network_stream, Qtarget_idx, make_number (3)); | 3652 | Fput (Qopen_network_stream, Qtarget_idx, make_number (3)); |
| 3631 | 3653 | ||
| 3632 | Qcoding_system = intern ("coding-system"); | 3654 | Qcoding_system = intern ("coding-system"); |
| @@ -3656,7 +3678,7 @@ syms_of_coding () | |||
| 3656 | Fput (Qcoding_system_error, Qerror_conditions, | 3678 | Fput (Qcoding_system_error, Qerror_conditions, |
| 3657 | Fcons (Qcoding_system_error, Fcons (Qerror, Qnil))); | 3679 | Fcons (Qcoding_system_error, Fcons (Qerror, Qnil))); |
| 3658 | Fput (Qcoding_system_error, Qerror_message, | 3680 | Fput (Qcoding_system_error, Qerror_message, |
| 3659 | build_string ("Coding-system error")); | 3681 | build_string ("Invalid coding system")); |
| 3660 | 3682 | ||
| 3661 | Qcoding_category_index = intern ("coding-category-index"); | 3683 | Qcoding_category_index = intern ("coding-category-index"); |
| 3662 | staticpro (&Qcoding_category_index); | 3684 | staticpro (&Qcoding_category_index); |
| @@ -3685,6 +3707,9 @@ syms_of_coding () | |||
| 3685 | = intern ("character-unification-table-for-encode"); | 3707 | = intern ("character-unification-table-for-encode"); |
| 3686 | staticpro (&Qcharacter_unification_table_for_encode); | 3708 | staticpro (&Qcharacter_unification_table_for_encode); |
| 3687 | 3709 | ||
| 3710 | Qemacs_mule = intern ("emacs-mule"); | ||
| 3711 | staticpro (&Qemacs_mule); | ||
| 3712 | |||
| 3688 | defsubr (&Scoding_system_spec); | 3713 | defsubr (&Scoding_system_spec); |
| 3689 | defsubr (&Scoding_system_p); | 3714 | defsubr (&Scoding_system_p); |
| 3690 | defsubr (&Sread_coding_system); | 3715 | defsubr (&Sread_coding_system); |
| @@ -3732,6 +3757,10 @@ If not, an appropriate element in `coding-system-alist' (which see) is used."); | |||
| 3732 | "Coding-system used in the latest file or process I/O."); | 3757 | "Coding-system used in the latest file or process I/O."); |
| 3733 | Vlast_coding_system_used = Qnil; | 3758 | Vlast_coding_system_used = Qnil; |
| 3734 | 3759 | ||
| 3760 | DEFVAR_BOOL ("inhibit-eol-conversion", &inhibit_eol_conversion, | ||
| 3761 | "*Non-nil inhibit code conversion of end-of-line format in any cases."); | ||
| 3762 | inhibit_eol_conversion = 0; | ||
| 3763 | |||
| 3735 | DEFVAR_LISP ("file-coding-system-alist", &Vfile_coding_system_alist, | 3764 | DEFVAR_LISP ("file-coding-system-alist", &Vfile_coding_system_alist, |
| 3736 | "Alist to decide a coding system to use for a file I/O operation.\n\ | 3765 | "Alist to decide a coding system to use for a file I/O operation.\n\ |
| 3737 | The format is ((PATTERN . VAL) ...),\n\ | 3766 | The format is ((PATTERN . VAL) ...),\n\ |
| @@ -3744,7 +3773,7 @@ and the cdr part is used for encoding.\n\ | |||
| 3744 | If VAL is a function symbol, the function must return a coding system\n\ | 3773 | If VAL is a function symbol, the function must return a coding system\n\ |
| 3745 | or a cons of coding systems which are used as above.\n\ | 3774 | or a cons of coding systems which are used as above.\n\ |
| 3746 | \n\ | 3775 | \n\ |
| 3747 | See also the function `find-coding-system'."); | 3776 | See also the function `find-operation-coding-system'."); |
| 3748 | Vfile_coding_system_alist = Qnil; | 3777 | Vfile_coding_system_alist = Qnil; |
| 3749 | 3778 | ||
| 3750 | DEFVAR_LISP ("process-coding-system-alist", &Vprocess_coding_system_alist, | 3779 | DEFVAR_LISP ("process-coding-system-alist", &Vprocess_coding_system_alist, |
| @@ -3759,7 +3788,7 @@ and the cdr part is used for encoding.\n\ | |||
| 3759 | If VAL is a function symbol, the function must return a coding system\n\ | 3788 | If VAL is a function symbol, the function must return a coding system\n\ |
| 3760 | or a cons of coding systems which are used as above.\n\ | 3789 | or a cons of coding systems which are used as above.\n\ |
| 3761 | \n\ | 3790 | \n\ |
| 3762 | See also the function `find-coding-system'."); | 3791 | See also the function `find-operation-coding-system'."); |
| 3763 | Vprocess_coding_system_alist = Qnil; | 3792 | Vprocess_coding_system_alist = Qnil; |
| 3764 | 3793 | ||
| 3765 | DEFVAR_LISP ("network-coding-system-alist", &Vnetwork_coding_system_alist, | 3794 | DEFVAR_LISP ("network-coding-system-alist", &Vnetwork_coding_system_alist, |
| @@ -3775,7 +3804,7 @@ and the cdr part is used for encoding.\n\ | |||
| 3775 | If VAL is a function symbol, the function must return a coding system\n\ | 3804 | If VAL is a function symbol, the function must return a coding system\n\ |
| 3776 | or a cons of coding systems which are used as above.\n\ | 3805 | or a cons of coding systems which are used as above.\n\ |
| 3777 | \n\ | 3806 | \n\ |
| 3778 | See also the function `find-coding-system'."); | 3807 | See also the function `find-operation-coding-system'."); |
| 3779 | Vnetwork_coding_system_alist = Qnil; | 3808 | Vnetwork_coding_system_alist = Qnil; |
| 3780 | 3809 | ||
| 3781 | DEFVAR_INT ("eol-mnemonic-unix", &eol_mnemonic_unix, | 3810 | DEFVAR_INT ("eol-mnemonic-unix", &eol_mnemonic_unix, |