(get_translation_table): Declare it as Lisp_Object.
authorKenichi Handa <handa@m17n.org>
Thu, 11 Mar 2004 05:54:58 +0000 (05:54 +0000)
committerKenichi Handa <handa@m17n.org>
Thu, 11 Mar 2004 05:54:58 +0000 (05:54 +0000)
(LOOKUP_TRANSLATION_TABLE): New macro.
(produce_chars): Use LOOKUP_TRANSLATION_TABLE instead of
CHAR_TABLE_REF.
(consume_chars): Likewise.

src/coding.c

index e4d2fda..ef66395 100644 (file)
@@ -5507,7 +5507,7 @@ decode_eol (coding)
    attribute vector ATTRS for encoding (ENCODEP is nonzero) or
    decoding (ENCODEP is zero). */
 
-static INLINE
+static Lisp_Object
 get_translation_table (attrs, encodep)
 {
   Lisp_Object standard, translation_table;
@@ -5541,6 +5541,30 @@ get_translation_table (attrs, encodep)
   return translation_table;
 }
 
+#define LOOKUP_TRANSLATION_TABLE(table, c, trans)      \
+  do {                                                 \
+    if (CHAR_TABLE_P (table))                          \
+      {                                                        \
+       trans = CHAR_TABLE_REF (table, c);              \
+       if (CHARACTERP (trans))                         \
+         c = XFASTINT (trans), trans = Qnil;           \
+      }                                                        \
+    else                                               \
+      {                                                        \
+       Lisp_Object tail = table;                       \
+                                                       \
+       for (; CONSP (tail); tail = XCDR (tail))        \
+         if (CHAR_TABLE_P (XCAR (tail)))               \
+           {                                           \
+             trans = CHAR_TABLE_REF (table, c);        \
+             if (CHARACTERP (trans))                   \
+               c = XFASTINT (trans), trans = Qnil;     \
+             else if (! NILP (trans))                  \
+               break;                                  \
+           }                                           \
+      }                                                        \
+  } while (0)
+
 
 static Lisp_Object
 get_translation (val, buf, buf_end, last_block, from_nchars, to_nchars)
@@ -5621,8 +5645,9 @@ produce_chars (coding, translation_table, last_block)
              int from_nchars = 1, to_nchars = 1;
              Lisp_Object trans = Qnil;
 
-             if (! NILP (translation_table)
-                 && ! NILP (trans = CHAR_TABLE_REF (translation_table, c)))
+             if (! NILP (translation_table))
+               LOOKUP_TRANSLATION_TABLE (translation_table, c, trans);
+             if (! NILP (trans))
                {
                  trans = get_translation (trans, buf, buf_end, last_block,
                                           &from_nchars, &to_nchars);
@@ -6264,8 +6289,10 @@ consume_chars (coding, translation_table)
            }
        }
 
-      if (NILP (translation_table)
-         || NILP (trans = CHAR_TABLE_REF (translation_table, c)))
+      trans = Qnil;
+      if (! NILP (translation_table))
+       LOOKUP_TRANSLATION_TABLE (translation_table, c, trans);
+      if (NILP (trans))
        *buf++ = c;
       else
        {