diff options
| author | Kenichi Handa | 2002-03-01 01:45:23 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-03-01 01:45:23 +0000 |
| commit | 5bbf78c1f9fee19872be7557580219d2795d6d64 (patch) | |
| tree | c82ee7bc9f66001f02688ba4f110dadb1d91619a /src/process.c | |
| parent | 8b4b4467b507ed2f43a58a3537f68776fedfa240 (diff) | |
| download | emacs-5bbf78c1f9fee19872be7557580219d2795d6d64.tar.gz emacs-5bbf78c1f9fee19872be7557580219d2795d6d64.zip | |
Include "character.h" instead of "charset.h".
(read_process_output): Adjusted for the new code-conversion API.
(send_process): Likewise.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 99 |
1 files changed, 45 insertions, 54 deletions
diff --git a/src/process.c b/src/process.c index 56d3a67e8d1..4b009e2b076 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -98,7 +98,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 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" |
| @@ -3011,17 +3011,17 @@ read_process_output (proc, channel) | |||
| 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 |
| @@ -3037,8 +3037,8 @@ read_process_output (proc, channel) | |||
| 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 | } |
| @@ -3128,19 +3128,19 @@ read_process_output (proc, channel) | |||
| 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 | } |
| @@ -3269,86 +3269,77 @@ send_process (proc, buf, len, object) | |||
| 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) | ||
| 3330 | { | 3336 | { |
| 3331 | if (from_byte >= 0) | 3337 | coding->dst_object = make_unibyte_string (buf, len); |
| 3332 | coding_save_composition (coding, from, to, object); | 3338 | coding->produced = len; |
| 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 |
| @@ -4726,7 +4717,7 @@ The value takes effect when `start-process' is called. */); | |||
| 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" |