update.
[chise/xemacs-chise.git.1] / src / process.c
index 405dc90..127fc17 100644 (file)
@@ -1,5 +1,5 @@
 /* Asynchronous subprocess control for XEmacs.
-   Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995
+   Copyright (C) 1985, 1986, 1987, 1988, 1992, 1993, 1994, 1995, 2003
    Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
    Copyright (C) 1995, 1996 Ben Wing.
@@ -58,7 +58,7 @@ Boston, MA 02111-1307, USA.  */
 #include "systty.h"
 #include "syswait.h"
 
-Lisp_Object Qprocessp, Qprocess_live_p;
+Lisp_Object Qprocessp, Qprocess_live_p, Qprocess_readable_p;
 
 /* Process methods */
 struct process_methods the_process_methods;
@@ -266,6 +266,29 @@ Return t if OBJECT is a process that is alive.
     ? Qt : Qnil;
 }
 
+#if 0
+/* This is a reasonable definition for this new primitive.  Kyle sez:
+
+   "The patch looks OK to me except for the creation and exporting of the
+   Fprocess_readable_p function.  I don't think a new Lisp function
+   should be created until we know something actually needs it.  If
+   we later want to give process-readable-p different semantics it
+   may be hard to do it and stay compatible with what we hastily
+   create today."
+
+   He's right, not yet.  Let's discuss the semantics on XEmacs Design
+   before enabling this.
+*/
+DEFUN ("process-readable-p", Fprocess_readable_p, 1, 1, 0, /*
+Return t if OBJECT is a process from which input may be available.
+*/
+       (object))
+{
+  return PROCESSP (object) && PROCESS_READABLE_P (XPROCESS (object))
+    ? Qt : Qnil;
+}
+#endif
+
 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /*
 Return a list of all processes.
 */
@@ -329,7 +352,7 @@ get_process (Lisp_Object name)
 #endif
 
   /* This may be called during a GC from process_send_signal() from
-     kill_buffer_processes() if emacs decides to abort(). */
+     kill_buffer_processes() if emacs decides to ABORT(). */
   if (PROCESSP (name))
     return name;
   else if (STRINGP (name))
@@ -512,7 +535,7 @@ create_process (Lisp_Object process, Lisp_Object *argv, int nargv,
   pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir));
 
   p->pid = make_int (pid);
-  if (PROCESS_LIVE_P (p))
+  if (PROCESS_READABLE_P (p))
     event_stream_select_process (p);
 }
 
@@ -541,8 +564,8 @@ BUFFER is the buffer or (buffer-name) to associate with the process.
  with any buffer
 Third arg is program file name.  It is searched for as in the shell.
 Remaining arguments are strings to give program as arguments.
-INCODE and OUTCODE specify the coding-system objects used in input/output
- from/to the process.
+If bound, `coding-system-for-read' and `coding-system-for-write' specify
+ the coding-system objects used in input from and output to the process.
 */
        (int nargs, Lisp_Object *args))
 {
@@ -550,6 +573,7 @@ INCODE and OUTCODE specify the coding-system objects used in input/output
   /* !!#### This function has not been Mule-ized */
   Lisp_Object buffer, name, program, process, current_dir;
   Lisp_Object tem;
+  int i;
   int speccount = specpdl_depth ();
   struct gcpro gcpro1, gcpro2, gcpro3;
 
@@ -566,6 +590,8 @@ INCODE and OUTCODE specify the coding-system objects used in input/output
 
   CHECK_STRING (name);
   CHECK_STRING (program);
+  for (i = 3; i < nargs; ++i)
+    CHECK_STRING (args[i]);
 
   /* Make sure that the child will be able to chdir to the current
      buffer's current directory, or its unhandled equivalent.  We
@@ -733,8 +759,8 @@ against lost packets.
 
   event_stream_select_process (XPROCESS (process));
 
-  UNGCPRO;
   NUNGCPRO;
+  UNGCPRO;
   return process;
 }
 
@@ -842,7 +868,7 @@ read_process_output (Lisp_Object process)
      Really, the loop in execute_internal_event() should check itself
      for a process-filter change, like in status_notify(); but the
      struct Lisp_Process is not exported outside of this file. */
-  if (!PROCESS_LIVE_P (p))
+  if (!PROCESS_READABLE_P (p))
     return -1; /* already closed */
 
   if (!NILP (p->filter) && (p->filter_does_read))
@@ -1051,7 +1077,7 @@ void
 set_process_filter (Lisp_Object process, Lisp_Object filter, int filter_does_read)
 {
   CHECK_PROCESS (process);
-  if (PROCESS_LIVE_P (XPROCESS (process))) {
+  if (PROCESS_READABLE_P (XPROCESS (process))) {
     if (EQ (filter, Qt))
       event_stream_unselect_process (XPROCESS (process));
     else
@@ -1142,7 +1168,7 @@ Return PROCESS's input coding system.
        (process))
 {
   process = get_process (process);
-  CHECK_LIVE_PROCESS (process);
+  CHECK_READABLE_PROCESS (process);
   return decoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_instream) );
 }
 
@@ -1162,7 +1188,7 @@ Return a pair of coding-system for decoding and encoding of PROCESS.
        (process))
 {
   process = get_process (process);
-  CHECK_LIVE_PROCESS (process);
+  CHECK_READABLE_PROCESS (process);
   return Fcons (decoding_stream_coding_system
                (XLSTREAM (XPROCESS (process)->coding_instream)),
                encoding_stream_coding_system
@@ -1177,7 +1203,7 @@ Set PROCESS's input coding system to CODESYS.
 {
   codesys = Fget_coding_system (codesys);
   process = get_process (process);
-  CHECK_LIVE_PROCESS (process);
+  CHECK_READABLE_PROCESS (process);
 
   set_decoding_stream_coding_system
     (XLSTREAM (XPROCESS (process)->coding_instream), codesys);
@@ -2023,6 +2049,10 @@ syms_of_process (void)
 
   defsymbol (&Qprocessp, "processp");
   defsymbol (&Qprocess_live_p, "process-live-p");
+#if 0
+  /* see comment at Fprocess_readable_p */
+  defsymbol (&Qprocess_readable_p, "process-readable-p");
+#endif
   defsymbol (&Qrun, "run");
   defsymbol (&Qstop, "stop");
   defsymbol (&Qopen, "open");
@@ -2037,6 +2067,10 @@ syms_of_process (void)
 
   DEFSUBR (Fprocessp);
   DEFSUBR (Fprocess_live_p);
+#if 0
+  /* see comment at Fprocess_readable_p */
+  DEFSUBR (Fprocess_readable_p);
+#endif
   DEFSUBR (Fget_process);
   DEFSUBR (Fget_buffer_process);
   DEFSUBR (Fdelete_process);