+/* Return a character unified with C (or a character made of CHARSET,
+ C1, and C2) in unification table TABLE. If no unification is found
+ in TABLE, return C. */
+unify_char (table, c, charset, c1, c2)
+ Lisp_Object table;
+ int c, charset, c1, c2;
+{
+ Lisp_Object ch;
+ int alt_charset, alt_c1, alt_c2, dimension;
+
+ if (c < 0) c = MAKE_CHAR (charset, c1, c2);
+ if (!CHAR_TABLE_P (table)
+ || (ch = Faref (table, make_number (c)), !INTEGERP (ch))
+ || XINT (ch) < 0)
+ return c;
+
+ SPLIT_CHAR (XFASTINT (ch), alt_charset, alt_c1, alt_c2);
+ dimension = CHARSET_DIMENSION (alt_charset);
+ if (dimension == 1 && alt_c1 > 0 || dimension == 2 && alt_c2 > 0)
+ /* CH is not a generic character, just return it. */
+ return XFASTINT (ch);
+
+ /* Since CH is a generic character, we must return a specific
+ charater which has the same position codes as C from CH. */
+ if (charset < 0)
+ SPLIT_CHAR (c, charset, c1, c2);
+ if (dimension != CHARSET_DIMENSION (charset))
+ /* We can't make such a character because of dimension mismatch. */
+ return c;
+ if (!alt_c1) alt_c1 = c1;
+ if (!alt_c2) alt_c2 = c2;
+ return MAKE_CHAR (alt_charset, c1, c2);
+}
+