(M17260): Separate U+6CBF, J90-3168 and C1-4E58.
[chise/xemacs-chise.git] / src / mule-charset.h
index 07f72df..3d51fdc 100644 (file)
@@ -239,7 +239,7 @@ Boston, MA 02111-1307, USA.  */
 
    Character set               Encoding (PC == position-code)
    -------------               -------- (LB == leading-byte)
-   ASCII                       PC1 |
+   ASCII                       PC1  |
    Control-1                   LB   | PC1 + 0xA0
    Dimension-1 official                LB   | PC1 + 0x80
    Dimension-1 private         0x9E | LB         | PC1 + 0x80
@@ -324,6 +324,8 @@ Boston, MA 02111-1307, USA.  */
 /*                    Definition of leading bytes                       */
 /************************************************************************/
 
+typedef int Charset_ID;
+
 #define MIN_LEADING_BYTE               0x80
 /* These need special treatment in a string and/or character */
 #define LEADING_BYTE_ASCII             0x8E /* Omitted in a buffer */
@@ -548,8 +550,8 @@ DECLARE_LRECORD (charset, struct Lisp_Charset);
   CHARSET_REVERSE_DIRECTION_CHARSET (XCHARSET (cs))
 
 struct charset_lookup {
-  /* Table of charsets indexed by leading byte. */
-  Lisp_Object charset_by_leading_byte[128];
+  /* Table of charsets indexed by (leading byte - MIN_LEADING_BYTE). */
+  Lisp_Object charset_by_leading_byte[NUM_LEADING_BYTES];
   
   /* Table of charsets indexed by type/final-byte/direction. */
   Lisp_Object charset_by_attributes[4][128][2];
@@ -557,17 +559,6 @@ struct charset_lookup {
 
 extern struct charset_lookup *chlook;
 
-/* Table of number of bytes in the string representation of a character
-   indexed by the first byte of that representation.
-
-   This value can be derived other ways -- e.g. something like
-
-   (BYTE_ASCII_P (first_byte) ? 1 :
-    XCHARSET_REP_BYTES (CHARSET_BY_LEADING_BYTE (first_byte)))
-
-   but it's faster this way. */
-extern Bytecount rep_bytes_by_first_byte[0xA0];
-
 #ifdef ERROR_CHECK_TYPECHECK
 /* int not Bufbyte even though that is the actual type of a leading byte.
    This way, out-ot-range values will get caught rather than automatically
@@ -576,44 +567,47 @@ INLINE Lisp_Object CHARSET_BY_LEADING_BYTE (int lb);
 INLINE Lisp_Object
 CHARSET_BY_LEADING_BYTE (int lb)
 {
-  assert (lb >= 0x80 && lb <= 0xFF);
-  return chlook->charset_by_leading_byte[lb - 128];
+  assert (lb >= MIN_LEADING_BYTE &&
+         lb < (MIN_LEADING_BYTE + NUM_LEADING_BYTES));
+  return chlook->charset_by_leading_byte[lb - MIN_LEADING_BYTE];
 }
 
 #else
 
-#define CHARSET_BY_LEADING_BYTE(lb) (chlook->charset_by_leading_byte[(lb) - 128])
+#define CHARSET_BY_LEADING_BYTE(lb) \
+  (chlook->charset_by_leading_byte[(lb) - MIN_LEADING_BYTE])
 
 #endif
 
 #define CHARSET_BY_ATTRIBUTES(type, final, dir) \
   (chlook->charset_by_attributes[type][final][dir])
 
-#ifdef ERROR_CHECK_TYPECHECK
 
-/* Number of bytes in the string representation of a character */
+/* Table of number of bytes in the string representation of a character
+   indexed by the first byte of that representation.
+
+   This value can be derived in other ways -- e.g. something like
+   XCHARSET_REP_BYTES (CHARSET_BY_LEADING_BYTE (first_byte))
+   but it's faster this way. */
+extern const Bytecount rep_bytes_by_first_byte[0xA0];
+
+/* Number of bytes in the string representation of a character. */
 INLINE int REP_BYTES_BY_FIRST_BYTE (int fb);
 INLINE int
 REP_BYTES_BY_FIRST_BYTE (int fb)
 {
-  assert (fb >= 0 && fb < 0xA0);
+#ifdef ERROR_CHECK_TYPECHECK
+  assert (0 <= fb && fb < 0xA0);
+#endif
   return rep_bytes_by_first_byte[fb];
 }
 
-#else
-#define REP_BYTES_BY_FIRST_BYTE(fb) (rep_bytes_by_first_byte[fb])
-#endif
-
 \f
 /************************************************************************/
 /*                        Dealing with characters                       */
 /************************************************************************/
 
-/* Is this character represented by more than one byte in a string? */
-
-#define CHAR_MULTIBYTE_P(c) ((c) >= 0x80)
-
-#define CHAR_ASCII_P(c) (!CHAR_MULTIBYTE_P (c))
+#define CHAR_ASCII_P(ch) ((ch) <= 0x7F)
 
 /* The bit fields of character are divided into 3 parts:
    FIELD1(5bits):FIELD2(7bits):FIELD3(7bits) */