/[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.408 by handa, Thu Jul 31 01:24:27 2003 UTC revision 1.408.2.1 by handa, Mon Sep 8 12:48:12 2003 UTC
# Line 112  Boston, MA 02111-1307, USA.  */ Line 112  Boston, MA 02111-1307, USA.  */
112  #include "lisp.h"  #include "lisp.h"
113  #include "window.h"  #include "window.h"
114  #include "buffer.h"  #include "buffer.h"
115  #include "charset.h"  #include "character.h"
116  #include "coding.h"  #include "coding.h"
117  #include "process.h"  #include "process.h"
118  #include "termhooks.h"  #include "termhooks.h"
# Line 600  setup_process_coding_systems (process) Line 600  setup_process_coding_systems (process)
600    struct Lisp_Process *p = XPROCESS (process);    struct Lisp_Process *p = XPROCESS (process);
601    int inch = XINT (p->infd);    int inch = XINT (p->infd);
602    int outch = XINT (p->outfd);    int outch = XINT (p->outfd);
603      Lisp_Object coding_system;
604    
605    if (inch < 0 || outch < 0)    if (inch < 0 || outch < 0)
606      return;      return;
# Line 607  setup_process_coding_systems (process) Line 608  setup_process_coding_systems (process)
608    if (!proc_decode_coding_system[inch])    if (!proc_decode_coding_system[inch])
609      proc_decode_coding_system[inch]      proc_decode_coding_system[inch]
610        = (struct coding_system *) xmalloc (sizeof (struct coding_system));        = (struct coding_system *) xmalloc (sizeof (struct coding_system));
611    setup_coding_system (p->decode_coding_system,    coding_system = p->decode_coding_system;
                        proc_decode_coding_system[inch]);  
612    if (! NILP (p->filter))    if (! NILP (p->filter))
613      {      {
614        if (NILP (p->filter_multibyte))        if (NILP (p->filter_multibyte))
615          setup_raw_text_coding_system (proc_decode_coding_system[inch]);          coding_system = raw_text_coding_system (coding_system);
616      }      }
617    else if (BUFFERP (p->buffer))    else if (BUFFERP (p->buffer))
618      {      {
619        if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters))        if (NILP (XBUFFER (p->buffer)->enable_multibyte_characters))
620          setup_raw_text_coding_system (proc_decode_coding_system[inch]);          coding_system = raw_text_coding_system (coding_system);
621      }      }
622      setup_coding_system (coding_system, proc_decode_coding_system[inch]);
623    
624    if (!proc_encode_coding_system[outch])    if (!proc_encode_coding_system[outch])
625      proc_encode_coding_system[outch]      proc_encode_coding_system[outch]
# Line 4400  read_process_output (proc, channel) Line 4401  read_process_output (proc, channel)
4401       Lisp_Object proc;       Lisp_Object proc;
4402       register int channel;       register int channel;
4403  {  {
4404    register int nchars, nbytes;    register int nbytes;
4405    char *chars;    char *chars;
4406    register Lisp_Object outstream;    register Lisp_Object outstream;
4407    register struct buffer *old = current_buffer;    register struct buffer *old = current_buffer;
# Line 4534  read_process_output (proc, channel) Line 4535  read_process_output (proc, channel)
4535           save the match data in a special nonrecursive fashion.  */           save the match data in a special nonrecursive fashion.  */
4536        running_asynch_code = 1;        running_asynch_code = 1;
4537    
4538        text = decode_coding_string (make_unibyte_string (chars, nbytes),        decode_coding_c_string (coding, chars, nbytes, Qt);
4539                                     coding, 0);        text = coding->dst_object;
4540        Vlast_coding_system_used = coding->symbol;        Vlast_coding_system_used = CODING_ID_NAME (coding->id);
4541        /* A new coding system might be found.  */        /* A new coding system might be found.  */
4542        if (!EQ (p->decode_coding_system, coding->symbol))        if (!EQ (p->decode_coding_system, Vlast_coding_system_used))
4543          {          {
4544            p->decode_coding_system = coding->symbol;            p->decode_coding_system = Vlast_coding_system_used;
4545    
4546            /* Don't call setup_coding_system for            /* Don't call setup_coding_system for
4547               proc_decode_coding_system[channel] here.  It is done in               proc_decode_coding_system[channel] here.  It is done in
# Line 4556  read_process_output (proc, channel) Line 4557  read_process_output (proc, channel)
4557            if (NILP (p->encode_coding_system)            if (NILP (p->encode_coding_system)
4558                && proc_encode_coding_system[XINT (p->outfd)])                && proc_encode_coding_system[XINT (p->outfd)])
4559              {              {
4560                p->encode_coding_system = coding->symbol;                p->encode_coding_system = Vlast_coding_system_used;
4561                setup_coding_system (coding->symbol,                setup_coding_system (p->encode_coding_system,
4562                                     proc_encode_coding_system[XINT (p->outfd)]);                                     proc_encode_coding_system[XINT (p->outfd)]);
4563              }              }
4564          }          }
4565    
4566        carryover = nbytes - coding->consumed;        if (coding->carryover_bytes > 0)
4567        bcopy (chars + coding->consumed, SDATA (p->decoding_buf),          {
4568               carryover);            bcopy (coding->carryover, SDATA (p->decoding_buf),
4569        XSETINT (p->decoding_carryover, carryover);                   coding->carryover_bytes);
4570              XSETINT (p->decoding_carryover, coding->carryover_bytes);
4571            }
4572        /* Adjust the multibyteness of TEXT to that of the filter.  */        /* Adjust the multibyteness of TEXT to that of the filter.  */
4573        if (NILP (p->filter_multibyte) != ! STRING_MULTIBYTE (text))        if (NILP (p->filter_multibyte) != ! STRING_MULTIBYTE (text))
4574          text = (STRING_MULTIBYTE (text)          text = (STRING_MULTIBYTE (text)
# Line 4650  read_process_output (proc, channel) Line 4653  read_process_output (proc, channel)
4653        if (! (BEGV <= PT && PT <= ZV))        if (! (BEGV <= PT && PT <= ZV))
4654          Fwiden ();          Fwiden ();
4655    
4656        text = decode_coding_string (make_unibyte_string (chars, nbytes),        decode_coding_c_string (coding, chars, nbytes, Qt);
4657                                     coding, 0);        text = coding->dst_object;
4658        Vlast_coding_system_used = coding->symbol;        Vlast_coding_system_used = CODING_ID_NAME (coding->id);
4659        /* A new coding system might be found.  See the comment in the        /* A new coding system might be found.  See the comment in the
4660           similar code in the previous `if' block.  */           similar code in the previous `if' block.  */
4661        if (!EQ (p->decode_coding_system, coding->symbol))        if (!EQ (p->decode_coding_system, Vlast_coding_system_used))
4662          {          {
4663            p->decode_coding_system = coding->symbol;            p->decode_coding_system = Vlast_coding_system_used;
4664            if (NILP (p->encode_coding_system)            if (NILP (p->encode_coding_system)
4665                && proc_encode_coding_system[XINT (p->outfd)])                && proc_encode_coding_system[XINT (p->outfd)])
4666              {              {
4667                p->encode_coding_system = coding->symbol;                p->encode_coding_system = Vlast_coding_system_used;
4668                setup_coding_system (coding->symbol,                setup_coding_system (p->encode_coding_system,
4669                                     proc_encode_coding_system[XINT (p->outfd)]);                                     proc_encode_coding_system[XINT (p->outfd)]);
4670              }              }
4671          }          }
4672        carryover = nbytes - coding->consumed;        if (coding->carryover_bytes > 0)
4673        bcopy (chars + coding->consumed, SDATA (p->decoding_buf),          {
4674               carryover);            bcopy (coding->carryover, SDATA (p->decoding_buf),
4675        XSETINT (p->decoding_carryover, carryover);                   coding->carryover_bytes);
4676              XSETINT (p->decoding_carryover, coding->carryover_bytes);
4677            }
4678        /* Adjust the multibyteness of TEXT to that of the buffer.  */        /* Adjust the multibyteness of TEXT to that of the buffer.  */
4679        if (NILP (current_buffer->enable_multibyte_characters)        if (NILP (current_buffer->enable_multibyte_characters)
4680            != ! STRING_MULTIBYTE (text))            != ! STRING_MULTIBYTE (text))
# Line 4790  send_process (proc, buf, len, object) Line 4795  send_process (proc, buf, len, object)
4795             SDATA (XPROCESS (proc)->name));             SDATA (XPROCESS (proc)->name));
4796    
4797    coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];    coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];
4798    Vlast_coding_system_used = coding->symbol;    Vlast_coding_system_used = CODING_ID_NAME (coding->id);
4799    
4800    if ((STRINGP (object) && STRING_MULTIBYTE (object))    if ((STRINGP (object) && STRING_MULTIBYTE (object))
4801        || (BUFFERP (object)        || (BUFFERP (object)
4802            && !NILP (XBUFFER (object)->enable_multibyte_characters))            && !NILP (XBUFFER (object)->enable_multibyte_characters))
4803        || EQ (object, Qt))        || EQ (object, Qt))
4804      {      {
4805        if (!EQ (coding->symbol, XPROCESS (proc)->encode_coding_system))        if (!EQ (Vlast_coding_system_used,
4806                   XPROCESS (proc)->encode_coding_system))
4807          /* The coding system for encoding was changed to raw-text          /* The coding system for encoding was changed to raw-text
4808             because we sent a unibyte text previously.  Now we are             because we sent a unibyte text previously.  Now we are
4809             sending a multibyte text, thus we must encode it by the             sending a multibyte text, thus we must encode it by the
4810             original coding system specified for the current             original coding system specified for the current
4811             process.  */             process.  */
4812          setup_coding_system (XPROCESS (proc)->encode_coding_system, coding);          setup_coding_system (XPROCESS (proc)->encode_coding_system, coding);
       /* src_multibyte should be set to 1 _after_ a call to  
          setup_coding_system, since it resets src_multibyte to  
          zero.  */  
       coding->src_multibyte = 1;  
4813      }      }
4814    else    else
4815      {      {
4816        /* For sending a unibyte text, character code conversion should        /* For sending a unibyte text, character code conversion should
4817           not take place but EOL conversion should.  So, setup raw-text           not take place but EOL conversion should.  So, setup raw-text
4818           or one of the subsidiary if we have not yet done it.  */           or one of the subsidiary if we have not yet done it.  */
4819        if (coding->type != coding_type_raw_text)        if (CODING_REQUIRE_ENCODING (coding))
4820          {          {
4821            if (CODING_REQUIRE_FLUSHING (coding))            if (CODING_REQUIRE_FLUSHING (coding))
4822              {              {
4823                /* But, before changing the coding, we must flush out data.  */                /* But, before changing the coding, we must flush out data.  */
4824                coding->mode |= CODING_MODE_LAST_BLOCK;                coding->mode |= CODING_MODE_LAST_BLOCK;
4825                send_process (proc, "", 0, Qt);                send_process (proc, "", 0, Qt);
4826                  coding->mode &= CODING_MODE_LAST_BLOCK;
4827              }              }
4828            coding->src_multibyte = 0;            coding->src_multibyte = 0;
4829            setup_raw_text_coding_system (coding);            setup_coding_system (raw_text_coding_system
4830                                   (Vlast_coding_system_used),
4831                                   coding);
4832          }          }
4833      }      }
4834    coding->dst_multibyte = 0;    coding->dst_multibyte = 0;
4835    
4836    if (CODING_REQUIRE_ENCODING (coding))    if (CODING_REQUIRE_ENCODING (coding))
4837      {      {
4838        int require = encoding_buffer_size (coding, len);        coding->dst_object = Qt;
       int from_byte = -1, from = -1, to = -1;  
       unsigned char *temp_buf = NULL;  
   
4839        if (BUFFERP (object))        if (BUFFERP (object))
4840          {          {
4841            from_byte = BUF_PTR_BYTE_POS (XBUFFER (object), buf);            int from_byte, from, to;
4842            from = buf_bytepos_to_charpos (XBUFFER (object), from_byte);            int save_pt, save_pt_byte;
4843            to = buf_bytepos_to_charpos (XBUFFER (object), from_byte + len);            struct buffer *cur = current_buffer;
4844    
4845              set_buffer_internal (XBUFFER (object));
4846              save_pt = PT, save_pt_byte = PT_BYTE;
4847    
4848              from_byte = PTR_BYTE_POS (buf);
4849              from = BYTE_TO_CHAR (from_byte);
4850              to = BYTE_TO_CHAR (from_byte + len);
4851              TEMP_SET_PT_BOTH (from, from_byte);
4852              encode_coding_object (coding, object, from, from_byte,
4853                                    to, from_byte + len, Qt);
4854              TEMP_SET_PT_BOTH (save_pt, save_pt_byte);
4855              set_buffer_internal (cur);
4856          }          }
4857        else if (STRINGP (object))        else if (STRINGP (object))
4858          {          {
4859            from_byte = buf - SDATA (object);            encode_coding_string (coding, object, 1);
           from = string_byte_to_char (object, from_byte);  
           to =  string_byte_to_char (object, from_byte + len);  
4860          }          }
4861          else
       if (coding->composing != COMPOSITION_DISABLED)  
4862          {          {
4863            if (from_byte >= 0)            coding->dst_object = make_unibyte_string (buf, len);
4864              coding_save_composition (coding, from, to, object);            coding->produced = len;
           else  
             coding->composing = COMPOSITION_DISABLED;  
4865          }          }
4866    
       if (SBYTES (XPROCESS (proc)->encoding_buf) < require)  
         XPROCESS (proc)->encoding_buf = make_uninit_string (require);  
   
       if (from_byte >= 0)  
         buf = (BUFFERP (object)  
                ? BUF_BYTE_ADDRESS (XBUFFER (object), from_byte)  
                : SDATA (object) + from_byte);  
   
       object = XPROCESS (proc)->encoding_buf;  
       encode_coding (coding, (char *) buf, SDATA (object),  
                      len, SBYTES (object));  
4867        len = coding->produced;        len = coding->produced;
4868        buf = SDATA (object);        buf = SDATA (coding->dst_object);
       if (temp_buf)  
         xfree (temp_buf);  
4869      }      }
4870    
4871  #ifdef VMS  #ifdef VMS
# Line 6499  The value takes effect when `start-proce Line 6495  The value takes effect when `start-proce
6495    
6496  #include "lisp.h"  #include "lisp.h"
6497  #include "systime.h"  #include "systime.h"
6498  #include "charset.h"  #include "character.h"
6499  #include "coding.h"  #include "coding.h"
6500  #include "termopts.h"  #include "termopts.h"
6501  #include "sysselect.h"  #include "sysselect.h"

Legend:
Removed from v.1.408  
changed lines
  Added in v.1.408.2.1

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