diff options
| author | Kenichi Handa | 2003-09-08 12:53:41 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-09-08 12:53:41 +0000 |
| commit | 8f924df7df019cce90537647de2627581043b5c4 (patch) | |
| tree | 6c40bd05679425e710d6b2e5649eae3da5e40a52 /src/process.c | |
| parent | 463f5630a5e7cbe7f042bc1175d1fa1c4e98860f (diff) | |
| parent | 9d4807432a01f9b3cc519fcfa3ea92a70ffa7f43 (diff) | |
| download | emacs-8f924df7df019cce90537647de2627581043b5c4.tar.gz emacs-8f924df7df019cce90537647de2627581043b5c4.zip | |
*** empty log message ***
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 130 |
1 files changed, 63 insertions, 67 deletions
diff --git a/src/process.c b/src/process.c index c4ba96a9e5c..3051b81f7cd 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -112,7 +112,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 112 | #include "lisp.h" | 112 | #include "lisp.h" |
| 113 | #include "window.h" | 113 | #include "window.h" |
| 114 | #include "buffer.h" | 114 | #include "buffer.h" |
| 115 | #include "charset.h" | 115 | #include "character.h" |
| 116 | #include "coding.h" | 116 | #include "coding.h" |
| 117 | #include "process.h" | 117 | #include "process.h" |
| 118 | #include "termhooks.h" | 118 | #include "termhooks.h" |
| @@ -600,6 +600,7 @@ setup_process_coding_systems (process) | |||
| 600 | struct Lisp_Process *p = XPROCESS (process); | 600 | struct Lisp_Process *p = XPROCESS (process); |
| 601 | int inch = XINT (p->infd); | 601 | int inch = XINT (p->infd); |
| 602 | int outch = XINT (p->outfd); | 602 | int outch = XINT (p->outfd); |
| 603 | Lisp_Object coding_system; | ||
| 603 | 604 | ||
| 604 | if (inch < 0 || outch < 0) | 605 | if (inch < 0 || outch < 0) |
| 605 | return; | 606 | return; |
| @@ -607,18 +608,18 @@ setup_process_coding_systems (process) | |||
| 607 | if (!proc_decode_coding_system[inch]) | 608 | if (!proc_decode_coding_system[inch]) |
| 608 | proc_decode_coding_system[inch] | 609 | proc_decode_coding_system[inch] |
| 609 | = (struct coding_system *) xmalloc (sizeof (struct coding_system)); | 610 | = (struct coding_system *) xmalloc (sizeof (struct coding_system)); |
| 610 | setup_coding_system (p->decode_coding_system, | 611 | coding_system = p->decode_coding_system; |
| 611 | proc_decode_coding_system[inch]); | ||
| 612 | if (! NILP (p->filter)) | 612 | if (! NILP (p->filter)) |
| 613 | { | 613 | { |
| 614 | if (NILP (p->filter_multibyte)) | 614 | if (NILP (p->filter_multibyte)) |
| 615 | setup_raw_text_coding_system (proc_decode_coding_system[inch]); | 615 | coding_system = raw_text_coding_system (coding_system); |
| 616 | } | 616 | } |
| 617 | else if (BUFFERP (p->buffer)) | 617 | else if (BUFFERP (p->buffer)) |
| 618 | { | 618 | { |
| 619 | if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters)) | 619 | if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters)) |
| 620 | setup_raw_text_coding_system (proc_decode_coding_system[inch]); | 620 | coding_system = raw_text_coding_system (coding_system); |
| 621 | } | 621 | } |
| 622 | setup_coding_system (coding_system, proc_decode_coding_system[inch]); | ||
| 622 | 623 | ||
| 623 | if (!proc_encode_coding_system[outch]) | 624 | if (!proc_encode_coding_system[outch]) |
| 624 | proc_encode_coding_system[outch] | 625 | proc_encode_coding_system[outch] |
| @@ -4400,7 +4401,7 @@ read_process_output (proc, channel) | |||
| 4400 | Lisp_Object proc; | 4401 | Lisp_Object proc; |
| 4401 | register int channel; | 4402 | register int channel; |
| 4402 | { | 4403 | { |
| 4403 | register int nchars, nbytes; | 4404 | register int nbytes; |
| 4404 | char *chars; | 4405 | char *chars; |
| 4405 | register Lisp_Object outstream; | 4406 | register Lisp_Object outstream; |
| 4406 | register struct buffer *old = current_buffer; | 4407 | register struct buffer *old = current_buffer; |
| @@ -4534,13 +4535,13 @@ read_process_output (proc, channel) | |||
| 4534 | save the match data in a special nonrecursive fashion. */ | 4535 | save the match data in a special nonrecursive fashion. */ |
| 4535 | running_asynch_code = 1; | 4536 | running_asynch_code = 1; |
| 4536 | 4537 | ||
| 4537 | text = decode_coding_string (make_unibyte_string (chars, nbytes), | 4538 | decode_coding_c_string (coding, chars, nbytes, Qt); |
| 4538 | coding, 0); | 4539 | text = coding->dst_object; |
| 4539 | Vlast_coding_system_used = coding->symbol; | 4540 | Vlast_coding_system_used = CODING_ID_NAME (coding->id); |
| 4540 | /* A new coding system might be found. */ | 4541 | /* A new coding system might be found. */ |
| 4541 | if (!EQ (p->decode_coding_system, coding->symbol)) | 4542 | if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) |
| 4542 | { | 4543 | { |
| 4543 | p->decode_coding_system = coding->symbol; | 4544 | p->decode_coding_system = Vlast_coding_system_used; |
| 4544 | 4545 | ||
| 4545 | /* Don't call setup_coding_system for | 4546 | /* Don't call setup_coding_system for |
| 4546 | proc_decode_coding_system[channel] here. It is done in | 4547 | proc_decode_coding_system[channel] here. It is done in |
| @@ -4556,16 +4557,18 @@ read_process_output (proc, channel) | |||
| 4556 | if (NILP (p->encode_coding_system) | 4557 | if (NILP (p->encode_coding_system) |
| 4557 | && proc_encode_coding_system[XINT (p->outfd)]) | 4558 | && proc_encode_coding_system[XINT (p->outfd)]) |
| 4558 | { | 4559 | { |
| 4559 | p->encode_coding_system = coding->symbol; | 4560 | p->encode_coding_system = Vlast_coding_system_used; |
| 4560 | setup_coding_system (coding->symbol, | 4561 | setup_coding_system (p->encode_coding_system, |
| 4561 | proc_encode_coding_system[XINT (p->outfd)]); | 4562 | proc_encode_coding_system[XINT (p->outfd)]); |
| 4562 | } | 4563 | } |
| 4563 | } | 4564 | } |
| 4564 | 4565 | ||
| 4565 | carryover = nbytes - coding->consumed; | 4566 | if (coding->carryover_bytes > 0) |
| 4566 | bcopy (chars + coding->consumed, SDATA (p->decoding_buf), | 4567 | { |
| 4567 | carryover); | 4568 | bcopy (coding->carryover, SDATA (p->decoding_buf), |
| 4568 | XSETINT (p->decoding_carryover, carryover); | 4569 | coding->carryover_bytes); |
| 4570 | XSETINT (p->decoding_carryover, coding->carryover_bytes); | ||
| 4571 | } | ||
| 4569 | /* Adjust the multibyteness of TEXT to that of the filter. */ | 4572 | /* Adjust the multibyteness of TEXT to that of the filter. */ |
| 4570 | if (NILP (p->filter_multibyte) != ! STRING_MULTIBYTE (text)) | 4573 | if (NILP (p->filter_multibyte) != ! STRING_MULTIBYTE (text)) |
| 4571 | text = (STRING_MULTIBYTE (text) | 4574 | text = (STRING_MULTIBYTE (text) |
| @@ -4650,26 +4653,28 @@ read_process_output (proc, channel) | |||
| 4650 | if (! (BEGV <= PT && PT <= ZV)) | 4653 | if (! (BEGV <= PT && PT <= ZV)) |
| 4651 | Fwiden (); | 4654 | Fwiden (); |
| 4652 | 4655 | ||
| 4653 | text = decode_coding_string (make_unibyte_string (chars, nbytes), | 4656 | decode_coding_c_string (coding, chars, nbytes, Qt); |
| 4654 | coding, 0); | 4657 | text = coding->dst_object; |
| 4655 | Vlast_coding_system_used = coding->symbol; | 4658 | Vlast_coding_system_used = CODING_ID_NAME (coding->id); |
| 4656 | /* A new coding system might be found. See the comment in the | 4659 | /* A new coding system might be found. See the comment in the |
| 4657 | similar code in the previous `if' block. */ | 4660 | similar code in the previous `if' block. */ |
| 4658 | if (!EQ (p->decode_coding_system, coding->symbol)) | 4661 | if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) |
| 4659 | { | 4662 | { |
| 4660 | p->decode_coding_system = coding->symbol; | 4663 | p->decode_coding_system = Vlast_coding_system_used; |
| 4661 | if (NILP (p->encode_coding_system) | 4664 | if (NILP (p->encode_coding_system) |
| 4662 | && proc_encode_coding_system[XINT (p->outfd)]) | 4665 | && proc_encode_coding_system[XINT (p->outfd)]) |
| 4663 | { | 4666 | { |
| 4664 | p->encode_coding_system = coding->symbol; | 4667 | p->encode_coding_system = Vlast_coding_system_used; |
| 4665 | setup_coding_system (coding->symbol, | 4668 | setup_coding_system (p->encode_coding_system, |
| 4666 | proc_encode_coding_system[XINT (p->outfd)]); | 4669 | proc_encode_coding_system[XINT (p->outfd)]); |
| 4667 | } | 4670 | } |
| 4668 | } | 4671 | } |
| 4669 | carryover = nbytes - coding->consumed; | 4672 | if (coding->carryover_bytes > 0) |
| 4670 | bcopy (chars + coding->consumed, SDATA (p->decoding_buf), | 4673 | { |
| 4671 | carryover); | 4674 | bcopy (coding->carryover, SDATA (p->decoding_buf), |
| 4672 | XSETINT (p->decoding_carryover, carryover); | 4675 | coding->carryover_bytes); |
| 4676 | XSETINT (p->decoding_carryover, coding->carryover_bytes); | ||
| 4677 | } | ||
| 4673 | /* Adjust the multibyteness of TEXT to that of the buffer. */ | 4678 | /* Adjust the multibyteness of TEXT to that of the buffer. */ |
| 4674 | if (NILP (current_buffer->enable_multibyte_characters) | 4679 | if (NILP (current_buffer->enable_multibyte_characters) |
| 4675 | != ! STRING_MULTIBYTE (text)) | 4680 | != ! STRING_MULTIBYTE (text)) |
| @@ -4790,86 +4795,77 @@ send_process (proc, buf, len, object) | |||
| 4790 | SDATA (XPROCESS (proc)->name)); | 4795 | SDATA (XPROCESS (proc)->name)); |
| 4791 | 4796 | ||
| 4792 | coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; | 4797 | coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; |
| 4793 | Vlast_coding_system_used = coding->symbol; | 4798 | Vlast_coding_system_used = CODING_ID_NAME (coding->id); |
| 4794 | 4799 | ||
| 4795 | if ((STRINGP (object) && STRING_MULTIBYTE (object)) | 4800 | if ((STRINGP (object) && STRING_MULTIBYTE (object)) |
| 4796 | || (BUFFERP (object) | 4801 | || (BUFFERP (object) |
| 4797 | && !NILP (XBUFFER (object)->enable_multibyte_characters)) | 4802 | && !NILP (XBUFFER (object)->enable_multibyte_characters)) |
| 4798 | || EQ (object, Qt)) | 4803 | || EQ (object, Qt)) |
| 4799 | { | 4804 | { |
| 4800 | if (!EQ (coding->symbol, XPROCESS (proc)->encode_coding_system)) | 4805 | if (!EQ (Vlast_coding_system_used, |
| 4806 | XPROCESS (proc)->encode_coding_system)) | ||
| 4801 | /* The coding system for encoding was changed to raw-text | 4807 | /* The coding system for encoding was changed to raw-text |
| 4802 | because we sent a unibyte text previously. Now we are | 4808 | because we sent a unibyte text previously. Now we are |
| 4803 | sending a multibyte text, thus we must encode it by the | 4809 | sending a multibyte text, thus we must encode it by the |
| 4804 | original coding system specified for the current | 4810 | original coding system specified for the current |
| 4805 | process. */ | 4811 | process. */ |
| 4806 | setup_coding_system (XPROCESS (proc)->encode_coding_system, coding); | 4812 | setup_coding_system (XPROCESS (proc)->encode_coding_system, coding); |
| 4807 | /* src_multibyte should be set to 1 _after_ a call to | ||
| 4808 | setup_coding_system, since it resets src_multibyte to | ||
| 4809 | zero. */ | ||
| 4810 | coding->src_multibyte = 1; | ||
| 4811 | } | 4813 | } |
| 4812 | else | 4814 | else |
| 4813 | { | 4815 | { |
| 4814 | /* For sending a unibyte text, character code conversion should | 4816 | /* For sending a unibyte text, character code conversion should |
| 4815 | not take place but EOL conversion should. So, setup raw-text | 4817 | not take place but EOL conversion should. So, setup raw-text |
| 4816 | or one of the subsidiary if we have not yet done it. */ | 4818 | or one of the subsidiary if we have not yet done it. */ |
| 4817 | if (coding->type != coding_type_raw_text) | 4819 | if (CODING_REQUIRE_ENCODING (coding)) |
| 4818 | { | 4820 | { |
| 4819 | if (CODING_REQUIRE_FLUSHING (coding)) | 4821 | if (CODING_REQUIRE_FLUSHING (coding)) |
| 4820 | { | 4822 | { |
| 4821 | /* But, before changing the coding, we must flush out data. */ | 4823 | /* But, before changing the coding, we must flush out data. */ |
| 4822 | coding->mode |= CODING_MODE_LAST_BLOCK; | 4824 | coding->mode |= CODING_MODE_LAST_BLOCK; |
| 4823 | send_process (proc, "", 0, Qt); | 4825 | send_process (proc, "", 0, Qt); |
| 4826 | coding->mode &= CODING_MODE_LAST_BLOCK; | ||
| 4824 | } | 4827 | } |
| 4825 | coding->src_multibyte = 0; | 4828 | coding->src_multibyte = 0; |
| 4826 | setup_raw_text_coding_system (coding); | 4829 | setup_coding_system (raw_text_coding_system |
| 4830 | (Vlast_coding_system_used), | ||
| 4831 | coding); | ||
| 4827 | } | 4832 | } |
| 4828 | } | 4833 | } |
| 4829 | coding->dst_multibyte = 0; | 4834 | coding->dst_multibyte = 0; |
| 4830 | 4835 | ||
| 4831 | if (CODING_REQUIRE_ENCODING (coding)) | 4836 | if (CODING_REQUIRE_ENCODING (coding)) |
| 4832 | { | 4837 | { |
| 4833 | int require = encoding_buffer_size (coding, len); | 4838 | coding->dst_object = Qt; |
| 4834 | int from_byte = -1, from = -1, to = -1; | ||
| 4835 | unsigned char *temp_buf = NULL; | ||
| 4836 | |||
| 4837 | if (BUFFERP (object)) | 4839 | if (BUFFERP (object)) |
| 4838 | { | 4840 | { |
| 4839 | from_byte = BUF_PTR_BYTE_POS (XBUFFER (object), buf); | 4841 | int from_byte, from, to; |
| 4840 | from = buf_bytepos_to_charpos (XBUFFER (object), from_byte); | 4842 | int save_pt, save_pt_byte; |
| 4841 | to = buf_bytepos_to_charpos (XBUFFER (object), from_byte + len); | 4843 | struct buffer *cur = current_buffer; |
| 4844 | |||
| 4845 | set_buffer_internal (XBUFFER (object)); | ||
| 4846 | save_pt = PT, save_pt_byte = PT_BYTE; | ||
| 4847 | |||
| 4848 | from_byte = PTR_BYTE_POS (buf); | ||
| 4849 | from = BYTE_TO_CHAR (from_byte); | ||
| 4850 | to = BYTE_TO_CHAR (from_byte + len); | ||
| 4851 | TEMP_SET_PT_BOTH (from, from_byte); | ||
| 4852 | encode_coding_object (coding, object, from, from_byte, | ||
| 4853 | to, from_byte + len, Qt); | ||
| 4854 | TEMP_SET_PT_BOTH (save_pt, save_pt_byte); | ||
| 4855 | set_buffer_internal (cur); | ||
| 4842 | } | 4856 | } |
| 4843 | else if (STRINGP (object)) | 4857 | else if (STRINGP (object)) |
| 4844 | { | 4858 | { |
| 4845 | from_byte = buf - SDATA (object); | 4859 | encode_coding_string (coding, object, 1); |
| 4846 | from = string_byte_to_char (object, from_byte); | ||
| 4847 | to = string_byte_to_char (object, from_byte + len); | ||
| 4848 | } | 4860 | } |
| 4849 | 4861 | else | |
| 4850 | if (coding->composing != COMPOSITION_DISABLED) | ||
| 4851 | { | 4862 | { |
| 4852 | if (from_byte >= 0) | 4863 | coding->dst_object = make_unibyte_string (buf, len); |
| 4853 | coding_save_composition (coding, from, to, object); | 4864 | coding->produced = len; |
| 4854 | else | ||
| 4855 | coding->composing = COMPOSITION_DISABLED; | ||
| 4856 | } | 4865 | } |
| 4857 | 4866 | ||
| 4858 | if (SBYTES (XPROCESS (proc)->encoding_buf) < require) | ||
| 4859 | XPROCESS (proc)->encoding_buf = make_uninit_string (require); | ||
| 4860 | |||
| 4861 | if (from_byte >= 0) | ||
| 4862 | buf = (BUFFERP (object) | ||
| 4863 | ? BUF_BYTE_ADDRESS (XBUFFER (object), from_byte) | ||
| 4864 | : SDATA (object) + from_byte); | ||
| 4865 | |||
| 4866 | object = XPROCESS (proc)->encoding_buf; | ||
| 4867 | encode_coding (coding, (char *) buf, SDATA (object), | ||
| 4868 | len, SBYTES (object)); | ||
| 4869 | len = coding->produced; | 4867 | len = coding->produced; |
| 4870 | buf = SDATA (object); | 4868 | buf = SDATA (coding->dst_object); |
| 4871 | if (temp_buf) | ||
| 4872 | xfree (temp_buf); | ||
| 4873 | } | 4869 | } |
| 4874 | 4870 | ||
| 4875 | #ifdef VMS | 4871 | #ifdef VMS |
| @@ -6499,7 +6495,7 @@ The value takes effect when `start-process' is called. */); | |||
| 6499 | 6495 | ||
| 6500 | #include "lisp.h" | 6496 | #include "lisp.h" |
| 6501 | #include "systime.h" | 6497 | #include "systime.h" |
| 6502 | #include "charset.h" | 6498 | #include "character.h" |
| 6503 | #include "coding.h" | 6499 | #include "coding.h" |
| 6504 | #include "termopts.h" | 6500 | #include "termopts.h" |
| 6505 | #include "sysselect.h" | 6501 | #include "sysselect.h" |