diff options
| author | Richard M. Stallman | 1997-09-03 20:35:35 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-09-03 20:35:35 +0000 |
| commit | 914894115d3b0ffdffe58578adb8fd6d6ac09143 (patch) | |
| tree | 3b75f5a2a4d091a969d5054f05ae4127b159425b /src | |
| parent | d785cf9e4de92f12f76562f4bb42ba681a650410 (diff) | |
| download | emacs-914894115d3b0ffdffe58578adb8fd6d6ac09143.tar.gz emacs-914894115d3b0ffdffe58578adb8fd6d6ac09143.zip | |
(Fcall_process): Set EOL conversion type to LF when
binary-process-output is non-nil.
(Fcall_process_region): binary-process-XXXput only determines EOL
conversion; if it is nil, convert LF <-> CRLF. Don't bind
coding-system-for-read, it is done in Fcall_process.
Diffstat (limited to 'src')
| -rw-r--r-- | src/callproc.c | 95 |
1 files changed, 53 insertions, 42 deletions
diff --git a/src/callproc.c b/src/callproc.c index b5eeadd3d75..d876a4c17fb 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -296,8 +296,17 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 296 | } | 296 | } |
| 297 | setup_coding_system (Fcheck_coding_system (val), &process_coding); | 297 | setup_coding_system (Fcheck_coding_system (val), &process_coding); |
| 298 | #ifdef MSDOS | 298 | #ifdef MSDOS |
| 299 | /* On MSDOS, if the user did not ask for binary, | 299 | /* On MSDOS, if the user did not ask for binary, treat it as |
| 300 | treat it as "text" which means doing CRLF conversion. */ | 300 | "text" which means doing CRLF conversion. Otherwise, leave |
| 301 | the EOLs alone. | ||
| 302 | |||
| 303 | Note that ``binary'' here only means whether EOLs should or | ||
| 304 | should not be converted, since that's what Vbinary_process_XXXput | ||
| 305 | meant in the days before the coding systems were introduced. | ||
| 306 | |||
| 307 | For other conversions, the caller should set coding-system | ||
| 308 | variables explicitly, or rely on auto-detection. */ | ||
| 309 | |||
| 301 | /* FIXME: this probably should be moved into the guts of | 310 | /* FIXME: this probably should be moved into the guts of |
| 302 | `Ffind_operation_coding_system' for the case of `call-process'. */ | 311 | `Ffind_operation_coding_system' for the case of `call-process'. */ |
| 303 | if (NILP (Vbinary_process_output)) | 312 | if (NILP (Vbinary_process_output)) |
| @@ -307,6 +316,8 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 307 | /* FIXME: should we set type to undecided? */ | 316 | /* FIXME: should we set type to undecided? */ |
| 308 | process_coding.type = coding_type_emacs_mule; | 317 | process_coding.type = coding_type_emacs_mule; |
| 309 | } | 318 | } |
| 319 | else | ||
| 320 | process_coding.eol_type = CODING_EOL_LF; | ||
| 310 | #endif | 321 | #endif |
| 311 | } | 322 | } |
| 312 | } | 323 | } |
| @@ -802,57 +813,57 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.") | |||
| 802 | end = args[1]; | 813 | end = args[1]; |
| 803 | /* Decide coding-system of the contents of the temporary file. */ | 814 | /* Decide coding-system of the contents of the temporary file. */ |
| 804 | #ifdef DOS_NT | 815 | #ifdef DOS_NT |
| 816 | /* This is to cause find-buffer-file-type-coding-system (see | ||
| 817 | dos-w32.el) to choose correct EOL translation for write-region. */ | ||
| 805 | specbind (Qbuffer_file_type, Vbinary_process_input); | 818 | specbind (Qbuffer_file_type, Vbinary_process_input); |
| 806 | if (NILP (Vbinary_process_input)) | 819 | #endif |
| 820 | if (!NILP (Vcoding_system_for_write)) | ||
| 821 | val = Vcoding_system_for_write; | ||
| 822 | else if (NILP (current_buffer->enable_multibyte_characters)) | ||
| 807 | val = Qnil; | 823 | val = Qnil; |
| 808 | else | 824 | else |
| 809 | #endif | ||
| 810 | { | 825 | { |
| 811 | if (!NILP (Vcoding_system_for_write)) | 826 | args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); |
| 812 | val = Vcoding_system_for_write; | 827 | args2[0] = Qcall_process_region; |
| 813 | else if (NILP (current_buffer->enable_multibyte_characters)) | 828 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; |
| 814 | val = Qnil; | 829 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); |
| 830 | if (CONSP (coding_systems)) | ||
| 831 | val = XCONS (coding_systems)->cdr; | ||
| 832 | else if (CONSP (Vdefault_process_coding_system)) | ||
| 833 | val = XCONS (Vdefault_process_coding_system)->cdr; | ||
| 815 | else | 834 | else |
| 816 | { | 835 | val = Qnil; |
| 817 | args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); | ||
| 818 | args2[0] = Qcall_process_region; | ||
| 819 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | ||
| 820 | coding_systems = Ffind_operation_coding_system (nargs + 1, args2); | ||
| 821 | if (CONSP (coding_systems)) | ||
| 822 | val = XCONS (coding_systems)->cdr; | ||
| 823 | else if (CONSP (Vdefault_process_coding_system)) | ||
| 824 | val = XCONS (Vdefault_process_coding_system)->cdr; | ||
| 825 | else | ||
| 826 | val = Qnil; | ||
| 827 | } | ||
| 828 | } | 836 | } |
| 829 | specbind (intern ("coding-system-for-write"), val); | ||
| 830 | Fwrite_region (start, end, filename_string, Qnil, Qlambda, Qnil); | ||
| 831 | 837 | ||
| 832 | #ifdef DOS_NT | 838 | #ifdef DOS_NT |
| 833 | if (NILP (Vbinary_process_input)) | 839 | /* binary-process-input tells whether the buffer needs to be |
| 834 | val = Qnil; | 840 | written with EOL conversions, but it doesn't say anything |
| 835 | else | 841 | about the rest of text encoding. It takes effect whenever |
| 836 | #endif | 842 | the coding system doesn't otherwise specify what to do for |
| 843 | eol conversion. */ | ||
| 844 | if (NILP (val)) | ||
| 837 | { | 845 | { |
| 838 | if (!NILP (Vcoding_system_for_read)) | 846 | if (! NILP (Vbinary_process_input)) |
| 839 | val = Vcoding_system_for_read; | 847 | val = intern ("undecided-unix"); |
| 840 | else if (NILP (current_buffer->enable_multibyte_characters)) | ||
| 841 | val = Qemacs_mule; | ||
| 842 | else | 848 | else |
| 843 | { | 849 | val = intern ("undecided-dos"); |
| 844 | if (EQ (coding_systems, Qt)) | ||
| 845 | { | ||
| 846 | args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); | ||
| 847 | args2[0] = Qcall_process_region; | ||
| 848 | for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; | ||
| 849 | coding_systems = Ffind_operation_coding_system (nargs + 1, | ||
| 850 | args2); | ||
| 851 | } | ||
| 852 | val = CONSP (coding_systems) ? XCONS (coding_systems)->car : Qnil; | ||
| 853 | } | ||
| 854 | } | 850 | } |
| 855 | specbind (intern ("coding-system-for-read"), val); | 851 | else if (SYMBOLP (val)) |
| 852 | { | ||
| 853 | Lisp_Object eolval; | ||
| 854 | eolval = Fget (val, Qeol_type); | ||
| 855 | if (VECTORP (eolval) && XVECTOR (eolval)->size > 1) | ||
| 856 | /* Use element 1 (CRLF conversion) for "text", | ||
| 857 | and element 0 (LF conversion) for "binary". */ | ||
| 858 | val = XVECTOR (eolval)->contents[NILP (Vbinary_process_input)]; | ||
| 859 | } | ||
| 860 | #endif | ||
| 861 | |||
| 862 | specbind (intern ("coding-system-for-write"), val); | ||
| 863 | Fwrite_region (start, end, filename_string, Qnil, Qlambda, Qnil); | ||
| 864 | |||
| 865 | /* Note that Fcall_process takes care of binding | ||
| 866 | coding-system-for-read. */ | ||
| 856 | 867 | ||
| 857 | record_unwind_protect (delete_temp_file, filename_string); | 868 | record_unwind_protect (delete_temp_file, filename_string); |
| 858 | 869 | ||