/* Maximum number of bytes to send to a pty without an eof. */
static int pty_max_bytes;
+extern Lisp_Object Vfile_name_coding_system;
+
#ifdef HAVE_PTYS
/* The file name of the pty opened by allocate_pty. */
/* Make the process marker point into the process buffer (if any). */
if (!NILP (buffer))
- Fset_marker (XPROCESS (proc)->mark,
- make_number (BUF_ZV (XBUFFER (buffer))), buffer);
+ set_marker_both (XPROCESS (proc)->mark, buffer,
+ BUF_ZV (XBUFFER (buffer)),
+ BUF_ZV_BYTE (XBUFFER (buffer)));
if (!NILP (buffer) && NILP (XBUFFER (buffer)->enable_multibyte_characters)
|| NILP (buffer) && NILP (buffer_defaults.enable_multibyte_characters))
XPROCESS (proc)->decoding_buf = make_uninit_string (0);
XPROCESS (proc)->encoding_buf = make_uninit_string (0);
- create_process (proc, new_argv, current_dir);
+ create_process (proc, (char **) new_argv, current_dir);
return unbind_to (count, proc);
}
#endif
#ifndef VMS /* VMS version of this function is in vmsproc.c. */
+void
create_process (process, new_argv, current_dir)
Lisp_Object process;
char **new_argv;
setup_coding_system (XPROCESS (process)->encode_coding_system,
proc_encode_coding_system[outchannel]);
+ if (CODING_REQUIRE_ENCODING (proc_encode_coding_system[outchannel]))
+ {
+ /* Here we encode arguments by the coding system used for
+ sending data to the process. We don't support using
+ different coding systems for encoding arguments and for
+ encoding data sent to the process. */
+ struct gcpro gcpro1;
+ int i = 1;
+ struct coding_system *coding = proc_encode_coding_system[outchannel];
+
+ coding->last_block = 1;
+ GCPRO1 (process);
+ while (new_argv[i] != 0)
+ {
+ int len = strlen (new_argv[i]);
+ int size = encoding_buffer_size (coding, len);
+ unsigned char *buf = (unsigned char *) alloca (size);
+ int produced, dmy;
+
+ produced = encode_coding (coding, new_argv[i], buf, len, size, &dmy);
+ buf[produced] = 0;
+ /* We don't have to free new_argv[i] because it points to a
+ Lisp string given as an argument to `start-process'. */
+ new_argv[i++] = buf;
+ }
+ UNGCPRO;
+ coding->last_block = 0;
+ }
+
/* Delay interrupts until we have a chance to store
the new fork's pid in its process structure */
#ifdef POSIX_SIGNALS
Protect it from permanent change. */
char **save_environ = environ;
+ current_dir
+ = Fencode_coding_string (current_dir, Vfile_name_coding_system, Qt);
+
#ifndef WINDOWSNT
pid = vfork ();
if (pid == 0)
}
#endif /* HAVE_SOCKETS */
+void
deactivate_process (proc)
Lisp_Object proc;
{
with subprocess. This is used in a newly-forked subprocess
to get rid of irrelevant descriptors. */
+void
close_process_descs ()
{
#ifndef WINDOWSNT
/* Now set NCHARS how many bytes we must decode. */
nchars += coding->carryover_size;
- if (! CODING_REQUIRE_NO_CONVERSION (coding))
+ if (CODING_REQUIRE_DECODING (coding)
+ || CODING_REQUIRE_DETECTION (coding))
{
int require = decoding_buffer_size (coding, nchars);
int consumed, produced;
proc_decode_coding_system[channel] here. It is done in
detect_coding called via decode_coding above. */
- /* If coding-system for encoding is not yet decided, we set it
- as the same as coding-system for decoding. */
- if (NILP (p->encode_coding_system))
+ /* If 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. */
+ if (NILP (p->encode_coding_system)
+ && proc_encode_coding_system[p->outfd])
{
p->encode_coding_system = coding->symbol;
setup_coding_system (coding->symbol,
- proc_encode_coding_system[channel]);
+ proc_encode_coding_system[p->outfd]);
}
}
#ifdef VMS
}
#endif
+ Vlast_coding_system_used = coding->symbol;
+
outstream = p->filter;
if (!NILP (outstream))
{
{
Lisp_Object old_read_only;
int old_begv, old_zv;
+ int old_begv_byte, old_zv_byte;
Lisp_Object odeactivate;
- int before;
+ int before, before_byte;
+ int opoint_byte;
odeactivate = Vdeactivate_mark;
Fset_buffer (p->buffer);
opoint = PT;
+ opoint_byte = PT_BYTE;
old_read_only = current_buffer->read_only;
old_begv = BEGV;
old_zv = ZV;
+ old_begv_byte = BEGV_BYTE;
+ old_zv_byte = ZV_BYTE;
current_buffer->read_only = Qnil;
at the current end-of-output marker,
thus preserving logical ordering of input and output. */
if (XMARKER (p->mark)->buffer)
- SET_PT (clip_to_bounds (BEGV, marker_position (p->mark), ZV));
+ SET_PT_BOTH (clip_to_bounds (BEGV, marker_position (p->mark), ZV),
+ clip_to_bounds (BEGV_BYTE, marker_byte_position (p->mark),
+ ZV_BYTE));
else
- SET_PT (ZV);
+ SET_PT_BOTH (ZV, ZV_BYTE);
before = PT;
+ before_byte = PT_BYTE;
/* If the output marker is outside of the visible region, save
the restriction and widen. */
insert_from_string_before_markers (p->decoding_buf, 0, nchars, 0);
else
insert_before_markers (chars, nchars);
- Fset_marker (p->mark, make_number (PT), p->buffer);
+ set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
update_mode_lines++;
/* Make sure opoint and the old restrictions
float ahead of any new text just as point would. */
if (opoint >= before)
- opoint += PT - before;
+ {
+ opoint += PT - before;
+ opoint_byte += PT_BYTE - before_byte;
+ }
if (old_begv > before)
- old_begv += PT - before;
+ {
+ old_begv += PT - before;
+ old_begv_byte += PT_BYTE - before_byte;
+ }
if (old_zv >= before)
- old_zv += PT - before;
+ {
+ old_zv += PT - before;
+ old_zv_byte += PT_BYTE - before_byte;
+ }
/* If the restriction isn't what it should be, set it. */
if (old_begv != BEGV || old_zv != ZV)
Vdeactivate_mark = odeactivate;
current_buffer->read_only = old_read_only;
- SET_PT (opoint);
+ SET_PT_BOTH (opoint, opoint_byte);
set_buffer_internal (old);
}
#ifdef VMS
error ("Output file descriptor of %s is closed", procname);
coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];
- if (! CODING_MAY_REQUIRE_NO_CONVERSION (coding))
+ Vlast_coding_system_used = coding->symbol;
+
+ if (CODING_REQUIRE_ENCODING (coding))
{
int require = encoding_buffer_size (coding, len);
int offset, dummy;
be relocated. Setting OFFSET to -1 means we don't have to
care relocation. */
offset = (BUFFERP (object)
- ? BUF_PTR_CHAR_POS (XBUFFER (object), buf)
+ ? BUF_PTR_BYTE_POS (XBUFFER (object), buf)
: (STRINGP (object)
? offset = buf - XSTRING (object)->data
: -1));
if (offset >= 0)
{
if (BUFFERP (object))
- buf = BUF_CHAR_ADDRESS (XBUFFER (object), offset);
+ buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset);
else if (STRINGP (object))
buf = offset + XSTRING (object)->data;
/* Now we don't have to care relocation. */
if (offset >= 0)
{
if (BUFFERP (object))
- buf = BUF_CHAR_ADDRESS (XBUFFER (object), offset);
+ buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset);
else if (STRINGP (object))
buf = offset + XSTRING (object)->data;
}
/* Running filters might relocate buffers or strings.
Arrange to relocate BUF. */
if (BUFFERP (object))
- offset = BUF_PTR_CHAR_POS (XBUFFER (object), buf);
+ offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf);
else if (STRINGP (object))
offset = buf - XSTRING (object)->data;
#endif
if (BUFFERP (object))
- buf = BUF_CHAR_ADDRESS (XBUFFER (object), offset);
+ buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset);
else if (STRINGP (object))
buf = offset + XSTRING (object)->data;
Lisp_Object process, start, end;
{
Lisp_Object proc;
- int start1;
+ int start1, end1;
proc = get_process (process);
validate_region (&start, &end);
if (XINT (start) < GPT && XINT (end) > GPT)
move_gap (XINT (start));
- start1 = XINT (start);
- send_process (proc, POS_ADDR (start1), XINT (end) - XINT (start),
+ start1 = CHAR_TO_BYTE (XINT (start));
+ end1 = CHAR_TO_BYTE (XINT (end));
+ send_process (proc, BYTE_POS_ADDR (start1), end1 - start1,
Fcurrent_buffer ());
return Qnil;
/* Kill all processes associated with `buffer'.
If `buffer' is nil, kill all processes */
+void
kill_buffer_processes (buffer)
Lisp_Object buffer;
{
(either run the sentinel or output a message).
This is done while Emacs is waiting for keyboard input. */
+void
status_notify ()
{
register Lisp_Object proc, buffer;
{
Lisp_Object ro, tem;
struct buffer *old = current_buffer;
- int opoint;
- int before;
+ int opoint, opoint_byte;
+ int before, before_byte;
ro = XBUFFER (buffer)->read_only;
Fset_buffer (buffer);
opoint = PT;
+ opoint_byte = PT_BYTE;
/* Insert new output into buffer
at the current end-of-output marker,
thus preserving logical ordering of input and output. */
if (XMARKER (p->mark)->buffer)
- SET_PT (marker_position (p->mark));
+ Fgoto_char (p->mark);
else
- SET_PT (ZV);
+ SET_PT_BOTH (ZV, ZV_BYTE);
before = PT;
+ before_byte = PT_BYTE;
tem = current_buffer->read_only;
current_buffer->read_only = Qnil;
insert_string (" ");
Finsert (1, &msg);
current_buffer->read_only = tem;
- Fset_marker (p->mark, make_number (PT), p->buffer);
+ set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
if (opoint >= before)
- SET_PT (opoint + (PT - before));
+ SET_PT_BOTH (opoint + (PT - before),
+ opoint_byte + (PT_BYTE - before_byte));
else
- SET_PT (opoint);
+ SET_PT_BOTH (opoint, opoint_byte);
set_buffer_internal (old);
}
\f
DEFUN ("set-process-coding-system", Fset_process_coding_system,
Sset_process_coding_system, 1, 3, 0,
- "Set coding-systems of PROCESS to DECODING (input from the process) and\n\
+ "Set coding systems of PROCESS to DECODING (input from the process) and\n\
ENCODING (output to the process).")
(proc, decoding, encoding)
register Lisp_Object proc, decoding, encoding;
DEFUN ("process-coding-system",
Fprocess_coding_system, Sprocess_coding_system, 1, 1, 0,
- "Return a cons of coding-system for decoding and encoding of PROCESS.")
+ "Return a cons of coding systems for decoding and encoding of PROCESS.")
(proc)
register Lisp_Object proc;
{