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

Diff of /emacs/src/coding.c

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

revision 1.239.2.5 by handa, Tue May 7 04:50:48 2002 UTC revision 1.239.2.6 by handa, Wed May 8 04:19:41 2002 UTC
# Line 4258  decode_coding_charset (coding) Line 4258  decode_coding_charset (coding)
4258    int *charbuf_end = charbuf + coding->charbuf_size;    int *charbuf_end = charbuf + coding->charbuf_size;
4259    int consumed_chars = 0, consumed_chars_base;    int consumed_chars = 0, consumed_chars_base;
4260    int multibytep = coding->src_multibyte;    int multibytep = coding->src_multibyte;
4261    struct charset *charset;    Lisp_Object attrs, eol_type, charset_list, valids;
   Lisp_Object attrs, eol_type, charset_list;  
4262    
4263    CODING_GET_INFO (coding, attrs, eol_type, charset_list);    CODING_GET_INFO (coding, attrs, eol_type, charset_list);
4264    charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));    valids = AREF (attrs, coding_attr_charset_valids);
4265    
4266    while (1)    while (1)
4267      {      {
4268        int c, c1;        int c;
4269    
4270        src_base = src;        src_base = src;
4271        consumed_chars_base = consumed_chars;        consumed_chars_base = consumed_chars;
# Line 4274  decode_coding_charset (coding) Line 4273  decode_coding_charset (coding)
4273        if (charbuf >= charbuf_end)        if (charbuf >= charbuf_end)
4274          break;          break;
4275    
4276        ONE_MORE_BYTE (c1);        ONE_MORE_BYTE (c);
4277        if (c == '\r')        if (c == '\r')
4278          {          {
4279            if (EQ (eol_type, Qdos))            if (EQ (eol_type, Qdos))
4280              {              {
4281                if (src == src_end)                if (src < src_end
4282                  goto no_more_source;                    && *src == '\n')
               if (*src == '\n')  
4283                  ONE_MORE_BYTE (c);                  ONE_MORE_BYTE (c);
4284              }              }
4285            else if (EQ (eol_type, Qmac))            else if (EQ (eol_type, Qmac))
# Line 4289  decode_coding_charset (coding) Line 4287  decode_coding_charset (coding)
4287          }          }
4288        else        else
4289          {          {
4290            CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c1, c);            Lisp_Object val;
4291              struct charset *charset;
4292              int c1;
4293    
4294              val = AREF (valids, c);
4295              if (NILP (val))
4296                goto invalid_code;
4297              charset = CHARSET_FROM_ID (XFASTINT (val));
4298              if (CHARSET_DIMENSION (charset) > 1)
4299                {
4300                  ONE_MORE_BYTE (c1);
4301                  c = (c << 8) | c1;
4302                  if (CHARSET_DIMENSION (charset) > 2)
4303                    {
4304                      ONE_MORE_BYTE (c1);
4305                      c = (c << 8) | c1;
4306                      if (CHARSET_DIMENSION (charset) > 3)
4307                        {
4308                          ONE_MORE_BYTE (c1);
4309                          c = (c << 8) | c1;
4310                        }
4311                    }
4312                }
4313              CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c);
4314            if (c < 0)            if (c < 0)
4315              goto invalid_code;              goto invalid_code;
4316          }          }
# Line 4327  encode_coding_charset (coding) Line 4348  encode_coding_charset (coding)
4348    int c;    int c;
4349    
4350    CODING_GET_INFO (coding, attrs, eol_type, charset_list);    CODING_GET_INFO (coding, attrs, eol_type, charset_list);
   charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));  
4351    ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs));    ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs));
4352    
4353    while (charbuf < charbuf_end)    while (charbuf < charbuf_end)
4354      {      {
4355          struct charset *charset;
4356        unsigned code;        unsigned code;
4357                
4358        ASSURE_DESTINATION (safe_room);        ASSURE_DESTINATION (safe_room);
4359        c = *charbuf++;        c = *charbuf++;
4360        if (ascii_compatible && ASCII_CHAR_P (c))        if (ascii_compatible && ASCII_CHAR_P (c))
4361          EMIT_ONE_ASCII_BYTE (c);          EMIT_ONE_ASCII_BYTE (c);
       else if ((code = ENCODE_CHAR (charset, c))  
                != CHARSET_INVALID_CODE (charset))  
         EMIT_ONE_BYTE (code);  
4362        else        else
4363          EMIT_ONE_BYTE (coding->default_char);          {
4364              charset = char_charset (c, charset_list, &code);
4365              if (charset)
4366                {
4367                  if (CHARSET_DIMENSION (charset) == 1)
4368                    EMIT_ONE_BYTE (code);
4369                  else if (CHARSET_DIMENSION (charset) == 2)
4370                    EMIT_TWO_BYTES (code >> 8, code & 0xFF);
4371                  else if (CHARSET_DIMENSION (charset) == 3)
4372                    EMIT_THREE_BYTES (code >> 16, (code >> 8) & 0xFF, code & 0xFF);
4373                  else
4374                    EMIT_FOUR_BYTES (code >> 24, (code >> 16) & 0xFF,
4375                                     (code >> 8) & 0xFF, code & 0xFF);
4376                }
4377              else
4378                EMIT_ONE_BYTE (coding->default_char);
4379            }
4380      }      }
4381    
4382    coding->result = CODING_RESULT_SUCCESS;    coding->result = CODING_RESULT_SUCCESS;

Legend:
Removed from v.1.239.2.5  
changed lines
  Added in v.1.239.2.6

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