Mercurial > emacs
comparison src/process.c @ 88385:c60e206fcf58
Include "character.h" instead of "charset.h".
(read_process_output): Adjusted for the new code-conversion API.
(send_process): Likewise.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 01 Mar 2002 01:45:23 +0000 |
parents | 93254645e03b |
children | 0358964d3d98 |
comparison
equal
deleted
inserted
replaced
88384:4bff91d684f4 | 88385:c60e206fcf58 |
---|---|
96 #include "systty.h" | 96 #include "systty.h" |
97 | 97 |
98 #include "lisp.h" | 98 #include "lisp.h" |
99 #include "window.h" | 99 #include "window.h" |
100 #include "buffer.h" | 100 #include "buffer.h" |
101 #include "charset.h" | 101 #include "character.h" |
102 #include "coding.h" | 102 #include "coding.h" |
103 #include "process.h" | 103 #include "process.h" |
104 #include "termhooks.h" | 104 #include "termhooks.h" |
105 #include "termopts.h" | 105 #include "termopts.h" |
106 #include "commands.h" | 106 #include "commands.h" |
3009 | 3009 |
3010 /* For speed, if a search happens within this code, | 3010 /* For speed, if a search happens within this code, |
3011 save the match data in a special nonrecursive fashion. */ | 3011 save the match data in a special nonrecursive fashion. */ |
3012 running_asynch_code = 1; | 3012 running_asynch_code = 1; |
3013 | 3013 |
3014 text = decode_coding_string (make_unibyte_string (chars, nbytes), | 3014 decode_coding_c_string (coding, chars, nbytes, Qt); |
3015 coding, 0); | 3015 text = coding->dst_object; |
3016 if (NILP (buffer_defaults.enable_multibyte_characters)) | 3016 if (NILP (buffer_defaults.enable_multibyte_characters)) |
3017 /* We had better return unibyte string. */ | 3017 /* We had better return unibyte string. */ |
3018 text = string_make_unibyte (text); | 3018 text = string_make_unibyte (text); |
3019 | 3019 |
3020 Vlast_coding_system_used = coding->symbol; | 3020 Vlast_coding_system_used = CODING_ID_NAME (coding->id); |
3021 /* A new coding system might be found. */ | 3021 /* A new coding system might be found. */ |
3022 if (!EQ (p->decode_coding_system, coding->symbol)) | 3022 if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) |
3023 { | 3023 { |
3024 p->decode_coding_system = coding->symbol; | 3024 p->decode_coding_system = Vlast_coding_system_used; |
3025 | 3025 |
3026 /* Don't call setup_coding_system for | 3026 /* Don't call setup_coding_system for |
3027 proc_decode_coding_system[channel] here. It is done in | 3027 proc_decode_coding_system[channel] here. It is done in |
3028 detect_coding called via decode_coding above. */ | 3028 detect_coding called via decode_coding above. */ |
3029 | 3029 |
3035 valid memory because p->outfd will be changed once EOF is | 3035 valid memory because p->outfd will be changed once EOF is |
3036 sent to the process. */ | 3036 sent to the process. */ |
3037 if (NILP (p->encode_coding_system) | 3037 if (NILP (p->encode_coding_system) |
3038 && proc_encode_coding_system[XINT (p->outfd)]) | 3038 && proc_encode_coding_system[XINT (p->outfd)]) |
3039 { | 3039 { |
3040 p->encode_coding_system = coding->symbol; | 3040 p->encode_coding_system = Vlast_coding_system_used; |
3041 setup_coding_system (coding->symbol, | 3041 setup_coding_system (p->encode_coding_system, |
3042 proc_encode_coding_system[XINT (p->outfd)]); | 3042 proc_encode_coding_system[XINT (p->outfd)]); |
3043 } | 3043 } |
3044 } | 3044 } |
3045 | 3045 |
3046 carryover = nbytes - coding->consumed; | 3046 carryover = nbytes - coding->consumed; |
3126 /* If the output marker is outside of the visible region, save | 3126 /* If the output marker is outside of the visible region, save |
3127 the restriction and widen. */ | 3127 the restriction and widen. */ |
3128 if (! (BEGV <= PT && PT <= ZV)) | 3128 if (! (BEGV <= PT && PT <= ZV)) |
3129 Fwiden (); | 3129 Fwiden (); |
3130 | 3130 |
3131 text = decode_coding_string (make_unibyte_string (chars, nbytes), | 3131 decode_coding_c_string (coding, chars, nbytes, Qt); |
3132 coding, 0); | 3132 text = coding->dst_object; |
3133 Vlast_coding_system_used = coding->symbol; | 3133 Vlast_coding_system_used = CODING_ID_NAME (coding->id); |
3134 /* A new coding system might be found. See the comment in the | 3134 /* A new coding system might be found. See the comment in the |
3135 similar code in the previous `if' block. */ | 3135 similar code in the previous `if' block. */ |
3136 if (!EQ (p->decode_coding_system, coding->symbol)) | 3136 if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) |
3137 { | 3137 { |
3138 p->decode_coding_system = coding->symbol; | 3138 p->decode_coding_system = Vlast_coding_system_used; |
3139 if (NILP (p->encode_coding_system) | 3139 if (NILP (p->encode_coding_system) |
3140 && proc_encode_coding_system[XINT (p->outfd)]) | 3140 && proc_encode_coding_system[XINT (p->outfd)]) |
3141 { | 3141 { |
3142 p->encode_coding_system = coding->symbol; | 3142 p->encode_coding_system = Vlast_coding_system_used; |
3143 setup_coding_system (coding->symbol, | 3143 setup_coding_system (p->encode_coding_system, |
3144 proc_encode_coding_system[XINT (p->outfd)]); | 3144 proc_encode_coding_system[XINT (p->outfd)]); |
3145 } | 3145 } |
3146 } | 3146 } |
3147 carryover = nbytes - coding->consumed; | 3147 carryover = nbytes - coding->consumed; |
3148 bcopy (chars + coding->consumed, XSTRING (p->decoding_buf)->data, | 3148 bcopy (chars + coding->consumed, XSTRING (p->decoding_buf)->data, |
3267 if (XINT (XPROCESS (proc)->outfd) < 0) | 3267 if (XINT (XPROCESS (proc)->outfd) < 0) |
3268 error ("Output file descriptor of %s is closed", | 3268 error ("Output file descriptor of %s is closed", |
3269 XSTRING (XPROCESS (proc)->name)->data); | 3269 XSTRING (XPROCESS (proc)->name)->data); |
3270 | 3270 |
3271 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; | 3271 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; |
3272 Vlast_coding_system_used = coding->symbol; | 3272 Vlast_coding_system_used = CODING_ID_NAME (coding->id); |
3273 | 3273 |
3274 if ((STRINGP (object) && STRING_MULTIBYTE (object)) | 3274 if ((STRINGP (object) && STRING_MULTIBYTE (object)) |
3275 || (BUFFERP (object) | 3275 || (BUFFERP (object) |
3276 && !NILP (XBUFFER (object)->enable_multibyte_characters)) | 3276 && !NILP (XBUFFER (object)->enable_multibyte_characters)) |
3277 || EQ (object, Qt)) | 3277 || EQ (object, Qt)) |
3278 { | 3278 { |
3279 if (!EQ (coding->symbol, XPROCESS (proc)->encode_coding_system)) | 3279 if (!EQ (Vlast_coding_system_used, |
3280 XPROCESS (proc)->encode_coding_system)) | |
3280 /* The coding system for encoding was changed to raw-text | 3281 /* The coding system for encoding was changed to raw-text |
3281 because we sent a unibyte text previously. Now we are | 3282 because we sent a unibyte text previously. Now we are |
3282 sending a multibyte text, thus we must encode it by the | 3283 sending a multibyte text, thus we must encode it by the |
3283 original coding system specified for the current | 3284 original coding system specified for the current |
3284 process. */ | 3285 process. */ |
3285 setup_coding_system (XPROCESS (proc)->encode_coding_system, coding); | 3286 setup_coding_system (XPROCESS (proc)->encode_coding_system, coding); |
3286 /* src_multibyte should be set to 1 _after_ a call to | |
3287 setup_coding_system, since it resets src_multibyte to | |
3288 zero. */ | |
3289 coding->src_multibyte = 1; | |
3290 } | 3287 } |
3291 else | 3288 else |
3292 { | 3289 { |
3293 /* For sending a unibyte text, character code conversion should | 3290 /* For sending a unibyte text, character code conversion should |
3294 not take place but EOL conversion should. So, setup raw-text | 3291 not take place but EOL conversion should. So, setup raw-text |
3295 or one of the subsidiary if we have not yet done it. */ | 3292 or one of the subsidiary if we have not yet done it. */ |
3296 if (coding->type != coding_type_raw_text) | 3293 if (CODING_REQUIRE_ENCODING (coding)) |
3297 { | 3294 { |
3298 if (CODING_REQUIRE_FLUSHING (coding)) | 3295 if (CODING_REQUIRE_FLUSHING (coding)) |
3299 { | 3296 { |
3300 /* But, before changing the coding, we must flush out data. */ | 3297 /* But, before changing the coding, we must flush out data. */ |
3301 coding->mode |= CODING_MODE_LAST_BLOCK; | 3298 coding->mode |= CODING_MODE_LAST_BLOCK; |
3302 send_process (proc, "", 0, Qt); | 3299 send_process (proc, "", 0, Qt); |
3300 coding->mode &= ~CODING_MODE_LAST_BLOCK; | |
3303 } | 3301 } |
3304 coding->src_multibyte = 0; | 3302 coding->src_multibyte = 0; |
3305 setup_raw_text_coding_system (coding); | 3303 setup_coding_system (raw_text_coding_system |
3304 (Vlast_coding_system_used), | |
3305 coding); | |
3306 } | 3306 } |
3307 } | 3307 } |
3308 coding->dst_multibyte = 0; | 3308 coding->dst_multibyte = 0; |
3309 | 3309 |
3310 if (CODING_REQUIRE_ENCODING (coding)) | 3310 if (CODING_REQUIRE_ENCODING (coding)) |
3311 { | 3311 { |
3312 int require = encoding_buffer_size (coding, len); | 3312 coding->dst_object = Qt; |
3313 int from_byte = -1, from = -1, to = -1; | |
3314 unsigned char *temp_buf = NULL; | |
3315 | |
3316 if (BUFFERP (object)) | 3313 if (BUFFERP (object)) |
3317 { | 3314 { |
3318 from_byte = BUF_PTR_BYTE_POS (XBUFFER (object), buf); | 3315 int from_byte, from, to; |
3319 from = buf_bytepos_to_charpos (XBUFFER (object), from_byte); | 3316 int save_pt, save_pt_byte; |
3320 to = buf_bytepos_to_charpos (XBUFFER (object), from_byte + len); | 3317 struct buffer *cur = current_buffer; |
3318 | |
3319 set_buffer_internal (XBUFFER (object)); | |
3320 save_pt = PT, save_pt_byte = PT_BYTE; | |
3321 | |
3322 from_byte = PTR_BYTE_POS (buf); | |
3323 from = BYTE_TO_CHAR (from_byte); | |
3324 to = BYTE_TO_CHAR (from_byte + len); | |
3325 TEMP_SET_PT_BOTH (from, from_byte); | |
3326 encode_coding_object (coding, object, from, from_byte, | |
3327 to, from_byte + len, Qt); | |
3328 TEMP_SET_PT_BOTH (save_pt, save_pt_byte); | |
3329 set_buffer_internal (cur); | |
3321 } | 3330 } |
3322 else if (STRINGP (object)) | 3331 else if (STRINGP (object)) |
3323 { | 3332 { |
3324 from_byte = buf - XSTRING (object)->data; | 3333 encode_coding_string (coding, object, 1); |
3325 from = string_byte_to_char (object, from_byte); | |
3326 to = string_byte_to_char (object, from_byte + len); | |
3327 } | 3334 } |
3328 | 3335 else |
3329 if (coding->composing != COMPOSITION_DISABLED) | 3336 { |
3330 { | 3337 coding->dst_object = make_unibyte_string (buf, len); |
3331 if (from_byte >= 0) | 3338 coding->produced = len; |
3332 coding_save_composition (coding, from, to, object); | |
3333 else | |
3334 coding->composing = COMPOSITION_DISABLED; | |
3335 } | 3339 } |
3336 | 3340 |
3337 if (STRING_BYTES (XSTRING (XPROCESS (proc)->encoding_buf)) < require) | |
3338 XPROCESS (proc)->encoding_buf = make_uninit_string (require); | |
3339 | |
3340 if (from_byte >= 0) | |
3341 buf = (BUFFERP (object) | |
3342 ? BUF_BYTE_ADDRESS (XBUFFER (object), from_byte) | |
3343 : XSTRING (object)->data + from_byte); | |
3344 | |
3345 object = XPROCESS (proc)->encoding_buf; | |
3346 encode_coding (coding, (char *) buf, XSTRING (object)->data, | |
3347 len, STRING_BYTES (XSTRING (object))); | |
3348 len = coding->produced; | 3341 len = coding->produced; |
3349 buf = XSTRING (object)->data; | 3342 buf = XSTRING (coding->dst_object)->data; |
3350 if (temp_buf) | |
3351 xfree (temp_buf); | |
3352 } | 3343 } |
3353 | 3344 |
3354 #ifdef VMS | 3345 #ifdef VMS |
3355 vs = get_vms_process_pointer (p->pid); | 3346 vs = get_vms_process_pointer (p->pid); |
3356 if (vs == 0) | 3347 if (vs == 0) |
4724 #include <sys/types.h> | 4715 #include <sys/types.h> |
4725 #include <errno.h> | 4716 #include <errno.h> |
4726 | 4717 |
4727 #include "lisp.h" | 4718 #include "lisp.h" |
4728 #include "systime.h" | 4719 #include "systime.h" |
4729 #include "charset.h" | 4720 #include "character.h" |
4730 #include "coding.h" | 4721 #include "coding.h" |
4731 #include "termopts.h" | 4722 #include "termopts.h" |
4732 #include "sysselect.h" | 4723 #include "sysselect.h" |
4733 | 4724 |
4734 extern int frame_garbaged; | 4725 extern int frame_garbaged; |