changeset 89858:23cb9ed79225

(get_translation_table): Declare it as Lisp_Object. (LOOKUP_TRANSLATION_TABLE): New macro. (produce_chars): Use LOOKUP_TRANSLATION_TABLE instead of CHAR_TABLE_REF. (consume_chars): Likewise.
author Kenichi Handa <handa@m17n.org>
date Thu, 11 Mar 2004 05:54:58 +0000
parents b7584a65f2b8
children b706c5ee6492
files src/coding.c
diffstat 1 files changed, 32 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/coding.c	Thu Mar 11 02:18:25 2004 +0000
+++ b/src/coding.c	Thu Mar 11 05:54:58 2004 +0000
@@ -5507,7 +5507,7 @@
    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 @@
   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 @@
 	      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 @@
 	    }
 	}
 
-      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
 	{