#include "commands.h"
#include "frame.h"
#include "blockinput.h"
+#include "keyboard.h"
+#include "dispextern.h"
#define max(a, b) ((a) > (b) ? (a) : (b))
Lisp_Object status_convert ();
+void
update_status (p)
struct Lisp_Process *p;
{
allocate_pty ()
{
struct stat stb;
- register c, i;
+ register int c, i;
int fd;
/* Some systems name their pseudoterminals so that there are gaps in
return val;
}
+void
remove_process (proc)
register Lisp_Object proc;
{
return Qt;
}
+DEFUN ("set-process-inherit-coding-system-flag",
+ Fset_process_inherit_coding_system_flag,
+ Sset_process_inherit_coding_system_flag, 2, 2, 0,
+ "Determine whether buffer of PROCESS will inherit coding-system.\n\
+If the second argument FLAG is non-nil, then the variable\n\
+`buffer-file-coding-system' of the buffer associated with PROCESS\n\
+will be bound to the value of the coding system used to decode\n\
+the process output.\n\
+\n\
+This is useful when the coding system specified for the process buffer\n\
+leaves either the character code conversion or the end-of-line conversion\n\
+unspecified, or if the coding system used to decode the process output\n\
+is more appropriate for saving the process buffer.\n\
+\n\
+Binding the variable `inherit-process-coding-system' to non-nil before\n\
+starting the process is an alternative way of setting the inherit flag\n\
+for the process which will run.")
+ (process, flag)
+ register Lisp_Object process, flag;
+{
+ CHECK_PROCESS (process, 0);
+ XPROCESS (process)->inherit_coding_system_flag = flag;
+ return flag;
+}
+
+DEFUN ("process-inherit-coding-system-flag",
+ Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag,
+ 1, 1, 0,
+ "Return the value of inherit-coding-system flag for PROCESS.\n\
+If this flag is t, `buffer-file-coding-system' of the buffer\n\
+associated with PROCESS will inherit the coding system used to decode\n\
+the process output.")
+ (process)
+ register Lisp_Object process;
+{
+ CHECK_PROCESS (process, 0);
+ return XPROCESS (process)->inherit_coding_system_flag;
+}
+
DEFUN ("process-kill-without-query", Fprocess_kill_without_query,
Sprocess_kill_without_query, 1, 2, 0,
"Say no query needed if PROCESS is running when Emacs is exited.\n\
#ifdef VMS
/* Make a one member argv with all args concatenated
together separated by a blank. */
- len = XSTRING (program)->size_byte + 2;
+ len = STRING_BYTES (XSTRING (program)) + 2;
for (i = 3; i < nargs; i++)
{
tem = args[i];
CHECK_STRING (tem, i);
- len += XSTRING (tem)->size_byte + 1; /* count the blank */
+ len += STRING_BYTES (XSTRING (tem)) + 1; /* count the blank */
}
new_argv = (unsigned char *) alloca (len);
strcpy (new_argv, XSTRING (program)->data);
XPROCESS (proc)->encoding_buf = make_uninit_string (0);
XPROCESS (proc)->encoding_carryover = make_number (0);
+ XPROCESS (proc)->inherit_coding_system_flag
+ = (NILP (buffer) || !inherit_process_coding_system
+ ? Qnil : Qt);
+
create_process (proc, (char **) new_argv, current_dir);
return unbind_to (count, proc);
XPROCESS (proc)->encoding_buf = make_uninit_string (0);
XPROCESS (proc)->encoding_carryover = make_number (0);
+ XPROCESS (proc)->inherit_coding_system_flag
+ = (NILP (buffer) || !inherit_process_coding_system
+ ? Qnil : Qt);
+
UNGCPRO;
return proc;
}
static int waiting_for_user_input_p;
/* This is here so breakpoints can be put on it. */
-static
+static void
wait_reading_process_input_1 ()
{
}
before the timeout elapsed.
Otherwise, return true iff we received input from any process. */
+int
wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
int time_limit, microsecs;
Lisp_Object read_kbd;
The characters read are decoded according to PROC's coding-system
for decoding. */
+int
read_process_output (proc, channel)
Lisp_Object proc;
register int channel;
char *buf = (char *) xmalloc (nbytes + carryover);
bcopy (XSTRING (p->decoding_buf)->data
- + XSTRING (p->decoding_buf)->size_byte - carryover,
+ + STRING_BYTES (XSTRING (p->decoding_buf)) - carryover,
buf, carryover);
bcopy (chars, buf + carryover, nbytes);
chars = buf;
if (carryover)
/* See the comment above. */
bcopy (XSTRING (p->decoding_buf)->data
- + XSTRING (p->decoding_buf)->size_byte - carryover,
+ + STRING_BYTES (XSTRING (p->decoding_buf)) - carryover,
buf, carryover);
if (proc_buffered_char[channel] < 0)
int require = decoding_buffer_size (coding, nbytes);
int result;
- if (XSTRING (p->decoding_buf)->size_byte < require)
+ if (STRING_BYTES (XSTRING (p->decoding_buf)) < require)
p->decoding_buf = make_uninit_string (require);
result = decode_coding (coding, chars, XSTRING (p->decoding_buf)->data,
- nbytes, XSTRING (p->decoding_buf)->size_byte);
+ nbytes, STRING_BYTES (XSTRING (p->decoding_buf)));
carryover = nbytes - coding->consumed;
/* A new coding system might be found by `decode_coding'. */
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])
+ && proc_encode_coding_system[XINT (p->outfd)])
{
p->encode_coding_system = coding->symbol;
setup_coding_system (coding->symbol,
- proc_encode_coding_system[p->outfd]);
+ proc_encode_coding_system[XINT (p->outfd)]);
}
}
return 0;
chars = (char *) XSTRING (p->decoding_buf)->data;
nbytes = coding->produced;
- nchars = coding->produced_char;
+ nchars = (coding->fake_multibyte
+ ? multibyte_chars_in_text (chars, nbytes)
+ : coding->produced_char);
chars_in_decoding_buf = 1;
}
#ifdef VMS
/* Although we don't have to decode the received data, we must
move it to an area which we don't have to free. */
if (! STRINGP (p->decoding_buf)
- || XSTRING (p->decoding_buf)->size < nbytes)
+ || STRING_BYTES (XSTRING (p->decoding_buf)) < nbytes)
p->decoding_buf = make_uninit_string (nbytes);
bcopy (chars, XSTRING (p->decoding_buf)->data, nbytes);
free (chars);
chars = XSTRING (p->decoding_buf)->data;
+ nchars = multibyte_chars_in_text (chars, nbytes);
chars_in_decoding_buf = 1;
carryover = 0;
}
XSETINT (p->decoding_carryover, carryover);
Vlast_coding_system_used = coding->symbol;
+ /* If the caller required, let the process associated buffer
+ inherit the coding-system used to decode the process output. */
+ if (! NILP (p->inherit_coding_system_flag)
+ && !NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
+ {
+ struct buffer *prev_buf = current_buffer;
+
+ Fset_buffer (p->buffer);
+ call1 (intern ("after-insert-file-set-buffer-file-coding-system"),
+ make_number (nbytes));
+ set_buffer_internal (prev_buf);
+ }
+
/* Read and dispose of the process output. */
outstream = p->filter;
if (!NILP (outstream))
save the match data in a special nonrecursive fashion. */
running_asynch_code = 1;
- text = make_multibyte_string (chars, nchars, nbytes);
+ text = make_string_from_bytes (chars, nchars, nbytes);
internal_condition_case_1 (read_process_output_call,
Fcons (outstream,
Fcons (proc, Fcons (text, Qnil))),
/* Insert before markers in case we are inserting where
the buffer's mark is, and the user's next command is Meta-y. */
if (chars_in_decoding_buf)
- insert_from_string_before_markers (p->decoding_buf, 0, 0,
- nchars, nbytes, 0);
+ {
+ /* Since multibyteness of p->docoding_buf is corrupted, we
+ can't use insert_from_string_before_markers. */
+ char *temp_buf;
+
+ temp_buf = (char *) alloca (nbytes);
+ bcopy (XSTRING (p->decoding_buf)->data, temp_buf, nbytes);
+ insert_before_markers (temp_buf, nbytes);
+ }
else
insert_1_both (chars, nchars, nbytes, 0, 1, 1);
set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
being encoded. Should we store them in a buffer to prepend them to
the data send later? */
+void
send_process (proc, buf, len, object)
volatile Lisp_Object proc;
unsigned char *buf;
offset = -1;
}
bcopy ((XSTRING (XPROCESS (proc)->encoding_buf)->data
- + XSTRING (XPROCESS (proc)->encoding_buf)->size_byte
+ + STRING_BYTES (XSTRING (XPROCESS (proc)->encoding_buf))
- carryover),
temp_buf,
carryover);
buf = temp_buf;
}
- if (XSTRING (XPROCESS (proc)->encoding_buf)->size_byte < require)
+ if (STRING_BYTES (XSTRING (XPROCESS (proc)->encoding_buf)) < require)
{
XPROCESS (proc)->encoding_buf = make_uninit_string (require);
}
object = XPROCESS (proc)->encoding_buf;
encode_coding (coding, buf, XSTRING (object)->data,
- len, XSTRING (object)->size_byte);
+ len, STRING_BYTES (XSTRING (object)));
len = coding->produced;
buf = XSTRING (object)->data;
if (temp_buf)
CHECK_STRING (string, 1);
proc = get_process (process);
send_process (proc, XSTRING (string)->data,
- XSTRING (string)->size_byte, string);
+ STRING_BYTES (XSTRING (string)), string);
return Qnil;
}
\f
return 0;
}
\f
+void
init_process ()
{
register int i;
bzero (proc_encode_coding_system, sizeof proc_encode_coding_system);
}
+void
syms_of_process ()
{
Qprocessp = intern ("processp");
defsubr (&Sset_process_sentinel);
defsubr (&Sprocess_sentinel);
defsubr (&Sset_process_window_size);
+ defsubr (&Sset_process_inherit_coding_system_flag);
+ defsubr (&Sprocess_inherit_coding_system_flag);
defsubr (&Sprocess_kill_without_query);
defsubr (&Sprocess_contact);
defsubr (&Slist_processes);
#include "lisp.h"
#include "systime.h"
+#include "charset.h"
+#include "coding.h"
#include "termopts.h"
#include "sysselect.h"
return Qnil;
}
+DEFUN ("process-inherit-coding-system-flag",
+ Fprocess_inherit_coding_system_flag, Sprocess_inherit_coding_system_flag,
+ 1, 1, 0,
+ /* Don't confuse make-docfile by having two doc strings for this function.
+ make-docfile does not pay attention to #if, for good reason! */
+ 0)
+ (process)
+ register Lisp_Object process;
+{
+ /* Ignore the argument and return the value of
+ inherit-process-coding-system. */
+ return inherit_process_coding_system ? Qt : Qnil;
+}
+
/* Kill all processes associated with `buffer'.
If `buffer' is nil, kill all processes.
Since we have no subprocesses, this does nothing. */
+void
kill_buffer_processes (buffer)
Lisp_Object buffer;
{
syms_of_process ()
{
defsubr (&Sget_buffer_process);
+ defsubr (&Sprocess_inherit_coding_system_flag);
}
\f