SET_PT_BOTH (opoint, opoint_byte);
}
+static void
+read_process_output_set_last_coding_system (struct Lisp_Process *p,
+ struct coding_system *coding)
+{
+ Vlast_coding_system_used = CODING_ID_NAME (coding->id);
+ /* A new coding system might be found. */
+ if (!EQ (p->decode_coding_system, Vlast_coding_system_used))
+ {
+ pset_decode_coding_system (p, Vlast_coding_system_used);
+
+ /* Don't call setup_coding_system for
+ proc_decode_coding_system[channel] here. It is done in
+ detect_coding called via decode_coding above. */
+
+ /* If a coding system for encoding is not yet decided, we set
+ it as the same as coding-system for decoding.
+
+ But, before doing that we must check if
+ proc_encode_coding_system[p->outfd] surely points to a
+ valid memory because p->outfd will be changed once EOF is
+ sent to the process. */
+ eassert (p->outfd < FD_SETSIZE);
+ if (NILP (p->encode_coding_system) && p->outfd >= 0
+ && proc_encode_coding_system[p->outfd])
+ {
+ pset_encode_coding_system
+ (p, coding_inherit_eol_type (Vlast_coding_system_used, Qnil));
+ setup_coding_system (p->encode_coding_system,
+ proc_encode_coding_system[p->outfd]);
+ }
+ }
+
+ if (coding->carryover_bytes > 0)
+ {
+ if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
+ pset_decoding_buf (p, make_uninit_string (coding->carryover_bytes));
+ memcpy (SDATA (p->decoding_buf), coding->carryover,
+ coding->carryover_bytes);
+ p->decoding_carryover = coding->carryover_bytes;
+ }
+}
+
static void
read_and_insert_process_output (struct Lisp_Process *p, char *buf,
ssize_t nread,
else
{ /* We have to decode the input. */
Lisp_Object curbuf;
- int carryover = 0;
specpdl_ref count1 = SPECPDL_INDEX ();
XSETBUFFER (curbuf, current_buffer);
(unsigned char *) buf, nread, curbuf);
unbind_to (count1, Qnil);
+ read_process_output_set_last_coding_system (p, process_coding);
+
TEMP_SET_PT_BOTH (PT + process_coding->produced_char,
PT_BYTE + process_coding->produced);
signal_after_change (PT - process_coding->produced_char,
0, process_coding->produced_char);
- carryover = process_coding->carryover_bytes;
- if (carryover > 0)
- memcpy (buf, process_coding->carryover,
- process_coding->carryover_bytes);
}
read_process_output_after_insert (p, &old_read_only, old_begv, old_zv,
decode_coding_c_string (coding, (unsigned char *) chars, nbytes, Qt);
text = coding->dst_object;
- Vlast_coding_system_used = CODING_ID_NAME (coding->id);
- /* A new coding system might be found. */
- if (!EQ (p->decode_coding_system, Vlast_coding_system_used))
- {
- pset_decode_coding_system (p, Vlast_coding_system_used);
- /* Don't call setup_coding_system for
- proc_decode_coding_system[channel] here. It is done in
- detect_coding called via decode_coding above. */
+ read_process_output_set_last_coding_system (p, coding);
- /* If a coding system for encoding is not yet decided, we set
- it as the same as coding-system for decoding.
-
- But, before doing that we must check if
- proc_encode_coding_system[p->outfd] surely points to a
- valid memory because p->outfd will be changed once EOF is
- sent to the process. */
- eassert (p->outfd < FD_SETSIZE);
- if (NILP (p->encode_coding_system) && p->outfd >= 0
- && proc_encode_coding_system[p->outfd])
- {
- pset_encode_coding_system
- (p, coding_inherit_eol_type (Vlast_coding_system_used, Qnil));
- setup_coding_system (p->encode_coding_system,
- proc_encode_coding_system[p->outfd]);
- }
- }
-
- if (coding->carryover_bytes > 0)
- {
- if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
- pset_decoding_buf (p, make_uninit_string (coding->carryover_bytes));
- memcpy (SDATA (p->decoding_buf), coding->carryover,
- coding->carryover_bytes);
- p->decoding_carryover = coding->carryover_bytes;
- }
if (SBYTES (text) > 0)
/* FIXME: It's wrong to wrap or not based on debug-on-error, and
sometimes it's simply wrong to wrap (e.g. when called from