comparison src/process.c @ 32864:21acd0c60f5d

(send_process): If OBJECT is t, it means that the data is from C string, but we should encode it. Before calling setup_raw_text_coding_system, be sure to flush out data by the previous coding system.
author Kenichi Handa <handa@m17n.org>
date Wed, 25 Oct 2000 11:06:51 +0000
parents 11b8c07e5fed
children 642fb6c53a10
comparison
equal deleted inserted replaced
32863:0a4d038159dd 32864:21acd0c60f5d
3183 longjmp (send_process_frame, 1); 3183 longjmp (send_process_frame, 1);
3184 } 3184 }
3185 3185
3186 /* Send some data to process PROC. 3186 /* Send some data to process PROC.
3187 BUF is the beginning of the data; LEN is the number of characters. 3187 BUF is the beginning of the data; LEN is the number of characters.
3188 OBJECT is the Lisp object that the data comes from. 3188 OBJECT is the Lisp object that the data comes from. If OBJECT is
3189 3189 nil or t, it means that the data comes from C string.
3190 The data is encoded by PROC's coding-system for encoding before it 3190
3191 is sent. But if the data ends at the middle of multi-byte 3191 If OBJECT is not nil, the data is encoded by PROC's coding-system
3192 representation, that incomplete sequence of bytes are sent without 3192 for encoding before it is sent.
3193 being encoded. Should we store them in a buffer to prepend them to
3194 the data send later?
3195 3193
3196 This function can evaluate Lisp code and can garbage collect. */ 3194 This function can evaluate Lisp code and can garbage collect. */
3197 3195
3198 void 3196 void
3199 send_process (proc, buf, len, object) 3197 send_process (proc, buf, len, object)
3226 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; 3224 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];
3227 Vlast_coding_system_used = coding->symbol; 3225 Vlast_coding_system_used = coding->symbol;
3228 3226
3229 if ((STRINGP (object) && STRING_MULTIBYTE (object)) 3227 if ((STRINGP (object) && STRING_MULTIBYTE (object))
3230 || (BUFFERP (object) 3228 || (BUFFERP (object)
3231 && !NILP (XBUFFER (object)->enable_multibyte_characters))) 3229 && !NILP (XBUFFER (object)->enable_multibyte_characters))
3230 || EQ (object, Qt))
3232 { 3231 {
3233 coding->src_multibyte = 1; 3232 coding->src_multibyte = 1;
3234 if (!EQ (coding->symbol, XPROCESS (proc)->encode_coding_system)) 3233 if (!EQ (coding->symbol, XPROCESS (proc)->encode_coding_system))
3235 /* The coding system for encoding was changed to raw-text 3234 /* The coding system for encoding was changed to raw-text
3236 because we sent a unibyte text previously. Now we are 3235 because we sent a unibyte text previously. Now we are
3240 setup_coding_system (XPROCESS (proc)->encode_coding_system, 3239 setup_coding_system (XPROCESS (proc)->encode_coding_system,
3241 coding); 3240 coding);
3242 } 3241 }
3243 else 3242 else
3244 { 3243 {
3245 coding->src_multibyte = 0; 3244 /* For sending a unibyte text, character code conversion should
3246 /* For sending a unibyte text, character code conversion 3245 not take place but EOL conversion should. So, setup raw-text
3247 should not take place but EOL conversion should. So, setup 3246 or one of the subsidiary if we have not yet done it. */
3248 raw-text or one of the subsidiary. */ 3247 if (coding->type != coding_type_raw_text)
3249 setup_raw_text_coding_system (coding); 3248 {
3249 if (CODING_REQUIRE_FLUSHING (coding))
3250 {
3251 /* But, before changing the coding, we must flush out data. */
3252 coding->mode |= CODING_MODE_LAST_BLOCK;
3253 send_process (proc, "", 0, Qt);
3254 }
3255 coding->src_multibyte = 0;
3256 setup_raw_text_coding_system (coding);
3257 }
3250 } 3258 }
3251 coding->dst_multibyte = 0; 3259 coding->dst_multibyte = 0;
3252 3260
3253 if (CODING_REQUIRE_ENCODING (coding)) 3261 if (CODING_REQUIRE_ENCODING (coding))
3254 { 3262 {