(char_byte_table_equal): Fill braces to avoid ambiguous `else'.
[chise/xemacs-chise.git] / src / char-ucs.h
index 42d98ef..a47ea80 100644 (file)
@@ -29,15 +29,23 @@ Boston, MA 02111-1307, USA.  */
 #define CHAR_ASCII_P(ch) ((ch) <= 0x7F)
 
 \f
-typedef struct
+DECLARE_LRECORD (char_byte_table, struct Lisp_Char_Byte_Table);
+#define XCHAR_BYTE_TABLE(x) \
+  XRECORD (x, char_byte_table, struct Lisp_Char_Byte_Table)
+#define XSETCHAR_BYTE_TABLE(x, p) XSETRECORD (x, p, char_byte_table)
+#define CHAR_BYTE_TABLE_P(x) RECORDP (x, char_byte_table)
+#define GC_CHAR_BYTE_TABLE_P(x) GC_RECORDP (x, char_byte_table)
+/* #define CHECK_CHAR_BYTE_TABLE(x) CHECK_RECORD (x, char_byte_table)
+   char table entries should never escape to Lisp */
+
+struct Lisp_Char_Byte_Table
 {
-  unsigned char *base;
-  size_t  offset;
-  size_t  size;
-} Emchar_to_byte_table;
+  struct lcrecord_header header;
+
+  Lisp_Object property[256];
+};
 
-unsigned char
-get_byte_from_character_table (Emchar ch, Emchar_to_byte_table* table);
+Lisp_Object get_char_code_table (Emchar ch, Lisp_Object table);
 
 
 extern Lisp_Object Vcharset_ucs_bmp;
@@ -62,7 +70,7 @@ typedef int Charset_ID;
 #define LEADING_BYTE_CONTROL_1         0x81 /* represent normal 80-9F */
 #define LEADING_BYTE_HIRAGANA_JISX0208 0x82
 #define LEADING_BYTE_KATAKANA_JISX0208 0x83
-
+#define LEADING_BYTE_LATIN_VISCII      0x84
 
 #define CHARSET_ID_OFFSET_94           0x55
 
@@ -221,8 +229,7 @@ struct Lisp_Charset
   Lisp_Object decoding_table;
 
   /* Character->byte mapping table */
-  Emchar_to_byte_table* to_byte1_table;
-  Emchar_to_byte_table* to_byte2_table;
+  Lisp_Object encoding_table;
 
   /* Range of character code */
   Emchar ucs_min, ucs_max;
@@ -242,12 +249,14 @@ DECLARE_LRECORD (charset, struct Lisp_Charset);
 #define CHECK_CHARSET(x) CHECK_RECORD (x, charset)
 #define CONCHECK_CHARSET(x) CONCHECK_RECORD (x, charset)
 
-#define CHARSET_TYPE_94      0 /* This charset includes 94    characters. */
-#define CHARSET_TYPE_96      1 /* This charset includes 96    characters. */
-#define CHARSET_TYPE_94X94   2 /* This charset includes 94x94 characters. */
-#define CHARSET_TYPE_96X96   3 /* This charset includes 96x96 characters. */
-#define CHARSET_TYPE_128X128 4 /* This charset includes 128x128 characters. */
-#define CHARSET_TYPE_256X256 5 /* This charset includes 256x256 characters. */
+#define CHARSET_TYPE_94      0 /* This charset includes 94      characters. */
+#define CHARSET_TYPE_94X94   1 /* This charset includes 94x94   characters. */
+#define CHARSET_TYPE_96      2 /* This charset includes 96      characters. */
+#define CHARSET_TYPE_96X96   3 /* This charset includes 96x96   characters. */
+#define CHARSET_TYPE_128     4 /* This charset includes 128     characters. */
+#define CHARSET_TYPE_128X128 5 /* This charset includes 128x128 characters. */
+#define CHARSET_TYPE_256     6 /* This charset includes 256     characters. */
+#define CHARSET_TYPE_256X256 7 /* This charset includes 256x256 characters. */
 
 #define CHARSET_LEFT_TO_RIGHT  0
 #define CHARSET_RIGHT_TO_LEFT  1
@@ -270,8 +279,7 @@ DECLARE_LRECORD (charset, struct Lisp_Charset);
 #define CHARSET_CHARS(cs)       ((cs)->chars)
 #define CHARSET_REVERSE_DIRECTION_CHARSET(cs) ((cs)->reverse_direction_charset)
 #define CHARSET_DECODING_TABLE(cs) ((cs)->decoding_table)
-#define CHARSET_TO_BYTE1_TABLE(cs) ((cs)->to_byte1_table)
-#define CHARSET_TO_BYTE2_TABLE(cs) ((cs)->to_byte2_table)
+#define CHARSET_ENCODING_TABLE(cs) ((cs)->encoding_table)
 #define CHARSET_UCS_MIN(cs)     ((cs)->ucs_min)
 #define CHARSET_UCS_MAX(cs)     ((cs)->ucs_max)
 #define CHARSET_CODE_OFFSET(cs)         ((cs)->code_offset)
@@ -295,8 +303,7 @@ DECLARE_LRECORD (charset, struct Lisp_Charset);
 #define XCHARSET_REVERSE_DIRECTION_CHARSET(cs) \
   CHARSET_REVERSE_DIRECTION_CHARSET (XCHARSET (cs))
 #define XCHARSET_DECODING_TABLE(cs) CHARSET_DECODING_TABLE(XCHARSET(cs))
-#define XCHARSET_TO_BYTE1_TABLE(cs) CHARSET_TO_BYTE1_TABLE(XCHARSET(cs))
-#define XCHARSET_TO_BYTE2_TABLE(cs) CHARSET_TO_BYTE2_TABLE(XCHARSET(cs))
+#define XCHARSET_ENCODING_TABLE(cs) CHARSET_ENCODING_TABLE(XCHARSET(cs))
 #define XCHARSET_UCS_MIN(cs)     CHARSET_UCS_MIN(XCHARSET(cs))
 #define XCHARSET_UCS_MAX(cs)     CHARSET_UCS_MAX(XCHARSET(cs))
 #define XCHARSET_CODE_OFFSET(cs)  CHARSET_CODE_OFFSET(XCHARSET(cs))
@@ -359,6 +366,9 @@ CHARSET_BY_LEADING_BYTE (Charset_ID lb)
 #define MIN_CHAR_HALFWIDTH_KATAKANA    0xFF61
 #define MAX_CHAR_HALFWIDTH_KATAKANA    0xFF9F
 
+#define MIN_CHAR_OBS_94x94     0xE00000
+#define MAX_CHAR_OBS_94x94     (0xE00000 + 94 * 94 * 14 - 1)
+
 #define MIN_CHAR_94            0xE90940
 #define MAX_CHAR_94            (MIN_CHAR_94 + 94 * 80 - 1)
 #define MIN_CHAR_96            (MIN_CHAR_94 + 94 * 80)
@@ -382,11 +392,21 @@ MAKE_CHAR (Lisp_Object charset, int c1, int c2)
   Lisp_Object ch;
 
   if (!EQ (decoding_table, Qnil)
-      && (0 <= (idx = c1 - (XCHARSET_CHARS (charset) == 94 ? 33 : 32)))
+      && (0 <= (idx = c1 - XCHARSET_BYTE_OFFSET (charset)))
       && (idx < XVECTOR_LENGTH (decoding_table))
       && !EQ (ch = XVECTOR_DATA(decoding_table)[idx], Qnil))
-    return XCHAR (ch);
-  else if (EQ (charset, Vcharset_katakana_jisx0201))
+    {
+      if (VECTORP (ch))
+       {
+         if ((0 <= (idx = c2 - XCHARSET_BYTE_OFFSET (charset)))
+             && (idx < XVECTOR_LENGTH (ch))
+             && !EQ (ch = XVECTOR_DATA(ch)[idx], Qnil))
+           return XCHAR (ch);
+       }
+      else
+       return XCHAR (ch);
+    }
+  if (EQ (charset, Vcharset_katakana_jisx0201))
     if (c1 < 0x60)
       return c1 + MIN_CHAR_HALFWIDTH_KATAKANA - 33;
     else
@@ -450,7 +470,7 @@ INLINE void breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2);
 INLINE void
 breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2)
 {
-  if (c < MIN_CHAR_94)
+  if (c < MIN_CHAR_OBS_94x94)
     {
       Lisp_Object charsets = Vdefault_coded_charset_priority_list;
       while (!EQ (charsets, Qnil))
@@ -521,6 +541,15 @@ breakup_char_1 (Emchar c, Lisp_Object *charset, int *c1, int *c2)
          *c2 = c & 0xff;
        }
     }
+  else if (c <= MAX_CHAR_OBS_94x94)
+    {
+      *charset
+       = CHARSET_BY_ATTRIBUTES (CHARSET_TYPE_94X94,
+                                ((c - MIN_CHAR_OBS_94x94) / (94 * 94)) + '@',
+                                CHARSET_LEFT_TO_RIGHT);
+      *c1 = (((c - MIN_CHAR_OBS_94x94) / 94) % 94) + 33;
+      *c2 = ((c - MIN_CHAR_OBS_94x94) % 94) + 33;
+    }
   else if (c <= MAX_CHAR_94)
     {
       *charset