XPROCESS (proc)->encode_coding_system = val;
}
- new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
-
/* If program file name is not absolute, search our path for it.
Put the name we will really use in TEM. */
if (!IS_DIRECTORY_SEP (SREF (program, 0))
&& SREF (tem, 1) == ':')
tem = Fsubstring (tem, make_number (2), Qnil);
- /* Encode the file name and put it in NEW_ARGV.
- That's where the child will use it to execute the program. */
- tem = ENCODE_FILE (tem);
- new_argv[0] = SDATA (tem);
+ {
+ struct gcpro gcpro1;
+ GCPRO1 (tem);
+
+ /* Encode the file name and put it in NEW_ARGV.
+ That's where the child will use it to execute the program. */
+ tem = Fcons (ENCODE_FILE (tem), Qnil);
+
+ /* 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. */
+
+ for (i = 3; i < nargs; i++)
+ {
+ tem = Fcons (args[i], tem);
+ CHECK_STRING (XCAR (tem));
+ if (STRING_MULTIBYTE (XCAR (tem)))
+ XSETCAR (tem,
+ code_convert_string_norecord
+ (XCAR (tem), XPROCESS (proc)->encode_coding_system, 1));
+ }
+
+ UNGCPRO;
+ }
- /* 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. */
+ /* Now that everything is encoded we can collect the strings into
+ NEW_ARGV. */
+ new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
+ new_argv[nargs - 2] = 0;
- for (i = 3; i < nargs; i++)
+ for (i = nargs - 3; i >= 0; i--)
{
- tem = args[i];
- CHECK_STRING (tem);
- if (STRING_MULTIBYTE (tem))
- tem = (code_convert_string_norecord
- (tem, XPROCESS (proc)->encode_coding_system, 1));
- new_argv[i - 2] = SDATA (tem);
+ new_argv[i] = SDATA (XCAR (tem));
+ tem = XCDR (tem);
}
- new_argv[i - 2] = 0;
XPROCESS (proc)->decoding_buf = make_uninit_string (0);
XPROCESS (proc)->decoding_carryover = 0;
#endif
if (forkin < 0)
report_file_error ("Opening pty", Qnil);
-#if defined (DONT_REOPEN_PTY)
- /* In the case that vfork is defined as fork, the parent process
- (Emacs) may send some data before the child process completes
- tty options setup. So we setup tty before forking. */
- child_setup_tty (forkout);
-#endif /* DONT_REOPEN_PTY */
#else
forkin = forkout = -1;
#endif /* not USG, or USG_SUBTTY_WORKS */
#endif /* SIGCHLD */
#endif /* !POSIX_SIGNALS */
-#if !defined (DONT_REOPEN_PTY)
if (pty_flag)
child_setup_tty (xforkout);
-#endif /* not DONT_REOPEN_PTY */
#ifdef WINDOWSNT
pid = child_setup (xforkin, xforkout, xforkout,
new_argv, 1, current_dir);
register int nbytes;
char *chars;
register Lisp_Object outstream;
- register struct buffer *old = current_buffer;
register struct Lisp_Process *p = XPROCESS (proc);
register int opoint;
struct coding_system *coding = proc_decode_coding_system[channel];
int opoint_byte;
Lisp_Object text;
struct buffer *b;
+ int count = SPECPDL_INDEX ();
odeactivate = Vdeactivate_mark;
+ record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
Fset_buffer (p->buffer);
opoint = PT;
opoint_byte = PT_BYTE;
current_buffer->read_only = old_read_only;
SET_PT_BOTH (opoint, opoint_byte);
- set_buffer_internal (old);
+ unbind_to (count, Qnil);
}
return nbytes;
}
/* Running filters might relocate buffers or strings.
Arrange to relocate BUF. */
- if (BUFFERP (object))
+ if (CODING_REQUIRE_ENCODING (coding))
+ offset = buf - SDATA (coding->dst_object);
+ else if (BUFFERP (object))
offset = BUF_PTR_BYTE_POS (XBUFFER (object), buf);
else if (STRINGP (object))
offset = buf - SDATA (object);
wait_reading_process_output (1, 0, 0, 0, Qnil, NULL, 0);
#endif
- if (BUFFERP (object))
+ if (CODING_REQUIRE_ENCODING (coding))
+ buf = offset + SDATA (coding->dst_object);
+ else if (BUFFERP (object))
buf = BUF_BYTE_ADDRESS (XBUFFER (object), offset);
else if (STRINGP (object))
buf = offset + SDATA (object);
doc: /* Return a list of numerical process IDs of all running processes.
If this functionality is unsupported, return nil.
-See `system-process-attributes' for getting attributes of a process
-given its ID. */)
+See `process-attributes' for getting attributes of a process given its ID. */)
()
{
return list_system_processes ();
}
-DEFUN ("system-process-attributes", Fsystem_process_attributes,
- Ssystem_process_attributes, 1, 1, 0,
+DEFUN ("process-attributes", Fprocess_attributes,
+ Sprocess_attributes, 1, 1, 0,
doc: /* Return attributes of the process given by its PID, a number.
Value is an alist where each element is a cons cell of the form
defsubr (&Sset_process_filter_multibyte);
defsubr (&Sprocess_filter_multibyte_p);
defsubr (&Slist_system_processes);
- defsubr (&Ssystem_process_attributes);
+ defsubr (&Sprocess_attributes);
}
\f
doc: /* Return a list of numerical process IDs of all running processes.
If this functionality is unsupported, return nil.
-See `system-process-attributes' for getting attributes of a process
-given its ID. */)
+See `process-attributes' for getting attributes of a process given its ID. */)
()
{
return list_system_processes ();
}
-DEFUN ("system-process-attributes", Fsystem_process_attributes,
- Ssystem_process_attributes, 1, 1, 0,
+DEFUN ("process-attributes", Fprocess_attributes,
+ Sprocess_attributes, 1, 1, 0,
doc: /* Return attributes of the process given by its PID, a number.
Value is an alist where each element is a cons cell of the form
defsubr (&Sget_buffer_process);
defsubr (&Sprocess_inherit_coding_system_flag);
defsubr (&Slist_system_processes);
- defsubr (&Ssystem_process_attributes);
+ defsubr (&Sprocess_attributes);
}
\f