diff options
| author | Miles Bader | 2008-02-01 16:01:31 +0000 |
|---|---|---|
| committer | Miles Bader | 2008-02-01 16:01:31 +0000 |
| commit | 6cc41fb06c37234822d5aedf7ce0f77b88bb450a (patch) | |
| tree | a130326faf29d4410ed126e4f0d6a13f11a19df3 /src/process.c | |
| parent | b502217bd845bc6280fd2bb1eacce176ed4f7d90 (diff) | |
| parent | dd559368b0db67654f643320b1d84afdabe60e97 (diff) | |
| download | emacs-6cc41fb06c37234822d5aedf7ce0f77b88bb450a.tar.gz emacs-6cc41fb06c37234822d5aedf7ce0f77b88bb450a.zip | |
Merge unicode branch
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1037
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 274 |
1 files changed, 90 insertions, 184 deletions
diff --git a/src/process.c b/src/process.c index c7ca36a847f..e5546488aae 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -133,7 +133,7 @@ Boston, MA 02110-1301, USA. */ | |||
| 133 | 133 | ||
| 134 | #include "window.h" | 134 | #include "window.h" |
| 135 | #include "buffer.h" | 135 | #include "buffer.h" |
| 136 | #include "charset.h" | 136 | #include "character.h" |
| 137 | #include "coding.h" | 137 | #include "coding.h" |
| 138 | #include "process.h" | 138 | #include "process.h" |
| 139 | #include "frame.h" | 139 | #include "frame.h" |
| @@ -174,8 +174,8 @@ extern Lisp_Object QCfilter; | |||
| 174 | Qt nor Qnil but is instead a property list (KEY VAL ...). */ | 174 | Qt nor Qnil but is instead a property list (KEY VAL ...). */ |
| 175 | 175 | ||
| 176 | #ifdef HAVE_SOCKETS | 176 | #ifdef HAVE_SOCKETS |
| 177 | #define NETCONN_P(p) (GC_CONSP (XPROCESS (p)->childp)) | 177 | #define NETCONN_P(p) (CONSP (XPROCESS (p)->childp)) |
| 178 | #define NETCONN1_P(p) (GC_CONSP ((p)->childp)) | 178 | #define NETCONN1_P(p) (CONSP ((p)->childp)) |
| 179 | #else | 179 | #else |
| 180 | #define NETCONN_P(p) 0 | 180 | #define NETCONN_P(p) 0 |
| 181 | #define NETCONN1_P(p) 0 | 181 | #define NETCONN1_P(p) 0 |
| @@ -678,6 +678,7 @@ setup_process_coding_systems (process) | |||
| 678 | struct Lisp_Process *p = XPROCESS (process); | 678 | struct Lisp_Process *p = XPROCESS (process); |
| 679 | int inch = p->infd; | 679 | int inch = p->infd; |
| 680 | int outch = p->outfd; | 680 | int outch = p->outfd; |
| 681 | Lisp_Object coding_system; | ||
| 681 | 682 | ||
| 682 | if (inch < 0 || outch < 0) | 683 | if (inch < 0 || outch < 0) |
| 683 | return; | 684 | return; |
| @@ -685,26 +686,24 @@ setup_process_coding_systems (process) | |||
| 685 | if (!proc_decode_coding_system[inch]) | 686 | if (!proc_decode_coding_system[inch]) |
| 686 | proc_decode_coding_system[inch] | 687 | proc_decode_coding_system[inch] |
| 687 | = (struct coding_system *) xmalloc (sizeof (struct coding_system)); | 688 | = (struct coding_system *) xmalloc (sizeof (struct coding_system)); |
| 688 | setup_coding_system (p->decode_coding_system, | 689 | coding_system = p->decode_coding_system; |
| 689 | proc_decode_coding_system[inch]); | ||
| 690 | if (! NILP (p->filter)) | 690 | if (! NILP (p->filter)) |
| 691 | { | 691 | { |
| 692 | if (!p->filter_multibyte) | 692 | if (!p->filter_multibyte) |
| 693 | setup_raw_text_coding_system (proc_decode_coding_system[inch]); | 693 | coding_system = raw_text_coding_system (coding_system); |
| 694 | } | 694 | } |
| 695 | else if (BUFFERP (p->buffer)) | 695 | else if (BUFFERP (p->buffer)) |
| 696 | { | 696 | { |
| 697 | if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters)) | 697 | if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters)) |
| 698 | setup_raw_text_coding_system (proc_decode_coding_system[inch]); | 698 | coding_system = raw_text_coding_system (coding_system); |
| 699 | } | 699 | } |
| 700 | setup_coding_system (coding_system, proc_decode_coding_system[inch]); | ||
| 700 | 701 | ||
| 701 | if (!proc_encode_coding_system[outch]) | 702 | if (!proc_encode_coding_system[outch]) |
| 702 | proc_encode_coding_system[outch] | 703 | proc_encode_coding_system[outch] |
| 703 | = (struct coding_system *) xmalloc (sizeof (struct coding_system)); | 704 | = (struct coding_system *) xmalloc (sizeof (struct coding_system)); |
| 704 | setup_coding_system (p->encode_coding_system, | 705 | setup_coding_system (p->encode_coding_system, |
| 705 | proc_encode_coding_system[outch]); | 706 | proc_encode_coding_system[outch]); |
| 706 | if (proc_encode_coding_system[outch]->eol_type == CODING_EOL_UNDECIDED) | ||
| 707 | proc_encode_coding_system[outch]->eol_type = system_eol_type; | ||
| 708 | } | 707 | } |
| 709 | 708 | ||
| 710 | DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, | 709 | DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, |
| @@ -5155,13 +5154,13 @@ read_process_output (proc, channel) | |||
| 5155 | save the match data in a special nonrecursive fashion. */ | 5154 | save the match data in a special nonrecursive fashion. */ |
| 5156 | running_asynch_code = 1; | 5155 | running_asynch_code = 1; |
| 5157 | 5156 | ||
| 5158 | text = decode_coding_string (make_unibyte_string (chars, nbytes), | 5157 | decode_coding_c_string (coding, chars, nbytes, Qt); |
| 5159 | coding, 0); | 5158 | text = coding->dst_object; |
| 5160 | Vlast_coding_system_used = coding->symbol; | 5159 | Vlast_coding_system_used = CODING_ID_NAME (coding->id); |
| 5161 | /* A new coding system might be found. */ | 5160 | /* A new coding system might be found. */ |
| 5162 | if (!EQ (p->decode_coding_system, coding->symbol)) | 5161 | if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) |
| 5163 | { | 5162 | { |
| 5164 | p->decode_coding_system = coding->symbol; | 5163 | p->decode_coding_system = Vlast_coding_system_used; |
| 5165 | 5164 | ||
| 5166 | /* Don't call setup_coding_system for | 5165 | /* Don't call setup_coding_system for |
| 5167 | proc_decode_coding_system[channel] here. It is done in | 5166 | proc_decode_coding_system[channel] here. It is done in |
| @@ -5177,25 +5176,21 @@ read_process_output (proc, channel) | |||
| 5177 | if (NILP (p->encode_coding_system) | 5176 | if (NILP (p->encode_coding_system) |
| 5178 | && proc_encode_coding_system[p->outfd]) | 5177 | && proc_encode_coding_system[p->outfd]) |
| 5179 | { | 5178 | { |
| 5180 | p->encode_coding_system = coding->symbol; | 5179 | p->encode_coding_system |
| 5181 | setup_coding_system (coding->symbol, | 5180 | = coding_inherit_eol_type (Vlast_coding_system_used, Qnil); |
| 5181 | setup_coding_system (p->encode_coding_system, | ||
| 5182 | proc_encode_coding_system[p->outfd]); | 5182 | proc_encode_coding_system[p->outfd]); |
| 5183 | if (proc_encode_coding_system[p->outfd]->eol_type | ||
| 5184 | == CODING_EOL_UNDECIDED) | ||
| 5185 | proc_encode_coding_system[p->outfd]->eol_type | ||
| 5186 | = system_eol_type; | ||
| 5187 | } | 5183 | } |
| 5188 | } | 5184 | } |
| 5189 | 5185 | ||
| 5190 | carryover = nbytes - coding->consumed; | 5186 | if (coding->carryover_bytes > 0) |
| 5191 | if (carryover < 0) | 5187 | { |
| 5192 | abort (); | 5188 | if (SCHARS (p->decoding_buf) < coding->carryover_bytes) |
| 5193 | 5189 | p->decoding_buf = make_uninit_string (coding->carryover_bytes); | |
| 5194 | if (SCHARS (p->decoding_buf) < carryover) | 5190 | bcopy (coding->carryover, SDATA (p->decoding_buf), |
| 5195 | p->decoding_buf = make_uninit_string (carryover); | 5191 | coding->carryover_bytes); |
| 5196 | bcopy (chars + coding->consumed, SDATA (p->decoding_buf), | 5192 | p->decoding_carryover = coding->carryover_bytes; |
| 5197 | carryover); | 5193 | } |
| 5198 | p->decoding_carryover = carryover; | ||
| 5199 | /* Adjust the multibyteness of TEXT to that of the filter. */ | 5194 | /* Adjust the multibyteness of TEXT to that of the filter. */ |
| 5200 | if (!p->filter_multibyte != !STRING_MULTIBYTE (text)) | 5195 | if (!p->filter_multibyte != !STRING_MULTIBYTE (text)) |
| 5201 | text = (STRING_MULTIBYTE (text) | 5196 | text = (STRING_MULTIBYTE (text) |
| @@ -5280,36 +5275,31 @@ read_process_output (proc, channel) | |||
| 5280 | if (! (BEGV <= PT && PT <= ZV)) | 5275 | if (! (BEGV <= PT && PT <= ZV)) |
| 5281 | Fwiden (); | 5276 | Fwiden (); |
| 5282 | 5277 | ||
| 5283 | text = decode_coding_string (make_unibyte_string (chars, nbytes), | 5278 | decode_coding_c_string (coding, chars, nbytes, Qt); |
| 5284 | coding, 0); | 5279 | text = coding->dst_object; |
| 5285 | Vlast_coding_system_used = coding->symbol; | 5280 | Vlast_coding_system_used = CODING_ID_NAME (coding->id); |
| 5286 | /* A new coding system might be found. See the comment in the | 5281 | /* A new coding system might be found. See the comment in the |
| 5287 | similar code in the previous `if' block. */ | 5282 | similar code in the previous `if' block. */ |
| 5288 | if (!EQ (p->decode_coding_system, coding->symbol)) | 5283 | if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) |
| 5289 | { | 5284 | { |
| 5290 | p->decode_coding_system = coding->symbol; | 5285 | p->decode_coding_system = Vlast_coding_system_used; |
| 5291 | if (NILP (p->encode_coding_system) | 5286 | if (NILP (p->encode_coding_system) |
| 5292 | && proc_encode_coding_system[p->outfd]) | 5287 | && proc_encode_coding_system[p->outfd]) |
| 5293 | { | 5288 | { |
| 5294 | p->encode_coding_system = coding->symbol; | 5289 | p->encode_coding_system |
| 5295 | setup_coding_system (coding->symbol, | 5290 | = coding_inherit_eol_type (Vlast_coding_system_used, Qnil); |
| 5291 | setup_coding_system (p->encode_coding_system, | ||
| 5296 | proc_encode_coding_system[p->outfd]); | 5292 | proc_encode_coding_system[p->outfd]); |
| 5297 | if (proc_encode_coding_system[p->outfd]->eol_type | ||
| 5298 | == CODING_EOL_UNDECIDED) | ||
| 5299 | proc_encode_coding_system[p->outfd]->eol_type | ||
| 5300 | = system_eol_type; | ||
| 5301 | } | 5293 | } |
| 5302 | } | 5294 | } |
| 5303 | carryover = nbytes - coding->consumed; | 5295 | if (coding->carryover_bytes > 0) |
| 5304 | if (carryover < 0) | 5296 | { |
| 5305 | abort (); | 5297 | if (SCHARS (p->decoding_buf) < coding->carryover_bytes) |
| 5306 | 5298 | p->decoding_buf = make_uninit_string (coding->carryover_bytes); | |
| 5307 | if (SCHARS (p->decoding_buf) < carryover) | 5299 | bcopy (coding->carryover, SDATA (p->decoding_buf), |
| 5308 | p->decoding_buf = make_uninit_string (carryover); | 5300 | coding->carryover_bytes); |
| 5309 | bcopy (chars + coding->consumed, SDATA (p->decoding_buf), | 5301 | p->decoding_carryover = coding->carryover_bytes; |
| 5310 | carryover); | 5302 | } |
| 5311 | p->decoding_carryover = carryover; | ||
| 5312 | |||
| 5313 | /* Adjust the multibyteness of TEXT to that of the buffer. */ | 5303 | /* Adjust the multibyteness of TEXT to that of the buffer. */ |
| 5314 | if (NILP (current_buffer->enable_multibyte_characters) | 5304 | if (NILP (current_buffer->enable_multibyte_characters) |
| 5315 | != ! STRING_MULTIBYTE (text)) | 5305 | != ! STRING_MULTIBYTE (text)) |
| @@ -5431,24 +5421,19 @@ send_process (proc, buf, len, object) | |||
| 5431 | error ("Output file descriptor of %s is closed", SDATA (p->name)); | 5421 | error ("Output file descriptor of %s is closed", SDATA (p->name)); |
| 5432 | 5422 | ||
| 5433 | coding = proc_encode_coding_system[p->outfd]; | 5423 | coding = proc_encode_coding_system[p->outfd]; |
| 5434 | Vlast_coding_system_used = coding->symbol; | 5424 | Vlast_coding_system_used = CODING_ID_NAME (coding->id); |
| 5435 | 5425 | ||
| 5436 | if ((STRINGP (object) && STRING_MULTIBYTE (object)) | 5426 | if ((STRINGP (object) && STRING_MULTIBYTE (object)) |
| 5437 | || (BUFFERP (object) | 5427 | || (BUFFERP (object) |
| 5438 | && !NILP (XBUFFER (object)->enable_multibyte_characters)) | 5428 | && !NILP (XBUFFER (object)->enable_multibyte_characters)) |
| 5439 | || EQ (object, Qt)) | 5429 | || EQ (object, Qt)) |
| 5440 | { | 5430 | { |
| 5441 | if (!EQ (coding->symbol, p->encode_coding_system)) | 5431 | if (!EQ (Vlast_coding_system_used, p->encode_coding_system)) |
| 5442 | /* The coding system for encoding was changed to raw-text | 5432 | /* The coding system for encoding was changed to raw-text |
| 5443 | because we sent a unibyte text previously. Now we are | 5433 | because we sent a unibyte text previously. Now we are |
| 5444 | sending a multibyte text, thus we must encode it by the | 5434 | sending a multibyte text, thus we must encode it by the |
| 5445 | original coding system specified for the current process. */ | 5435 | original coding system specified for the current process. */ |
| 5446 | setup_coding_system (p->encode_coding_system, coding); | 5436 | setup_coding_system (p->encode_coding_system, coding); |
| 5447 | if (coding->eol_type == CODING_EOL_UNDECIDED) | ||
| 5448 | coding->eol_type = system_eol_type; | ||
| 5449 | /* src_multibyte should be set to 1 _after_ a call to | ||
| 5450 | setup_coding_system, since it resets src_multibyte to | ||
| 5451 | zero. */ | ||
| 5452 | coding->src_multibyte = 1; | 5437 | coding->src_multibyte = 1; |
| 5453 | } | 5438 | } |
| 5454 | else | 5439 | else |
| @@ -5456,60 +5441,56 @@ send_process (proc, buf, len, object) | |||
| 5456 | /* For sending a unibyte text, character code conversion should | 5441 | /* For sending a unibyte text, character code conversion should |
| 5457 | not take place but EOL conversion should. So, setup raw-text | 5442 | not take place but EOL conversion should. So, setup raw-text |
| 5458 | or one of the subsidiary if we have not yet done it. */ | 5443 | or one of the subsidiary if we have not yet done it. */ |
| 5459 | if (coding->type != coding_type_raw_text) | 5444 | if (CODING_REQUIRE_ENCODING (coding)) |
| 5460 | { | 5445 | { |
| 5461 | if (CODING_REQUIRE_FLUSHING (coding)) | 5446 | if (CODING_REQUIRE_FLUSHING (coding)) |
| 5462 | { | 5447 | { |
| 5463 | /* But, before changing the coding, we must flush out data. */ | 5448 | /* But, before changing the coding, we must flush out data. */ |
| 5464 | coding->mode |= CODING_MODE_LAST_BLOCK; | 5449 | coding->mode |= CODING_MODE_LAST_BLOCK; |
| 5465 | send_process (proc, "", 0, Qt); | 5450 | send_process (proc, "", 0, Qt); |
| 5451 | coding->mode &= CODING_MODE_LAST_BLOCK; | ||
| 5466 | } | 5452 | } |
| 5453 | setup_coding_system (raw_text_coding_system | ||
| 5454 | (Vlast_coding_system_used), | ||
| 5455 | coding); | ||
| 5467 | coding->src_multibyte = 0; | 5456 | coding->src_multibyte = 0; |
| 5468 | setup_raw_text_coding_system (coding); | ||
| 5469 | } | 5457 | } |
| 5470 | } | 5458 | } |
| 5471 | coding->dst_multibyte = 0; | 5459 | coding->dst_multibyte = 0; |
| 5472 | 5460 | ||
| 5473 | if (CODING_REQUIRE_ENCODING (coding)) | 5461 | if (CODING_REQUIRE_ENCODING (coding)) |
| 5474 | { | 5462 | { |
| 5475 | int require = encoding_buffer_size (coding, len); | 5463 | coding->dst_object = Qt; |
| 5476 | int from_byte = -1, from = -1, to = -1; | ||
| 5477 | |||
| 5478 | if (BUFFERP (object)) | 5464 | if (BUFFERP (object)) |
| 5479 | { | 5465 | { |
| 5480 | from_byte = BUF_PTR_BYTE_POS (XBUFFER (object), buf); | 5466 | int from_byte, from, to; |
| 5481 | from = buf_bytepos_to_charpos (XBUFFER (object), from_byte); | 5467 | int save_pt, save_pt_byte; |
| 5482 | to = buf_bytepos_to_charpos (XBUFFER (object), from_byte + len); | 5468 | struct buffer *cur = current_buffer; |
| 5469 | |||
| 5470 | set_buffer_internal (XBUFFER (object)); | ||
| 5471 | save_pt = PT, save_pt_byte = PT_BYTE; | ||
| 5472 | |||
| 5473 | from_byte = PTR_BYTE_POS (buf); | ||
| 5474 | from = BYTE_TO_CHAR (from_byte); | ||
| 5475 | to = BYTE_TO_CHAR (from_byte + len); | ||
| 5476 | TEMP_SET_PT_BOTH (from, from_byte); | ||
| 5477 | encode_coding_object (coding, object, from, from_byte, | ||
| 5478 | to, from_byte + len, Qt); | ||
| 5479 | TEMP_SET_PT_BOTH (save_pt, save_pt_byte); | ||
| 5480 | set_buffer_internal (cur); | ||
| 5483 | } | 5481 | } |
| 5484 | else if (STRINGP (object)) | 5482 | else if (STRINGP (object)) |
| 5485 | { | 5483 | { |
| 5486 | from_byte = buf - SDATA (object); | 5484 | encode_coding_string (coding, object, 1); |
| 5487 | from = string_byte_to_char (object, from_byte); | ||
| 5488 | to = string_byte_to_char (object, from_byte + len); | ||
| 5489 | } | 5485 | } |
| 5490 | 5486 | else | |
| 5491 | if (coding->composing != COMPOSITION_DISABLED) | ||
| 5492 | { | 5487 | { |
| 5493 | if (from_byte >= 0) | 5488 | coding->dst_object = make_unibyte_string (buf, len); |
| 5494 | coding_save_composition (coding, from, to, object); | 5489 | coding->produced = len; |
| 5495 | else | ||
| 5496 | coding->composing = COMPOSITION_DISABLED; | ||
| 5497 | } | 5490 | } |
| 5498 | 5491 | ||
| 5499 | if (SBYTES (p->encoding_buf) < require) | ||
| 5500 | p->encoding_buf = make_uninit_string (require); | ||
| 5501 | |||
| 5502 | if (from_byte >= 0) | ||
| 5503 | buf = (BUFFERP (object) | ||
| 5504 | ? BUF_BYTE_ADDRESS (XBUFFER (object), from_byte) | ||
| 5505 | : SDATA (object) + from_byte); | ||
| 5506 | |||
| 5507 | object = p->encoding_buf; | ||
| 5508 | encode_coding (coding, (char *) buf, SDATA (object), | ||
| 5509 | len, SBYTES (object)); | ||
| 5510 | coding_free_composition_data (coding); | ||
| 5511 | len = coding->produced; | 5492 | len = coding->produced; |
| 5512 | buf = SDATA (object); | 5493 | buf = SDATA (coding->dst_object); |
| 5513 | } | 5494 | } |
| 5514 | 5495 | ||
| 5515 | #ifdef VMS | 5496 | #ifdef VMS |
| @@ -5703,91 +5684,6 @@ send_process (proc, buf, len, object) | |||
| 5703 | UNGCPRO; | 5684 | UNGCPRO; |
| 5704 | } | 5685 | } |
| 5705 | 5686 | ||
| 5706 | static Lisp_Object | ||
| 5707 | send_process_object_unwind (buf) | ||
| 5708 | Lisp_Object buf; | ||
| 5709 | { | ||
| 5710 | Lisp_Object tembuf; | ||
| 5711 | |||
| 5712 | if (XBUFFER (buf) == current_buffer) | ||
| 5713 | return Qnil; | ||
| 5714 | tembuf = Fcurrent_buffer (); | ||
| 5715 | Fset_buffer (buf); | ||
| 5716 | Fkill_buffer (tembuf); | ||
| 5717 | return Qnil; | ||
| 5718 | } | ||
| 5719 | |||
| 5720 | /* Send current contents of region between START and END to PROC. | ||
| 5721 | If START is a string, send it instead. | ||
| 5722 | This function can evaluate Lisp code and can garbage collect. */ | ||
| 5723 | |||
| 5724 | static void | ||
| 5725 | send_process_object (proc, start, end) | ||
| 5726 | Lisp_Object proc, start, end; | ||
| 5727 | { | ||
| 5728 | int count = SPECPDL_INDEX (); | ||
| 5729 | Lisp_Object object = STRINGP (start) ? start : Fcurrent_buffer (); | ||
| 5730 | struct buffer *given_buffer = current_buffer; | ||
| 5731 | unsigned char *buf; | ||
| 5732 | int len; | ||
| 5733 | |||
| 5734 | record_unwind_protect (send_process_object_unwind, Fcurrent_buffer ()); | ||
| 5735 | |||
| 5736 | if (STRINGP (object) ? STRING_MULTIBYTE (object) | ||
| 5737 | : ! NILP (XBUFFER (object)->enable_multibyte_characters)) | ||
| 5738 | { | ||
| 5739 | struct Lisp_Process *p = XPROCESS (proc); | ||
| 5740 | struct coding_system *coding; | ||
| 5741 | |||
| 5742 | if (p->raw_status_new) | ||
| 5743 | update_status (p); | ||
| 5744 | if (! EQ (p->status, Qrun)) | ||
| 5745 | error ("Process %s not running", SDATA (p->name)); | ||
| 5746 | if (p->outfd < 0) | ||
| 5747 | error ("Output file descriptor of %s is closed", SDATA (p->name)); | ||
| 5748 | |||
| 5749 | coding = proc_encode_coding_system[p->outfd]; | ||
| 5750 | if (! EQ (coding->symbol, p->encode_coding_system)) | ||
| 5751 | /* The coding system for encoding was changed to raw-text | ||
| 5752 | because we sent a unibyte text previously. Now we are | ||
| 5753 | sending a multibyte text, thus we must encode it by the | ||
| 5754 | original coding system specified for the current process. */ | ||
| 5755 | setup_coding_system (p->encode_coding_system, coding); | ||
| 5756 | if (! NILP (coding->pre_write_conversion)) | ||
| 5757 | { | ||
| 5758 | struct gcpro gcpro1, gcpro2; | ||
| 5759 | |||
| 5760 | GCPRO2 (proc, object); | ||
| 5761 | call2 (coding->pre_write_conversion, start, end); | ||
| 5762 | UNGCPRO; | ||
| 5763 | if (given_buffer != current_buffer) | ||
| 5764 | { | ||
| 5765 | start = make_number (BEGV), end = make_number (ZV); | ||
| 5766 | object = Fcurrent_buffer (); | ||
| 5767 | } | ||
| 5768 | } | ||
| 5769 | } | ||
| 5770 | |||
| 5771 | if (BUFFERP (object)) | ||
| 5772 | { | ||
| 5773 | EMACS_INT start_byte; | ||
| 5774 | |||
| 5775 | if (XINT (start) < GPT && XINT (end) > GPT) | ||
| 5776 | move_gap (XINT (end)); | ||
| 5777 | start_byte = CHAR_TO_BYTE (XINT (start)); | ||
| 5778 | buf = BYTE_POS_ADDR (start_byte); | ||
| 5779 | len = CHAR_TO_BYTE (XINT (end)) - start_byte; | ||
| 5780 | } | ||
| 5781 | else | ||
| 5782 | { | ||
| 5783 | buf = SDATA (object); | ||
| 5784 | len = SBYTES (object); | ||
| 5785 | } | ||
| 5786 | send_process (proc, buf, len, object); | ||
| 5787 | |||
| 5788 | unbind_to (count, Qnil); | ||
| 5789 | } | ||
| 5790 | |||
| 5791 | DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region, | 5687 | DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region, |
| 5792 | 3, 3, 0, | 5688 | 3, 3, 0, |
| 5793 | doc: /* Send current contents of region as input to PROCESS. | 5689 | doc: /* Send current contents of region as input to PROCESS. |
| @@ -5801,10 +5697,19 @@ Output from processes can arrive in between bunches. */) | |||
| 5801 | Lisp_Object process, start, end; | 5697 | Lisp_Object process, start, end; |
| 5802 | { | 5698 | { |
| 5803 | Lisp_Object proc; | 5699 | Lisp_Object proc; |
| 5700 | int start1, end1; | ||
| 5804 | 5701 | ||
| 5805 | proc = get_process (process); | 5702 | proc = get_process (process); |
| 5806 | validate_region (&start, &end); | 5703 | validate_region (&start, &end); |
| 5807 | send_process_object (proc, start, end); | 5704 | |
| 5705 | if (XINT (start) < GPT && XINT (end) > GPT) | ||
| 5706 | move_gap (XINT (start)); | ||
| 5707 | |||
| 5708 | start1 = CHAR_TO_BYTE (XINT (start)); | ||
| 5709 | end1 = CHAR_TO_BYTE (XINT (end)); | ||
| 5710 | send_process (proc, BYTE_POS_ADDR (start1), end1 - start1, | ||
| 5711 | Fcurrent_buffer ()); | ||
| 5712 | |||
| 5808 | return Qnil; | 5713 | return Qnil; |
| 5809 | } | 5714 | } |
| 5810 | 5715 | ||
| @@ -5822,7 +5727,8 @@ Output from processes can arrive in between bunches. */) | |||
| 5822 | Lisp_Object proc; | 5727 | Lisp_Object proc; |
| 5823 | CHECK_STRING (string); | 5728 | CHECK_STRING (string); |
| 5824 | proc = get_process (process); | 5729 | proc = get_process (process); |
| 5825 | send_process_object (proc, string, Qnil); | 5730 | send_process (proc, SDATA (string), |
| 5731 | SBYTES (string), string); | ||
| 5826 | return Qnil; | 5732 | return Qnil; |
| 5827 | } | 5733 | } |
| 5828 | 5734 | ||
| @@ -6471,10 +6377,10 @@ kill_buffer_processes (buffer) | |||
| 6471 | { | 6377 | { |
| 6472 | Lisp_Object tail, proc; | 6378 | Lisp_Object tail, proc; |
| 6473 | 6379 | ||
| 6474 | for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) | 6380 | for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) |
| 6475 | { | 6381 | { |
| 6476 | proc = XCDR (XCAR (tail)); | 6382 | proc = XCDR (XCAR (tail)); |
| 6477 | if (GC_PROCESSP (proc) | 6383 | if (PROCESSP (proc) |
| 6478 | && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) | 6384 | && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) |
| 6479 | { | 6385 | { |
| 6480 | if (NETCONN_P (proc)) | 6386 | if (NETCONN_P (proc)) |
| @@ -6569,11 +6475,11 @@ sigchld_handler (signo) | |||
| 6569 | /* Find the process that signaled us, and record its status. */ | 6475 | /* Find the process that signaled us, and record its status. */ |
| 6570 | 6476 | ||
| 6571 | /* The process can have been deleted by Fdelete_process. */ | 6477 | /* The process can have been deleted by Fdelete_process. */ |
| 6572 | for (tail = deleted_pid_list; GC_CONSP (tail); tail = XCDR (tail)) | 6478 | for (tail = deleted_pid_list; CONSP (tail); tail = XCDR (tail)) |
| 6573 | { | 6479 | { |
| 6574 | Lisp_Object xpid = XCAR (tail); | 6480 | Lisp_Object xpid = XCAR (tail); |
| 6575 | if ((GC_INTEGERP (xpid) && pid == (pid_t) XINT (xpid)) | 6481 | if ((INTEGERP (xpid) && pid == (pid_t) XINT (xpid)) |
| 6576 | || (GC_FLOATP (xpid) && pid == (pid_t) XFLOAT_DATA (xpid))) | 6482 | || (FLOATP (xpid) && pid == (pid_t) XFLOAT_DATA (xpid))) |
| 6577 | { | 6483 | { |
| 6578 | XSETCAR (tail, Qnil); | 6484 | XSETCAR (tail, Qnil); |
| 6579 | goto sigchld_end_of_loop; | 6485 | goto sigchld_end_of_loop; |
| @@ -6582,11 +6488,11 @@ sigchld_handler (signo) | |||
| 6582 | 6488 | ||
| 6583 | /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ | 6489 | /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ |
| 6584 | p = 0; | 6490 | p = 0; |
| 6585 | for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) | 6491 | for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) |
| 6586 | { | 6492 | { |
| 6587 | proc = XCDR (XCAR (tail)); | 6493 | proc = XCDR (XCAR (tail)); |
| 6588 | p = XPROCESS (proc); | 6494 | p = XPROCESS (proc); |
| 6589 | if (GC_EQ (p->childp, Qt) && p->pid == pid) | 6495 | if (EQ (p->childp, Qt) && p->pid == pid) |
| 6590 | break; | 6496 | break; |
| 6591 | p = 0; | 6497 | p = 0; |
| 6592 | } | 6498 | } |
| @@ -6594,7 +6500,7 @@ sigchld_handler (signo) | |||
| 6594 | /* Look for an asynchronous process whose pid hasn't been filled | 6500 | /* Look for an asynchronous process whose pid hasn't been filled |
| 6595 | in yet. */ | 6501 | in yet. */ |
| 6596 | if (p == 0) | 6502 | if (p == 0) |
| 6597 | for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) | 6503 | for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) |
| 6598 | { | 6504 | { |
| 6599 | proc = XCDR (XCAR (tail)); | 6505 | proc = XCDR (XCAR (tail)); |
| 6600 | p = XPROCESS (proc); | 6506 | p = XPROCESS (proc); |
| @@ -6917,7 +6823,7 @@ encode subprocess input. */) | |||
| 6917 | error ("Output file descriptor of %s closed", SDATA (p->name)); | 6823 | error ("Output file descriptor of %s closed", SDATA (p->name)); |
| 6918 | Fcheck_coding_system (decoding); | 6824 | Fcheck_coding_system (decoding); |
| 6919 | Fcheck_coding_system (encoding); | 6825 | Fcheck_coding_system (encoding); |
| 6920 | 6826 | encoding = coding_inherit_eol_type (encoding, Qnil); | |
| 6921 | p->decode_coding_system = decoding; | 6827 | p->decode_coding_system = decoding; |
| 6922 | p->encode_coding_system = encoding; | 6828 | p->encode_coding_system = encoding; |
| 6923 | setup_process_coding_systems (process); | 6829 | setup_process_coding_systems (process); |
| @@ -7336,7 +7242,7 @@ The variable takes effect when `start-process' is called. */); | |||
| 7336 | 7242 | ||
| 7337 | #include "lisp.h" | 7243 | #include "lisp.h" |
| 7338 | #include "systime.h" | 7244 | #include "systime.h" |
| 7339 | #include "charset.h" | 7245 | #include "character.h" |
| 7340 | #include "coding.h" | 7246 | #include "coding.h" |
| 7341 | #include "termopts.h" | 7247 | #include "termopts.h" |
| 7342 | #include "sysselect.h" | 7248 | #include "sysselect.h" |