]> code.delx.au - gnu-emacs/commitdiff
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
authorK. Handa <handa@gnu.org>
Tue, 31 May 2016 23:07:18 +0000 (08:07 +0900)
committerK. Handa <handa@gnu.org>
Tue, 31 May 2016 23:07:18 +0000 (08:07 +0900)
1  2 
src/coding.c

diff --combined src/coding.c
index 55a4cea7c0b66c74f766c7b611a4beba81090a7e,9d75ef931021bacac25d1eba00fed9703a52f436..a28fec1efe49cc77865cb6ef7d0274043f065114
@@@ -6947,21 -6947,18 +6947,21 @@@ get_translation_table (Lisp_Object attr
  
  
  /* Return a translation of character(s) at BUF according to TRANS.
 -   TRANS is TO-CHAR or ((FROM .  TO) ...) where
 -   FROM = [FROM-CHAR ...], TO is TO-CHAR or [TO-CHAR ...].
 -   The return value is TO-CHAR or ([FROM-CHAR ...] . TO) if a
 -   translation is found, and Qnil if not found..
 -   If BUF is too short to lookup characters in FROM, return Qt.  */
 +   TRANS is TO-CHAR, [TO-CHAR ...], or ((FROM .  TO) ...) where FROM =
 +   [FROM-CHAR ...], TO is TO-CHAR or [TO-CHAR ...].  The return value
 +   is TO-CHAR or [TO-CHAR ...] if a translation is found, Qnil if not
 +   found, or Qt if BUF is too short to lookup characters in FROM.  As
 +   a side effect, if a translation is found, *NCHARS is set to the
 +   number of characters being translated.  */
  
  static Lisp_Object
 -get_translation (Lisp_Object trans, int *buf, int *buf_end)
 +get_translation (Lisp_Object trans, int *buf, int *buf_end, ptrdiff_t *nchars)
  {
 -
 -  if (INTEGERP (trans))
 -    return trans;
 +  if (INTEGERP (trans) || VECTORP (trans))
 +    {
 +      *nchars = 1;
 +      return trans;
 +    }
    for (; CONSP (trans); trans = XCDR (trans))
      {
        Lisp_Object val = XCAR (trans);
            break;
        }
        if (i == len)
 -      return val;
 +      {
 +        *nchars = len;
 +        return XCDR (val);
 +      }
      }
    return Qnil;
  }
@@@ -7023,13 -7017,20 +7023,13 @@@ produce_chars (struct coding_system *co
              LOOKUP_TRANSLATION_TABLE (translation_table, c, trans);
              if (! NILP (trans))
                {
 -                trans = get_translation (trans, buf, buf_end);
 +                trans = get_translation (trans, buf, buf_end, &from_nchars);
                  if (INTEGERP (trans))
                    c = XINT (trans);
 -                else if (CONSP (trans))
 +                else if (VECTORP (trans))
                    {
 -                    from_nchars = ASIZE (XCAR (trans));
 -                    trans = XCDR (trans);
 -                    if (INTEGERP (trans))
 -                      c = XINT (trans);
 -                    else
 -                      {
 -                        to_nchars = ASIZE (trans);
 -                        c = XINT (AREF (trans, 0));
 -                      }
 +                    to_nchars = ASIZE (trans);
 +                    c = XINT (AREF (trans, 0));
                    }
                  else if (EQ (trans, Qt) && ! last_block)
                    break;
@@@ -7670,16 -7671,22 +7670,16 @@@ consume_chars (struct coding_system *co
          for (i = 1; i < max_lookup && p < src_end; i++)
            lookup_buf[i] = STRING_CHAR_ADVANCE (p);
          lookup_buf_end = lookup_buf + i;
 -        trans = get_translation (trans, lookup_buf, lookup_buf_end);
 +        trans = get_translation (trans, lookup_buf, lookup_buf_end,
 +                                 &from_nchars);
          if (INTEGERP (trans))
            c = XINT (trans);
 -        else if (CONSP (trans))
 +        else if (VECTORP (trans))
            {
 -            from_nchars = ASIZE (XCAR (trans));
 -            trans = XCDR (trans);
 -            if (INTEGERP (trans))
 -              c = XINT (trans);
 -            else
 -              {
 -                to_nchars = ASIZE (trans);
 -                if (buf_end - buf < to_nchars)
 -                  break;
 -                c = XINT (AREF (trans, 0));
 -              }
 +            to_nchars = ASIZE (trans);
 +            if (buf_end - buf < to_nchars)
 +              break;
 +            c = XINT (AREF (trans, 0));
            }
          else
            break;
@@@ -8008,12 -8015,12 +8008,12 @@@ decode_coding_object (struct coding_sys
                      Lisp_Object dst_object)
  {
    ptrdiff_t count = SPECPDL_INDEX ();
-   unsigned char *destination IF_LINT (= NULL);
-   ptrdiff_t dst_bytes IF_LINT (= 0);
+   unsigned char *destination;
+   ptrdiff_t dst_bytes;
    ptrdiff_t chars = to - from;
    ptrdiff_t bytes = to_byte - from_byte;
    Lisp_Object attrs;
-   ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0);
+   ptrdiff_t saved_pt = -1, saved_pt_byte;
    bool need_marker_adjustment = 0;
    Lisp_Object old_deactivate_mark;
  
@@@ -8191,7 -8198,7 +8191,7 @@@ encode_coding_object (struct coding_sys
    ptrdiff_t chars = to - from;
    ptrdiff_t bytes = to_byte - from_byte;
    Lisp_Object attrs;
-   ptrdiff_t saved_pt = -1, saved_pt_byte IF_LINT (= 0);
+   ptrdiff_t saved_pt = -1, saved_pt_byte;
    bool need_marker_adjustment = 0;
    bool kill_src_buffer = 0;
    Lisp_Object old_deactivate_mark;