Lisp_Object process;
{
struct Lisp_Process *p = XPROCESS (process);
- int inch = XINT (p->infd);
- int outch = XINT (p->outfd);
+ int inch = p->infd;
+ int outch = p->outfd;
+ Lisp_Object coding_system;
if (inch < 0 || outch < 0)
return;
if (!proc_decode_coding_system[inch])
proc_decode_coding_system[inch]
= (struct coding_system *) xmalloc (sizeof (struct coding_system));
- setup_coding_system (p->decode_coding_system,
- proc_decode_coding_system[inch]);
+ coding_system = p->decode_coding_system;
if (! NILP (p->filter))
{
- if (NILP (p->filter_multibyte))
+ if (!p->filter_multibyte)
- setup_raw_text_coding_system (proc_decode_coding_system[inch]);
+ coding_system = raw_text_coding_system (coding_system);
}
else if (BUFFERP (p->buffer))
{
valid memory because p->outfd will be changed once EOF is
sent to the process. */
if (NILP (p->encode_coding_system)
- && proc_encode_coding_system[XINT (p->outfd)])
+ && proc_encode_coding_system[p->outfd])
{
- p->encode_coding_system = coding->symbol;
- setup_coding_system (coding->symbol,
+ p->encode_coding_system
+ = coding_inherit_eol_type (Vlast_coding_system_used, Qnil);
+ setup_coding_system (p->encode_coding_system,
- proc_encode_coding_system[XINT (p->outfd)]);
+ proc_encode_coding_system[p->outfd]);
- if (proc_encode_coding_system[p->outfd]->eol_type
- == CODING_EOL_UNDECIDED)
- proc_encode_coding_system[p->outfd]->eol_type
- = system_eol_type;
}
}
- carryover = nbytes - coding->consumed;
- if (carryover < 0)
- abort ();
-
- if (SCHARS (p->decoding_buf) < carryover)
- p->decoding_buf = make_uninit_string (carryover);
- bcopy (chars + coding->consumed, SDATA (p->decoding_buf),
- carryover);
- p->decoding_carryover = carryover;
+ if (coding->carryover_bytes > 0)
+ {
+ if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
+ p->decoding_buf = make_uninit_string (coding->carryover_bytes);
+ bcopy (coding->carryover, SDATA (p->decoding_buf),
+ coding->carryover_bytes);
- XSETINT (p->decoding_carryover, coding->carryover_bytes);
++ p->decoding_carryover = coding->carryover_bytes;
+ }
/* Adjust the multibyteness of TEXT to that of the filter. */
- if (NILP (p->filter_multibyte) != ! STRING_MULTIBYTE (text))
+ if (p->filter_multibyte != STRING_MULTIBYTE (text))
text = (STRING_MULTIBYTE (text)
? Fstring_as_unibyte (text)
: Fstring_to_multibyte (text));
if (! (BEGV <= PT && PT <= ZV))
Fwiden ();
- text = decode_coding_string (make_unibyte_string (chars, nbytes),
- coding, 0);
- Vlast_coding_system_used = coding->symbol;
+ decode_coding_c_string (coding, chars, nbytes, Qt);
+ text = coding->dst_object;
+ Vlast_coding_system_used = CODING_ID_NAME (coding->id);
/* A new coding system might be found. See the comment in the
similar code in the previous `if' block. */
- if (!EQ (p->decode_coding_system, coding->symbol))
+ if (!EQ (p->decode_coding_system, Vlast_coding_system_used))
{
- p->decode_coding_system = coding->symbol;
+ p->decode_coding_system = Vlast_coding_system_used;
if (NILP (p->encode_coding_system)
- && proc_encode_coding_system[XINT (p->outfd)])
+ && proc_encode_coding_system[p->outfd])
{
- p->encode_coding_system = coding->symbol;
- setup_coding_system (coding->symbol,
+ p->encode_coding_system
+ = coding_inherit_eol_type (Vlast_coding_system_used, Qnil);
+ setup_coding_system (p->encode_coding_system,
- proc_encode_coding_system[XINT (p->outfd)]);
+ proc_encode_coding_system[p->outfd]);
- if (proc_encode_coding_system[p->outfd]->eol_type
- == CODING_EOL_UNDECIDED)
- proc_encode_coding_system[p->outfd]->eol_type
- = system_eol_type;
}
}
- carryover = nbytes - coding->consumed;
- if (carryover < 0)
- abort ();
-
- if (SCHARS (p->decoding_buf) < carryover)
- p->decoding_buf = make_uninit_string (carryover);
- bcopy (chars + coding->consumed, SDATA (p->decoding_buf),
- carryover);
- p->decoding_carryover = carryover;
-
+ if (coding->carryover_bytes > 0)
+ {
+ if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
+ p->decoding_buf = make_uninit_string (coding->carryover_bytes);
+ bcopy (coding->carryover, SDATA (p->decoding_buf),
+ coding->carryover_bytes);
- XSETINT (p->decoding_carryover, coding->carryover_bytes);
++ p->decoding_carryover = coding->carryover_bytes;
+ }
/* Adjust the multibyteness of TEXT to that of the buffer. */
if (NILP (current_buffer->enable_multibyte_characters)
!= ! STRING_MULTIBYTE (text))
update_status (p);
if (! EQ (p->status, Qrun))
error ("Process %s not running", SDATA (p->name));
- if (XINT (p->outfd) < 0)
+ if (p->outfd < 0)
error ("Output file descriptor of %s is closed", SDATA (p->name));
- coding = proc_encode_coding_system[XINT (p->outfd)];
+ coding = proc_encode_coding_system[p->outfd];
- Vlast_coding_system_used = coding->symbol;
+ Vlast_coding_system_used = CODING_ID_NAME (coding->id);
if ((STRINGP (object) && STRING_MULTIBYTE (object))
|| (BUFFERP (object)