/[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.16 by handa, Tue May 21 05:09:20 2002 UTC revision 1.239.2.17 by handa, Wed May 22 11:14:45 2002 UTC
# Line 4320  decode_coding_charset (coding) Line 4320  decode_coding_charset (coding)
4320        ONE_MORE_BYTE (c);        ONE_MORE_BYTE (c);
4321        if (c == '\r')        if (c == '\r')
4322          {          {
4323              /* Here we assume that no charset maps '\r' to something
4324                 else.  */
4325            if (EQ (eol_type, Qdos))            if (EQ (eol_type, Qdos))
4326              {              {
4327                if (src < src_end                if (src < src_end
# Line 4333  decode_coding_charset (coding) Line 4335  decode_coding_charset (coding)
4335          {          {
4336            Lisp_Object val;            Lisp_Object val;
4337            struct charset *charset;            struct charset *charset;
4338              int dim;
4339              unsigned code;
4340            int c1;            int c1;
4341    
4342            val = AREF (valids, c);            val = AREF (valids, c);
4343            if (NILP (val))            if (NILP (val))
4344              goto invalid_code;              goto invalid_code;
4345            charset = CHARSET_FROM_ID (XFASTINT (val));            if (INTEGERP (val))
           if (CHARSET_DIMENSION (charset) > 1)  
4346              {              {
4347                ONE_MORE_BYTE (c1);                charset = CHARSET_FROM_ID (XFASTINT (val));
4348                c = (c << 8) | c1;                dim = CHARSET_DIMENSION (charset);
4349                if (CHARSET_DIMENSION (charset) > 2)                code = c;
4350                  if (dim > 1)
4351                  {                  {
4352                    ONE_MORE_BYTE (c1);                    ONE_MORE_BYTE (c1);
4353                    c = (c << 8) | c1;                    code = (code << 8) | c1;
4354                    if (CHARSET_DIMENSION (charset) > 3)                    if (dim > 2)
4355                      {                      {
4356                        ONE_MORE_BYTE (c1);                        ONE_MORE_BYTE (c1);
4357                        c = (c << 8) | c1;                        code = (code << 8) | c1;
4358                          if (dim > 3)
4359                            {
4360                              ONE_MORE_BYTE (c1);
4361                              code = (c << 8) | c1;
4362                            }
4363                      }                      }
4364                  }                  }
4365                  CODING_DECODE_CHAR (coding, src, src_base, src_end,
4366                                      charset, code, c);
4367                }
4368              else
4369                {
4370                  /* VAL is a list of charset IDs.  It is assured that the
4371                     list is sorted by charset dimensions (smaller one
4372                     comes first).  */
4373                  int b[4];
4374                  int len = 1;
4375    
4376                  b[0] = c;
4377                  /* VAL is a list of charset IDs.  */
4378                  while (CONSP (val))
4379                    {
4380                      charset = CHARSET_FROM_ID (XFASTINT (XCAR (val)));
4381                      dim = CHARSET_DIMENSION (charset);
4382                      while (len < dim)
4383                        {
4384                          ONE_MORE_BYTE (c1);
4385                          b[len++] = c1;
4386                        }
4387                      if (dim == 1)
4388                        code = b[0];
4389                      else if (dim == 2)
4390                        code = (b[0] << 8) | b[1];
4391                      else if (dim == 3)
4392                        code = (b[0] << 16) | (b[1] << 8) | b[2];
4393                      else
4394                        code = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
4395                      CODING_DECODE_CHAR (coding, src, src_base,
4396                                          src_end, charset, code, c);
4397                      if (c >= 0)
4398                        break;
4399                      val = XCDR (val);
4400                    }
4401              }              }
           CODING_DECODE_CHAR (coding, src, src_base, src_end, charset, c, c);  
4402            if (c < 0)            if (c < 0)
4403              goto invalid_code;              goto invalid_code;
4404          }          }
# Line 7366  usage: (define-coding-system-internal .. Line 7410  usage: (define-coding-system-internal ..
7410    
7411    if (EQ (coding_type, Qcharset))    if (EQ (coding_type, Qcharset))
7412      {      {
7413          /* Generate a lisp vector of 256 elements.  Each element is nil,
7414             integer, or a list of charset IDs.
7415    
7416             If Nth element is nil, the byte code N is invalid in this
7417             coding system.
7418    
7419             If Nth element is a number NUM, N is the first byte of a
7420             charset whose ID is NUM.
7421    
7422             If Nth element is a list of charset IDs, N is the first byte
7423             of one of them.  The list is sorted by dimensions of the
7424             charsets.  A charset of smaller dimension comes firtst.
7425          */
7426        val = Fmake_vector (make_number (256), Qnil);        val = Fmake_vector (make_number (256), Qnil);
7427    
7428        for (tail = charset_list; CONSP (tail); tail = XCDR (tail))        for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
7429          {          {
7430            struct charset *charset = CHARSET_FROM_ID (XINT (XCAR (tail)));            struct charset *charset = CHARSET_FROM_ID (XFASTINT (XCAR (tail)));
7431            int idx = (CHARSET_DIMENSION (charset) - 1) * 4;            int dim = CHARSET_DIMENSION (charset);
7432              int idx = (dim - 1) * 4;
7433              
7434            for (i = charset->code_space[idx];            for (i = charset->code_space[idx];
7435                 i <= charset->code_space[idx + 1]; i++)                 i <= charset->code_space[idx + 1]; i++)
7436              {              {
7437                if (NILP (AREF (val, i)))                Lisp_Object tmp, tmp2;
7438                  ASET (val, i, XCAR (tail));                int dim2;
7439    
7440                  tmp = AREF (val, i);
7441                  if (NILP (tmp))
7442                    tmp = XCAR (tail);
7443                  else if (NUMBERP (tmp))
7444                    {
7445                      dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (tmp)));
7446                      if (dim < dim2)
7447                        tmp = Fcons (tmp, Fcons (XCAR (tail), Qnil));
7448                      else
7449                        tmp = Fcons (XCAR (tail), Fcons (tmp, Qnil));
7450                    }
7451                else                else
7452                  error ("Charsets conflicts in the first byte");                  {
7453                      for (tmp2 = tmp; CONSP (tmp2); tmp2 = XCDR (tmp2))
7454                        {
7455                          dim2 = CHARSET_DIMENSION (CHARSET_FROM_ID (XFASTINT (XCAR (tmp2))));
7456                          if (dim < dim2)
7457                            break;
7458                        }
7459                      if (NILP (tmp2))
7460                        tmp = nconc2 (tmp, Fcons (XCAR (tail), Qnil));
7461                      else
7462                        {
7463                          XSETCDR (tmp2, Fcons (XCAR (tmp2), XCDR (tmp2)));
7464                          XSETCAR (tmp2, XCAR (tail));
7465                        }
7466                    }
7467                  ASET (val, i, tmp);
7468              }              }
7469          }          }
7470        ASET (attrs, coding_attr_charset_valids, val);        ASET (attrs, coding_attr_charset_valids, val);

Legend:
Removed from v.1.239.2.16  
changed lines
  Added in v.1.239.2.17

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