Fix -Wimplicit warnings.
[bpt/emacs.git] / src / process.c
index 65132d3..daa4e39 100644 (file)
@@ -106,6 +106,8 @@ Boston, MA 02111-1307, USA.  */
 #include "commands.h"
 #include "frame.h"
 #include "blockinput.h"
+#include "keyboard.h"
+#include "dispextern.h"
 
 #define max(a, b) ((a) > (b) ? (a) : (b))
 
@@ -279,6 +281,7 @@ static char pty_name[24];
 
 Lisp_Object status_convert ();
 
+void
 update_status (p)
      struct Lisp_Process *p;
 {
@@ -391,7 +394,7 @@ int
 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
@@ -512,6 +515,7 @@ make_process (name)
   return val;
 }
 
+void
 remove_process (proc)
      register Lisp_Object proc;
 {
@@ -1033,7 +1037,7 @@ BUFFER is the buffer or (buffer-name) to associate with the process.\n\
  an output stream or filter function to handle the output.\n\
  BUFFER may be also nil, meaning that this process is not associated\n\
  with any buffer.\n\
-Third arg is program file name.  It is searched for as in the shell.\n\
+Third arg is program file name.  It is searched for in PATH.\n\
 Remaining arguments are strings to give program as arguments.")
   (nargs, args)
      int nargs;
@@ -1089,12 +1093,12 @@ Remaining arguments are strings to give program as arguments.")
 #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);
@@ -2173,7 +2177,7 @@ Return non-nil iff we received any output before the timeout expired.")
 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 ()
 {
 }
@@ -2210,6 +2214,7 @@ 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;
@@ -2708,6 +2713,7 @@ read_process_output_error_handler (error)
    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;
@@ -2756,7 +2762,7 @@ read_process_output (proc, 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;
@@ -2767,7 +2773,7 @@ read_process_output (proc, channel)
   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)
@@ -2799,10 +2805,10 @@ read_process_output (proc, channel)
       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'.  */
@@ -2839,7 +2845,9 @@ read_process_output (proc, channel)
        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
@@ -2848,11 +2856,12 @@ read_process_output (proc, channel)
       /* 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;
     }
@@ -2892,15 +2901,15 @@ read_process_output (proc, channel)
          /* Don't clobber the CURRENT match data, either!  */
          tem = Fmatch_data (Qnil, Qnil);
          restore_match_data ();
-         record_unwind_protect (Fstore_match_data, Fmatch_data (Qnil, Qnil));
-         Fstore_match_data (tem);
+         record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
+         Fset_match_data (tem);
        }
 
       /* For speed, if a search happens within this code,
         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))),
@@ -2976,8 +2985,15 @@ read_process_output (proc, channel)
       /* 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);
@@ -3052,6 +3068,7 @@ send_process_trap ()
    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;
@@ -3111,7 +3128,7 @@ send_process (proc, buf, len, object)
              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);
@@ -3119,7 +3136,7 @@ send_process (proc, buf, len, object)
          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);
 
@@ -3133,7 +3150,7 @@ send_process (proc, buf, len, object)
        }
       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)
@@ -3318,7 +3335,7 @@ Output from processes can arrive in between bunches.")
   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
@@ -4028,8 +4045,8 @@ exec_sentinel (proc, reason)
       Lisp_Object tem;
       tem = Fmatch_data (Qnil, Qnil);
       restore_match_data ();
-      record_unwind_protect (Fstore_match_data, Fmatch_data (Qnil, Qnil));
-      Fstore_match_data (tem);
+      record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
+      Fset_match_data (tem);
     }
 
   /* For speed, if a search happens within this code,
@@ -4279,6 +4296,7 @@ keyboard_bit_set (mask)
   return 0;
 }
 \f
+void
 init_process ()
 {
   register int i;
@@ -4307,6 +4325,7 @@ init_process ()
   bzero (proc_encode_coding_system, sizeof proc_encode_coding_system);
 }
 
+void
 syms_of_process ()
 {
   Qprocessp = intern ("processp");
@@ -4637,6 +4656,7 @@ DEFUN ("get-buffer-process", Fget_buffer_process, Sget_buffer_process, 1, 1, 0,
    If `buffer' is nil, kill all processes.
    Since we have no subprocesses, this does nothing.  */
 
+void
 kill_buffer_processes (buffer)
      Lisp_Object buffer;
 {