/[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.351 by eliz, Mon Jan 7 21:16:38 2002 UTC revision 1.351.2.1 by handa, Fri Mar 1 01:45:23 2002 UTC
# Line 98  Boston, MA 02111-1307, USA.  */ Line 98  Boston, MA 02111-1307, USA.  */
98  #include "lisp.h"  #include "lisp.h"
99  #include "window.h"  #include "window.h"
100  #include "buffer.h"  #include "buffer.h"
101  #include "charset.h"  #include "character.h"
102  #include "coding.h"  #include "coding.h"
103  #include "process.h"  #include "process.h"
104  #include "termhooks.h"  #include "termhooks.h"
# Line 3011  read_process_output (proc, channel) Line 3011  read_process_output (proc, channel)
3011           save the match data in a special nonrecursive fashion.  */           save the match data in a special nonrecursive fashion.  */
3012        running_asynch_code = 1;        running_asynch_code = 1;
3013    
3014        text = decode_coding_string (make_unibyte_string (chars, nbytes),        decode_coding_c_string (coding, chars, nbytes, Qt);
3015                                     coding, 0);        text = coding->dst_object;
3016        if (NILP (buffer_defaults.enable_multibyte_characters))        if (NILP (buffer_defaults.enable_multibyte_characters))
3017          /* We had better return unibyte string.  */          /* We had better return unibyte string.  */
3018          text = string_make_unibyte (text);          text = string_make_unibyte (text);
3019    
3020        Vlast_coding_system_used = coding->symbol;        Vlast_coding_system_used = CODING_ID_NAME (coding->id);
3021        /* A new coding system might be found.  */        /* A new coding system might be found.  */
3022        if (!EQ (p->decode_coding_system, coding->symbol))        if (!EQ (p->decode_coding_system, Vlast_coding_system_used))
3023          {          {
3024            p->decode_coding_system = coding->symbol;            p->decode_coding_system = Vlast_coding_system_used;
3025    
3026            /* Don't call setup_coding_system for            /* Don't call setup_coding_system for
3027               proc_decode_coding_system[channel] here.  It is done in               proc_decode_coding_system[channel] here.  It is done in
# Line 3037  read_process_output (proc, channel) Line 3037  read_process_output (proc, channel)
3037            if (NILP (p->encode_coding_system)            if (NILP (p->encode_coding_system)
3038                && proc_encode_coding_system[XINT (p->outfd)])                && proc_encode_coding_system[XINT (p->outfd)])
3039              {              {
3040                p->encode_coding_system = coding->symbol;                p->encode_coding_system = Vlast_coding_system_used;
3041                setup_coding_system (coding->symbol,                setup_coding_system (p->encode_coding_system,
3042                                     proc_encode_coding_system[XINT (p->outfd)]);                                     proc_encode_coding_system[XINT (p->outfd)]);
3043              }              }
3044          }          }
# Line 3128  read_process_output (proc, channel) Line 3128  read_process_output (proc, channel)
3128        if (! (BEGV <= PT && PT <= ZV))        if (! (BEGV <= PT && PT <= ZV))
3129          Fwiden ();          Fwiden ();
3130    
3131        text = decode_coding_string (make_unibyte_string (chars, nbytes),        decode_coding_c_string (coding, chars, nbytes, Qt);
3132                                     coding, 0);        text = coding->dst_object;
3133        Vlast_coding_system_used = coding->symbol;        Vlast_coding_system_used = CODING_ID_NAME (coding->id);
3134        /* A new coding system might be found.  See the comment in the        /* A new coding system might be found.  See the comment in the
3135           similar code in the previous `if' block.  */           similar code in the previous `if' block.  */
3136        if (!EQ (p->decode_coding_system, coding->symbol))        if (!EQ (p->decode_coding_system, Vlast_coding_system_used))
3137          {          {
3138            p->decode_coding_system = coding->symbol;            p->decode_coding_system = Vlast_coding_system_used;
3139            if (NILP (p->encode_coding_system)            if (NILP (p->encode_coding_system)
3140                && proc_encode_coding_system[XINT (p->outfd)])                && proc_encode_coding_system[XINT (p->outfd)])
3141              {              {
3142                p->encode_coding_system = coding->symbol;                p->encode_coding_system = Vlast_coding_system_used;
3143                setup_coding_system (coding->symbol,                setup_coding_system (p->encode_coding_system,
3144                                     proc_encode_coding_system[XINT (p->outfd)]);                                     proc_encode_coding_system[XINT (p->outfd)]);
3145              }              }
3146          }          }
# Line 3269  send_process (proc, buf, len, object) Line 3269  send_process (proc, buf, len, object)
3269             XSTRING (XPROCESS (proc)->name)->data);             XSTRING (XPROCESS (proc)->name)->data);
3270    
3271    coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];    coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];
3272    Vlast_coding_system_used = coding->symbol;    Vlast_coding_system_used = CODING_ID_NAME (coding->id);
3273    
3274    if ((STRINGP (object) && STRING_MULTIBYTE (object))    if ((STRINGP (object) && STRING_MULTIBYTE (object))
3275        || (BUFFERP (object)        || (BUFFERP (object)
3276            && !NILP (XBUFFER (object)->enable_multibyte_characters))            && !NILP (XBUFFER (object)->enable_multibyte_characters))
3277        || EQ (object, Qt))        || EQ (object, Qt))
3278      {      {
3279        if (!EQ (coding->symbol, XPROCESS (proc)->encode_coding_system))        if (!EQ (Vlast_coding_system_used,
3280                   XPROCESS (proc)->encode_coding_system))
3281          /* The coding system for encoding was changed to raw-text          /* The coding system for encoding was changed to raw-text
3282             because we sent a unibyte text previously.  Now we are             because we sent a unibyte text previously.  Now we are
3283             sending a multibyte text, thus we must encode it by the             sending a multibyte text, thus we must encode it by the
3284             original coding system specified for the current             original coding system specified for the current
3285             process.  */             process.  */
3286          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;  
3287      }      }
3288    else    else
3289      {      {
3290        /* For sending a unibyte text, character code conversion should        /* For sending a unibyte text, character code conversion should
3291           not take place but EOL conversion should.  So, setup raw-text           not take place but EOL conversion should.  So, setup raw-text
3292           or one of the subsidiary if we have not yet done it.  */           or one of the subsidiary if we have not yet done it.  */
3293        if (coding->type != coding_type_raw_text)        if (CODING_REQUIRE_ENCODING (coding))
3294          {          {
3295            if (CODING_REQUIRE_FLUSHING (coding))            if (CODING_REQUIRE_FLUSHING (coding))
3296              {              {
3297                /* But, before changing the coding, we must flush out data.  */                /* But, before changing the coding, we must flush out data.  */
3298                coding->mode |= CODING_MODE_LAST_BLOCK;                coding->mode |= CODING_MODE_LAST_BLOCK;
3299                send_process (proc, "", 0, Qt);                send_process (proc, "", 0, Qt);
3300                  coding->mode &= ~CODING_MODE_LAST_BLOCK;
3301              }              }
3302            coding->src_multibyte = 0;            coding->src_multibyte = 0;
3303            setup_raw_text_coding_system (coding);            setup_coding_system (raw_text_coding_system
3304                                   (Vlast_coding_system_used),
3305                                   coding);
3306          }          }
3307      }      }
3308    coding->dst_multibyte = 0;    coding->dst_multibyte = 0;
3309    
3310    if (CODING_REQUIRE_ENCODING (coding))    if (CODING_REQUIRE_ENCODING (coding))
3311      {      {
3312        int require = encoding_buffer_size (coding, len);        coding->dst_object = Qt;
       int from_byte = -1, from = -1, to = -1;  
       unsigned char *temp_buf = NULL;  
   
3313        if (BUFFERP (object))        if (BUFFERP (object))
3314          {          {
3315            from_byte = BUF_PTR_BYTE_POS (XBUFFER (object), buf);            int from_byte, from, to;
3316            from = buf_bytepos_to_charpos (XBUFFER (object), from_byte);            int save_pt, save_pt_byte;
3317            to = buf_bytepos_to_charpos (XBUFFER (object), from_byte + len);            struct buffer *cur = current_buffer;
3318    
3319              set_buffer_internal (XBUFFER (object));
3320              save_pt = PT, save_pt_byte = PT_BYTE;
3321    
3322              from_byte = PTR_BYTE_POS (buf);
3323              from = BYTE_TO_CHAR (from_byte);
3324              to = BYTE_TO_CHAR (from_byte + len);
3325              TEMP_SET_PT_BOTH (from, from_byte);
3326              encode_coding_object (coding, object, from, from_byte,
3327                                    to, from_byte + len, Qt);
3328              TEMP_SET_PT_BOTH (save_pt, save_pt_byte);
3329              set_buffer_internal (cur);
3330          }          }
3331        else if (STRINGP (object))        else if (STRINGP (object))
3332          {          {
3333            from_byte = buf - XSTRING (object)->data;            encode_coding_string (coding, object, 1);
           from = string_byte_to_char (object, from_byte);  
           to =  string_byte_to_char (object, from_byte + len);  
3334          }          }
3335          else
       if (coding->composing != COMPOSITION_DISABLED)  
3336          {          {
3337            if (from_byte >= 0)            coding->dst_object = make_unibyte_string (buf, len);
3338              coding_save_composition (coding, from, to, object);            coding->produced = len;
           else  
             coding->composing = COMPOSITION_DISABLED;  
3339          }          }
3340    
       if (STRING_BYTES (XSTRING (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)  
                : XSTRING (object)->data + from_byte);  
   
       object = XPROCESS (proc)->encoding_buf;  
       encode_coding (coding, (char *) buf, XSTRING (object)->data,  
                      len, STRING_BYTES (XSTRING (object)));  
3341        len = coding->produced;        len = coding->produced;
3342        buf = XSTRING (object)->data;        buf = XSTRING (coding->dst_object)->data;
       if (temp_buf)  
         xfree (temp_buf);  
3343      }      }
3344    
3345  #ifdef VMS  #ifdef VMS
# Line 4726  The value takes effect when `start-proce Line 4717  The value takes effect when `start-proce
4717    
4718  #include "lisp.h"  #include "lisp.h"
4719  #include "systime.h"  #include "systime.h"
4720  #include "charset.h"  #include "character.h"
4721  #include "coding.h"  #include "coding.h"
4722  #include "termopts.h"  #include "termopts.h"
4723  #include "sysselect.h"  #include "sysselect.h"

Legend:
Removed from v.1.351  
changed lines
  Added in v.1.351.2.1

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