/[emacs]/emacs/src/process.c
ViewVC logotype

Diff of /emacs/src/process.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.397 by lektu, Tue Feb 4 14:03:13 2003 UTC revision 1.398 by handa, Mon Feb 10 07:58:29 2003 UTC
# Line 137  Lisp_Object Qlast_nonmenu_event; Line 137  Lisp_Object Qlast_nonmenu_event;
137  /* QCfamily is declared and initialized in xfaces.c,  /* QCfamily is declared and initialized in xfaces.c,
138     QCfilter in keyboard.c.  */     QCfilter in keyboard.c.  */
139  extern Lisp_Object QCfamily, QCfilter;  extern Lisp_Object QCfamily, QCfilter;
140    Lisp_Object QCfilter_multibyte;
141    
142  /* Qexit is declared and initialized in eval.c.  */  /* Qexit is declared and initialized in eval.c.  */
143    
# Line 586  remove_process (proc) Line 587  remove_process (proc)
587    
588    deactivate_process (proc);    deactivate_process (proc);
589  }  }
590    
591    /* Setup coding systems of PROCESS.  */
592    
593    void
594    setup_process_coding_systems (process)
595         Lisp_Object process;
596    {
597      struct Lisp_Process *p = XPROCESS (process);
598      int inch = XINT (p->infd);
599      int outch = XINT (p->outfd);
600    
601      if (!proc_decode_coding_system[inch])
602        proc_decode_coding_system[inch]
603          = (struct coding_system *) xmalloc (sizeof (struct coding_system));
604      setup_coding_system (p->decode_coding_system,
605                           proc_decode_coding_system[inch]);
606      if (! NILP (p->filter))
607        {
608          if (NILP (p->filter_multibyte))
609            setup_raw_text_coding_system (proc_decode_coding_system[inch]);
610        }
611      else if (BUFFERP (p->buffer))
612        {
613          if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters))
614            setup_raw_text_coding_system (proc_decode_coding_system[inch]);
615        }
616    
617      if (!proc_encode_coding_system[outch])
618        proc_encode_coding_system[outch]
619          = (struct coding_system *) xmalloc (sizeof (struct coding_system));
620      setup_coding_system (p->encode_coding_system,
621                           proc_encode_coding_system[outch]);
622    }
623    
624  DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0,  DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0,
625         doc: /* Return t if OBJECT is a process.  */)         doc: /* Return t if OBJECT is a process.  */)
# Line 816  DEFUN ("set-process-buffer", Fset_proces Line 850  DEFUN ("set-process-buffer", Fset_proces
850    p->buffer = buffer;    p->buffer = buffer;
851    if (NETCONN1_P (p))    if (NETCONN1_P (p))
852      p->childp = Fplist_put (p->childp, QCbuffer, buffer);      p->childp = Fplist_put (p->childp, QCbuffer, buffer);
853      setup_process_coding_systems (process);
854    return buffer;    return buffer;
855  }  }
856    
# Line 890  The string argument is normally a multib Line 925  The string argument is normally a multib
925    p->filter = filter;    p->filter = filter;
926    if (NETCONN1_P (p))    if (NETCONN1_P (p))
927      p->childp = Fplist_put (p->childp, QCfilter, filter);      p->childp = Fplist_put (p->childp, QCfilter, filter);
928      setup_process_coding_systems (process);
929    return filter;    return filter;
930  }  }
931    
# Line 1438  usage: (start-process NAME BUFFER PROGRA Line 1474  usage: (start-process NAME BUFFER PROGRA
1474    XPROCESS (proc)->buffer = buffer;    XPROCESS (proc)->buffer = buffer;
1475    XPROCESS (proc)->sentinel = Qnil;    XPROCESS (proc)->sentinel = Qnil;
1476    XPROCESS (proc)->filter = Qnil;    XPROCESS (proc)->filter = Qnil;
1477      XPROCESS (proc)->filter_multibyte
1478        = buffer_defaults.enable_multibyte_characters;
1479    XPROCESS (proc)->command = Flist (nargs - 2, args + 2);    XPROCESS (proc)->command = Flist (nargs - 2, args + 2);
1480    
1481    /* Make the process marker point into the process buffer (if any).  */    /* Make the process marker point into the process buffer (if any).  */
# Line 1748  create_process (process, new_argv, curre Line 1786  create_process (process, new_argv, curre
1786      XSETFASTINT (XPROCESS (process)->subtty, forkin);      XSETFASTINT (XPROCESS (process)->subtty, forkin);
1787    XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil);    XPROCESS (process)->pty_flag = (pty_flag ? Qt : Qnil);
1788    XPROCESS (process)->status = Qrun;    XPROCESS (process)->status = Qrun;
1789    if (!proc_decode_coding_system[inchannel])    setup_process_coding_systems (process);
     proc_decode_coding_system[inchannel]  
       = (struct coding_system *) xmalloc (sizeof (struct coding_system));  
   setup_coding_system (XPROCESS (process)->decode_coding_system,  
                        proc_decode_coding_system[inchannel]);  
   if (!proc_encode_coding_system[outchannel])  
     proc_encode_coding_system[outchannel]  
       = (struct coding_system *) xmalloc (sizeof (struct coding_system));  
   setup_coding_system (XPROCESS (process)->encode_coding_system,  
                        proc_encode_coding_system[outchannel]);  
1790    
1791    /* Delay interrupts until we have a chance to store    /* Delay interrupts until we have a chance to store
1792       the new fork's pid in its process structure */       the new fork's pid in its process structure */
# Line 2590  The stopped state is cleared by `continu Line 2619  The stopped state is cleared by `continu
2619    
2620  :filter FILTER -- Install FILTER as the process filter.  :filter FILTER -- Install FILTER as the process filter.
2621    
2622    :filter-multibyte BOOL -- If BOOL is non-nil, a string given to the
2623    process filter is multibyte, otherwise it is unibyte.  If this keyword
2624    is not specified, the string is multibyte iff
2625    `default-enable-multibyte-characters' is non-nil.
2626    
2627  :sentinel SENTINEL -- Install SENTINEL as the process sentinel.  :sentinel SENTINEL -- Install SENTINEL as the process sentinel.
2628    
2629  :log LOG -- Install LOG as the server process log function.  This  :log LOG -- Install LOG as the server process log function.  This
# Line 3185  usage: (make-network-process &rest ARGS) Line 3219  usage: (make-network-process &rest ARGS)
3219    p->buffer = buffer;    p->buffer = buffer;
3220    p->sentinel = sentinel;    p->sentinel = sentinel;
3221    p->filter = filter;    p->filter = filter;
3222      p->filter_multibyte = buffer_defaults.enable_multibyte_characters;
3223      /* Override the above only if :filter-multibyte is specified.  */
3224      if (! NILP (Fplist_member (contact, QCfilter_multibyte)))
3225        p->filter_multibyte = Fplist_get (contact, QCfilter_multibyte);
3226    p->log = Fplist_get (contact, QClog);    p->log = Fplist_get (contact, QClog);
3227    if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))    if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))
3228      p->kill_without_query = Qt;      p->kill_without_query = Qt;
# Line 3296  usage: (make-network-process &rest ARGS) Line 3334  usage: (make-network-process &rest ARGS)
3334        }        }
3335      p->encode_coding_system = val;      p->encode_coding_system = val;
3336    }    }
3337      setup_process_coding_systems (proc);
   if (!proc_decode_coding_system[inch])  
     proc_decode_coding_system[inch]  
       = (struct coding_system *) xmalloc (sizeof (struct coding_system));  
   setup_coding_system (p->decode_coding_system,  
                        proc_decode_coding_system[inch]);  
   if (!proc_encode_coding_system[outch])  
     proc_encode_coding_system[outch]  
       = (struct coding_system *) xmalloc (sizeof (struct coding_system));  
   setup_coding_system (p->encode_coding_system,  
                        proc_encode_coding_system[outch]);  
3338    
3339    p->decoding_buf = make_uninit_string (0);    p->decoding_buf = make_uninit_string (0);
3340    p->decoding_carryover = make_number (0);    p->decoding_carryover = make_number (0);
# Line 3641  server_accept_connection (server, channe Line 3669  server_accept_connection (server, channe
3669    
3670    p->decode_coding_system = ps->decode_coding_system;    p->decode_coding_system = ps->decode_coding_system;
3671    p->encode_coding_system = ps->encode_coding_system;    p->encode_coding_system = ps->encode_coding_system;
3672      setup_process_coding_systems (proc);
   if (!proc_decode_coding_system[s])  
     proc_decode_coding_system[s]  
       = (struct coding_system *) xmalloc (sizeof (struct coding_system));  
   setup_coding_system (p->decode_coding_system,  
                        proc_decode_coding_system[s]);  
   if (!proc_encode_coding_system[s])  
     proc_encode_coding_system[s]  
       = (struct coding_system *) xmalloc (sizeof (struct coding_system));  
   setup_coding_system (p->encode_coding_system,  
                        proc_encode_coding_system[s]);  
3673    
3674    p->decoding_buf = make_uninit_string (0);    p->decoding_buf = make_uninit_string (0);
3675    p->decoding_carryover = make_number (0);    p->decoding_carryover = make_number (0);
# Line 4517  read_process_output (proc, channel) Line 4535  read_process_output (proc, channel)
4535    
4536        text = decode_coding_string (make_unibyte_string (chars, nbytes),        text = decode_coding_string (make_unibyte_string (chars, nbytes),
4537                                     coding, 0);                                     coding, 0);
       if (NILP (buffer_defaults.enable_multibyte_characters))  
         /* We had better return unibyte string.  */  
         text = string_make_unibyte (text);  
   
4538        Vlast_coding_system_used = coding->symbol;        Vlast_coding_system_used = coding->symbol;
4539        /* A new coding system might be found.  */        /* A new coding system might be found.  */
4540        if (!EQ (p->decode_coding_system, coding->symbol))        if (!EQ (p->decode_coding_system, coding->symbol))
# Line 4551  read_process_output (proc, channel) Line 4565  read_process_output (proc, channel)
4565        bcopy (chars + coding->consumed, SDATA (p->decoding_buf),        bcopy (chars + coding->consumed, SDATA (p->decoding_buf),
4566               carryover);               carryover);
4567        XSETINT (p->decoding_carryover, carryover);        XSETINT (p->decoding_carryover, carryover);
4568          /* Adjust the multibyteness of TEXT to that of the filter.  */
4569          if (NILP (p->filter_multibyte) != ! STRING_MULTIBYTE (text))
4570            text = (STRING_MULTIBYTE (text)
4571                    ? Fstring_as_unibyte (text)
4572                    : Fstring_to_multibyte (text));
4573        nbytes = SBYTES (text);        nbytes = SBYTES (text);
4574        nchars = SCHARS (text);        nchars = SCHARS (text);
4575        if (nbytes > 0)        if (nbytes > 0)
# Line 4657  read_process_output (proc, channel) Line 4676  read_process_output (proc, channel)
4676            != ! STRING_MULTIBYTE (text))            != ! STRING_MULTIBYTE (text))
4677          text = (STRING_MULTIBYTE (text)          text = (STRING_MULTIBYTE (text)
4678                  ? Fstring_as_unibyte (text)                  ? Fstring_as_unibyte (text)
4679                  : Fstring_as_multibyte (text));                  : Fstring_to_multibyte (text));
4680        nbytes = SBYTES (text);        nbytes = SBYTES (text);
4681        nchars = SCHARS (text);        nchars = SCHARS (text);
4682        /* Insert before markers in case we are inserting where        /* Insert before markers in case we are inserting where
# Line 6118  encode subprocess input.  */) Line 6137  encode subprocess input.  */)
6137      error ("Input file descriptor of %s closed", SDATA (p->name));      error ("Input file descriptor of %s closed", SDATA (p->name));
6138    if (XINT (p->outfd) < 0)    if (XINT (p->outfd) < 0)
6139      error ("Output file descriptor of %s closed", SDATA (p->name));      error ("Output file descriptor of %s closed", SDATA (p->name));
6140      Fcheck_coding_system (decoding);
6141      Fcheck_coding_system (encoding);
6142    
6143    p->decode_coding_system = Fcheck_coding_system (decoding);    p->decode_coding_system = decoding;
6144    p->encode_coding_system = Fcheck_coding_system (encoding);    p->encode_coding_system = encoding;
6145    setup_coding_system (decoding,    setup_process_coding_systems (proc);
                        proc_decode_coding_system[XINT (p->infd)]);  
   setup_coding_system (encoding,  
                        proc_encode_coding_system[XINT (p->outfd)]);  
6146    
6147    return Qnil;    return Qnil;
6148  }  }
# Line 6139  DEFUN ("process-coding-system", Line 6157  DEFUN ("process-coding-system",
6157    return Fcons (XPROCESS (proc)->decode_coding_system,    return Fcons (XPROCESS (proc)->decode_coding_system,
6158                  XPROCESS (proc)->encode_coding_system);                  XPROCESS (proc)->encode_coding_system);
6159  }  }
6160    
6161    DEFUN ("set-process-filter-multibyte", Fset_process_filter_multibyte,
6162           Sset_process_filter_multibyte, 2, 2, 0,
6163           doc: /* Set multibyteness of a string given to PROCESS's filter.
6164    If FLAG is non-nil, the filter is given a multibyte string.
6165    If FLAG is nil, the filter is give a unibyte string.  In this case,
6166    all character code conversion except for end-of-line conversion is
6167    suppressed.  */)
6168         (proc, flag)
6169         Lisp_Object proc, flag;
6170    {
6171      register struct Lisp_Process *p;
6172    
6173      CHECK_PROCESS (proc);
6174      p = XPROCESS (proc);
6175      p->filter_multibyte = flag;
6176      setup_process_coding_systems (proc);
6177    
6178      return Qnil;
6179    }
6180    
6181    DEFUN ("process-filter-multibyte-p", Fprocess_filter_multibyte_p,
6182           Sprocess_filter_multibyte_p, 1, 1, 0,
6183           doc: /* Return t if a multibyte string is given to PROCESS's filter.*/)
6184         (proc)
6185         Lisp_Object proc;
6186    {
6187      register struct Lisp_Process *p;
6188    
6189      CHECK_PROCESS (proc);
6190      p = XPROCESS (proc);
6191    
6192      return (NILP (p->filter_multibyte) ? Qnil : Qt);
6193    }
6194    
6195    
6196    
6197  /* The first time this is called, assume keyboard input comes from DESC  /* The first time this is called, assume keyboard input comes from DESC
6198     instead of from where we used to expect it.     instead of from where we used to expect it.
# Line 6345  syms_of_process () Line 6399  syms_of_process ()
6399    
6400    Qlast_nonmenu_event = intern ("last-nonmenu-event");    Qlast_nonmenu_event = intern ("last-nonmenu-event");
6401    staticpro (&Qlast_nonmenu_event);    staticpro (&Qlast_nonmenu_event);
6402      QCfilter_multibyte = intern ("filter-multibyte");
6403      staticpro (&QCfilter_multibyte);
6404    
6405    staticpro (&Vprocess_alist);    staticpro (&Vprocess_alist);
6406    
# Line 6414  The value takes effect when `start-proce Line 6470  The value takes effect when `start-proce
6470  /*  defsubr (&Sprocess_connection); */  /*  defsubr (&Sprocess_connection); */
6471    defsubr (&Sset_process_coding_system);    defsubr (&Sset_process_coding_system);
6472    defsubr (&Sprocess_coding_system);    defsubr (&Sprocess_coding_system);
6473      defsubr (&Sset_process_filter_multibyte);
6474      defsubr (&Sprocess_filter_multibyte_p);
6475  }  }
6476    
6477    

Legend:
Removed from v.1.397  
changed lines
  Added in v.1.398

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26