(LEADING_BYTE_*): Delete definition for non-UTF-2000.
authortomo <tomo>
Mon, 30 Aug 1999 17:28:20 +0000 (17:28 +0000)
committertomo <tomo>
Mon, 30 Aug 1999 17:28:20 +0000 (17:28 +0000)
(LEADING_BYTE_PRIVATE_P): Deleted unconditionally.
(LEADING_BYTE_PREFIX_P): Deleted.
(PRIVATE_LEADING_BYTE_PREFIX): Deleted.
(BUFBYTE_FIRST_BYTE_P): Delete definition for non-UTF-2000.
(BUFBYTE_LEADING_BYTE_P): Deleted.
(CHARSET_PRIVATE_P): Deleted unconditionally.
(rep_bytes_by_first_byte): Deleted unconditionally.
(REP_BYTES_BY_FIRST_BYTE): Delete definition for non-UTF-2000.
(FIELD1_TO_PRIVATE_LEADING_BYTE): Likewise.
(FIELD1_TO_OFFICIAL_LEADING_BYTE): Likewise.
(FIELD2_TO_PRIVATE_LEADING_BYTE): Likewise.
(CHAR_FIELD2): Deleted.
(CHAR_FIELD3): Deleted.
(MAKE_CHAR): Delete definition for non-UTF-2000.
(BREAKUP_CHAR_1_UNSAFE): Deleted.
(breakup_char_1): New implementation.
(CHAR_CHARSET): Use `BREAKUP_CHAR'.
(CHAR_LEADING_BYTE): Use `CHAR_CHARSET'.

src/character.h

index e9e09c7..db8df92 100644 (file)
@@ -39,8 +39,6 @@ Boston, MA 02111-1307, USA.  */
 
 /** The following are for 1-byte characters in an official charset. **/
 
-#ifdef UTF2000
-
 #define LEADING_BYTE_LATIN_ISO8859_1   0x81 /* Right half of ISO 8859-1 */
 #define LEADING_BYTE_LATIN_ISO8859_2   0x82 /* Right half of ISO 8859-2 */
 #define LEADING_BYTE_LATIN_ISO8859_3   0x83 /* Right half of ISO 8859-3 */
@@ -90,91 +88,10 @@ Boston, MA 02111-1307, USA.  */
 #define MIN_LEADING_BYTE_PRIVATE_1     0x0D0
 #define MAX_LEADING_BYTE_PRIVATE_1     0x11f
 
-#else
-
-#define LEADING_BYTE_LATIN_ISO8859_1   0x81 /* Right half of ISO 8859-1 */
-#define LEADING_BYTE_LATIN_ISO8859_2   0x82 /* Right half of ISO 8859-2 */
-#define LEADING_BYTE_LATIN_ISO8859_3   0x83 /* Right half of ISO 8859-3 */
-#define LEADING_BYTE_LATIN_ISO8859_4   0x84 /* Right half of ISO 8859-4 */
-#define LEADING_BYTE_THAI_TIS620       0x85 /* TIS620-2533 */
-#define LEADING_BYTE_GREEK_ISO8859_7   0x86 /* Right half of ISO 8859-7 */
-#define LEADING_BYTE_ARABIC_ISO8859_6  0x87 /* Right half of ISO 8859-6 */
-#define LEADING_BYTE_HEBREW_ISO8859_8  0x88 /* Right half of ISO 8859-8 */
-#define LEADING_BYTE_KATAKANA_JISX0201 0x89 /* Right half of JIS X0201-1976 */
-#define LEADING_BYTE_LATIN_JISX0201    0x8A /* Left  half of JIS X0201-1976 */
-#define LEADING_BYTE_CYRILLIC_ISO8859_5        0x8C /* Right half of ISO 8859-5 */
-#define LEADING_BYTE_LATIN_ISO8859_9   0x8D /* Right half of ISO 8859-9 */
-
-#define MIN_LEADING_BYTE_OFFICIAL_1    LEADING_BYTE_LATIN_ISO8859_1
-#define MAX_LEADING_BYTE_OFFICIAL_1    LEADING_BYTE_LATIN_ISO8859_9
-
-/** The following are for 2-byte characters in an official charset. **/
-
-#define LEADING_BYTE_JAPANESE_JISX0208_1978 0x90/* Japanese JIS X0208-1978 */
-#define LEADING_BYTE_CHINESE_GB2312    0x91    /* Chinese Hanzi GB2312-1980 */
-#define LEADING_BYTE_JAPANESE_JISX0208 0x92    /* Japanese JIS X0208-1983 */
-#define LEADING_BYTE_KOREAN_KSC5601    0x93    /* Hangul KS C5601-1987 */
-#define LEADING_BYTE_JAPANESE_JISX0212 0x94    /* Japanese JIS X0212-1990 */
-#define LEADING_BYTE_CHINESE_CCITT_GB  0x95    /* CCITT Extended GB */
-#define LEADING_BYTE_CHINESE_BIG5_1    0x96    /* Big5 Level 1 */
-#define LEADING_BYTE_CHINESE_CNS11643_1        0x97    /* Chinese CNS11643 Set 1 */
-#define LEADING_BYTE_CHINESE_CNS11643_2        0x98    /* Chinese CNS11643 Set 2 */
-#define LEADING_BYTE_CHINESE_CNS11643_3        0x99    /* Chinese CNS11643 Set 3 */
-#define LEADING_BYTE_CHINESE_CNS11643_4        0x9A    /* Chinese CNS11643 Set 4 */
-#define LEADING_BYTE_CHINESE_CNS11643_5        0x9B    /* Chinese CNS11643 Set 5 */
-#define LEADING_BYTE_CHINESE_CNS11643_6        0x9C    /* Chinese CNS11643 Set 6 */
-#define LEADING_BYTE_CHINESE_CNS11643_7        0x9D    /* Chinese CNS11643 Set 7 */
-#define LEADING_BYTE_CHINESE_BIG5_2    0x9D    /* Big5 Level 2 */
-#define LEADING_BYTE_KOREAN_KPS9566    0x9E    /* DPRK Hangul KPS 9566-1997 */
-
-#define MIN_LEADING_BYTE_OFFICIAL_2    LEADING_BYTE_JAPANESE_JISX0208_1978
-#define MAX_LEADING_BYTE_OFFICIAL_2    LEADING_BYTE_CHINESE_BIG5_2
-
-/** The following are for 1- and 2-byte characters in a private charset. **/
-
-#define PRE_LEADING_BYTE_PRIVATE_1     0x9E    /* 1-byte char-set */
-#define PRE_LEADING_BYTE_PRIVATE_2     0x9F    /* 2-byte char-set */
-
-#define MIN_LEADING_BYTE_PRIVATE_1     0xA0
-#define MAX_LEADING_BYTE_PRIVATE_1     0xEF
-#define MIN_LEADING_BYTE_PRIVATE_2     0xF0
-#define MAX_LEADING_BYTE_PRIVATE_2     0xFF
-
-#endif
-
 #define NUM_LEADING_BYTES 256
 
 \f
 /************************************************************************/
-/*                    Operations on leading bytes                       */
-/************************************************************************/
-
-/* Is this leading byte for a private charset? */
-
-#ifndef UTF2000
-#define LEADING_BYTE_PRIVATE_P(lb) ((lb) >= MIN_LEADING_BYTE_PRIVATE_1)
-#endif
-
-/* Is this a prefix for a private leading byte? */
-
-INLINE int LEADING_BYTE_PREFIX_P (unsigned char lb);
-INLINE int
-LEADING_BYTE_PREFIX_P (unsigned char lb)
-{
-  return (lb == PRE_LEADING_BYTE_PRIVATE_1 ||
-         lb == PRE_LEADING_BYTE_PRIVATE_2);
-}
-
-/* Given a private leading byte, return the leading byte prefix stored
-   in a string */
-
-#define PRIVATE_LEADING_BYTE_PREFIX(lb)        \
-  ((lb) < MIN_LEADING_BYTE_PRIVATE_2 ? \
-   PRE_LEADING_BYTE_PRIVATE_1 :                \
-   PRE_LEADING_BYTE_PRIVATE_2)
-
-\f
-/************************************************************************/
 /*                     Operations on individual bytes                   */
 /*                             of any format                            */
 /************************************************************************/
@@ -195,19 +112,11 @@ LEADING_BYTE_PREFIX_P (unsigned char lb)
 
 /* Does this byte represent the first byte of a character? */
 
-#ifdef UTF2000
 INLINE int
 BUFBYTE_FIRST_BYTE_P(Bufbyte c)
 {
   return (c <= 0x7f) || (0xc0 <= c);
 }
-#else
-#define BUFBYTE_FIRST_BYTE_P(c) ((c) < 0xA0)
-#endif
-
-/* Does this byte represent the first byte of a multi-byte character? */
-
-#define BUFBYTE_LEADING_BYTE_P(c) BYTE_C1_P (c)
 
 \f
 /************************************************************************/
@@ -290,10 +199,6 @@ DECLARE_LRECORD (charset, struct Lisp_Charset);
 #define CHARSET_REVERSE_DIRECTION_CHARSET(cs) ((cs)->reverse_direction_charset)
 
 
-#ifdef LEADING_BYTE_PRIVATE_P
-#define CHARSET_PRIVATE_P(cs) LEADING_BYTE_PRIVATE_P (CHARSET_LEADING_BYTE (cs))
-#endif
-
 #define XCHARSET_ID(cs)                  CHARSET_ID           (XCHARSET (cs))
 #define XCHARSET_NAME(cs)        CHARSET_NAME         (XCHARSET (cs))
 #define XCHARSET_SHORT_NAME(cs)          CHARSET_SHORT_NAME   (XCHARSET (cs))
@@ -322,19 +227,6 @@ extern Lisp_Object charset_by_leading_byte[NUM_LEADING_BYTES];
 /* Table of charsets indexed by type/final-byte/direction. */
 extern Lisp_Object charset_by_attributes[4][128][2];
 
-#ifndef UTF2000
-/* 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];
-#endif
-
 #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
@@ -358,7 +250,6 @@ CHARSET_BY_LEADING_BYTE (int lb)
 #define CHARSET_BY_ATTRIBUTES(type, final, dir) \
   (charset_by_attributes[type][final][dir])
 
-#ifdef UTF2000
 INLINE int REP_BYTES_BY_FIRST_BYTE (int fb);
 INLINE int
 REP_BYTES_BY_FIRST_BYTE (int fb)
@@ -376,22 +267,6 @@ REP_BYTES_BY_FIRST_BYTE (int fb)
   else
     return 6;
 }
-#else /* MULE */
-#ifdef ERROR_CHECK_TYPECHECK
-
-/* 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);
-  return rep_bytes_by_first_byte[fb];
-}
-
-#else
-#define REP_BYTES_BY_FIRST_BYTE(fb) (rep_bytes_by_first_byte[fb])
-#endif
-#endif /* end MULE */
 
 \f
 /************************************************************************/
@@ -438,62 +313,10 @@ REP_BYTES_BY_FIRST_BYTE (int fb)
 
 /* Converting between field values and leading bytes.  */
 
-#define FIELD2_TO_OFFICIAL_LEADING_BYTE 0x80
-
-#ifdef UTF2000
-
 #define FIELD1_TO_PRIVATE_LEADING_BYTE  0x80
 #define FIELD1_TO_OFFICIAL_LEADING_BYTE 0x80
 #define FIELD2_TO_PRIVATE_LEADING_BYTE  0xb0
-
-#else
-
-#define FIELD1_TO_PRIVATE_LEADING_BYTE  0xc0
-#define FIELD1_TO_OFFICIAL_LEADING_BYTE 0x50
-#define FIELD2_TO_PRIVATE_LEADING_BYTE  0x80
-
-#endif
-
-INLINE Emchar
-CHAR_FIELD2 (Emchar c)
-{
-  if( (MIN_CHAR_GREEK <= c) && (c <= MAX_CHAR_GREEK) )
-    return LEADING_BYTE_GREEK_ISO8859_7
-      - FIELD2_TO_OFFICIAL_LEADING_BYTE;
-  else if( (MIN_CHAR_CYRILLIC <= c) && (c <= MAX_CHAR_CYRILLIC) )
-    return LEADING_BYTE_CYRILLIC_ISO8859_5
-      - FIELD2_TO_OFFICIAL_LEADING_BYTE;
-  else if( (MIN_CHAR_HEBREW <= c) && (c <= MAX_CHAR_HEBREW) )
-    return LEADING_BYTE_HEBREW_ISO8859_8
-      - FIELD2_TO_OFFICIAL_LEADING_BYTE;
-  else if( (MIN_CHAR_THAI <= c) && (c <= MAX_CHAR_THAI) )
-    return LEADING_BYTE_THAI_TIS620
-      - FIELD2_TO_OFFICIAL_LEADING_BYTE;
-  else if( (MIN_CHAR_HALFWIDTH_KATAKANA <= c)
-          && (c <= MAX_CHAR_HALFWIDTH_KATAKANA) )
-    return LEADING_BYTE_KATAKANA_JISX0201
-      - FIELD2_TO_OFFICIAL_LEADING_BYTE;
-  else
-    return CHAR_FIELD2_INTERNAL(c);
-}
-
-INLINE Emchar
-CHAR_FIELD3 (Emchar c)
-{
-  if( (MIN_CHAR_GREEK <= c) && (c <= MAX_CHAR_GREEK) )
-    return c - MIN_CHAR_GREEK + 0x20;
-  else if( (MIN_CHAR_CYRILLIC <= c) && (c <= MAX_CHAR_CYRILLIC) )
-    return c - MIN_CHAR_CYRILLIC + 0x20;
-  else if( (MIN_CHAR_HEBREW <= c) && (c <= MAX_CHAR_HEBREW) )
-    return c - MIN_CHAR_HEBREW + 0x20;
-  else if( (MIN_CHAR_THAI <= c) && (c <= MAX_CHAR_THAI) )
-    return c - MIN_CHAR_THAI + 0x20;
-  else if( (MIN_CHAR_HALFWIDTH_KATAKANA <= c)
-          && (c <= MAX_CHAR_HALFWIDTH_KATAKANA) )
-    return c - MIN_CHAR_HALFWIDTH_KATAKANA + 0x20;
-  else
-    return CHAR_FIELD3_INTERNAL(c);
-}
+#define FIELD2_TO_OFFICIAL_LEADING_BYTE 0x80
 
 /* Minimum and maximum allowed values for the fields. */
 
@@ -532,52 +355,6 @@ CHAR_FIELD3 (Emchar c)
 #define MIN_CHAR_COMPOSITION \
   (MULE_CHAR_PRIVATE_OFFSET | (0x7f << 14))
 
-/* Leading byte of a character.
-
-   NOTE: This takes advantage of the fact that
-   FIELD2_TO_OFFICIAL_LEADING_BYTE and
-   FIELD2_TO_PRIVATE_LEADING_BYTE are the same.
-   */
-
-INLINE Bufbyte CHAR_LEADING_BYTE (Emchar c);
-INLINE Bufbyte
-CHAR_LEADING_BYTE (Emchar c)
-{
-  if (CHAR_ASCII_P (c))
-    return LEADING_BYTE_ASCII;
-  else if (c < 0xA0)
-    return LEADING_BYTE_CONTROL_1;
-  else if (c <= 0xff)
-    return LEADING_BYTE_LATIN_ISO8859_1;
-  else if (c <= MAX_CHAR_GREEK)
-    return LEADING_BYTE_GREEK_ISO8859_7;
-  else if (c <= MAX_CHAR_CYRILLIC)
-    return LEADING_BYTE_CYRILLIC_ISO8859_5;
-  else if (c <= MAX_CHAR_HEBREW)
-    return LEADING_BYTE_HEBREW_ISO8859_8;
-  else if (c <= MAX_CHAR_THAI)
-    return LEADING_BYTE_THAI_TIS620;
-  else if (c <= MAX_CHAR_HALFWIDTH_KATAKANA)
-    return LEADING_BYTE_KATAKANA_JISX0201;
-  else if (c < MIN_CHAR_PRIVATE_TYPE9NX9N)
-    return CHAR_FIELD2 (c) + FIELD2_TO_OFFICIAL_LEADING_BYTE;
-  else if (c < MIN_CHAR_OFFICIAL_TYPE9NX9N)
-    return CHAR_FIELD1 (c) + FIELD1_TO_PRIVATE_LEADING_BYTE;
-  else if (c < MIN_CHAR_COMPOSITION)
-    return CHAR_FIELD1 (c) + FIELD1_TO_OFFICIAL_LEADING_BYTE;
-  else
-    {
-#ifdef ENABLE_COMPOSITE_CHARS
-      return LEADING_BYTE_COMPOSITE;
-#else
-      abort();
-      return 0;
-#endif /* ENABLE_COMPOSITE_CHARS */
-    }
-}
-
-#define CHAR_CHARSET(c) CHARSET_BY_LEADING_BYTE (CHAR_LEADING_BYTE (c))
-
 /* Return a character whose charset is CHARSET and position-codes
    are C1 and C2.  TYPE9N character ignores C2.
 
@@ -617,49 +394,126 @@ MAKE_CHAR (Lisp_Object charset, int c1, int c2)
     return MULE_CHAR_PRIVATE_OFFSET
       | ((XCHARSET_LEADING_BYTE (charset) -
          FIELD2_TO_OFFICIAL_LEADING_BYTE) << 7) | (c1);
-#ifdef UTF2000
   else
     return MULE_CHAR_PRIVATE_OFFSET
       | ((XCHARSET_LEADING_BYTE (charset) -
          FIELD1_TO_PRIVATE_LEADING_BYTE) << 14) | ((c1) << 7) | (c2);
-#else
-  else if (!XCHARSET_PRIVATE_P (charset))
-    return MULE_CHAR_PRIVATE_OFFSET
-      | ((XCHARSET_LEADING_BYTE (charset) -
-         FIELD1_TO_OFFICIAL_LEADING_BYTE) << 14) | ((c1) << 7) | (c2);
-  else
-    return MULE_CHAR_PRIVATE_OFFSET
-      | ((XCHARSET_LEADING_BYTE (charset) -
-         FIELD1_TO_PRIVATE_LEADING_BYTE) << 14) | ((c1) << 7) | (c2);
-#endif
 }
 
-/* The charset of character C is set to CHARSET, and the
-   position-codes of C are set to C1 and C2.  C2 of TYPE9N character
-   is 0.  */
-
-/* BREAKUP_CHAR_1_UNSAFE assumes that the charset has already been
-   calculated, and just computes c1 and c2.
-
-   BREAKUP_CHAR also computes and stores the charset. */
-
-#define BREAKUP_CHAR_1_UNSAFE(c, charset, c1, c2)      \
-  XCHARSET_DIMENSION (charset) == 1                    \
-  ? ((c1) = CHAR_FIELD3 (c), (c2) = 0)                 \
-  : ((c1) = CHAR_FIELD2 (c),                           \
-     (c2) = CHAR_FIELD3 (c))
-
 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)
 {
-  *charset = CHAR_CHARSET (c);
-  BREAKUP_CHAR_1_UNSAFE (c, *charset, *c1, *c2);
+  if (CHAR_ASCII_P (c))
+    {
+      *charset = Vcharset_ascii;
+      *c1 = c;
+      *c2 = 0;
+    }
+  else if (c < 0xA0)
+    {
+      *charset = Vcharset_control_1;
+      *c1 = CHAR_FIELD3_INTERNAL (c);
+      *c2 = 0;
+    }
+  else if (c <= 0xff)
+    {
+      *charset = Vcharset_latin_iso8859_1;
+      *c1 = CHAR_FIELD3_INTERNAL (c);
+      *c2 = 0;
+    }
+  else if (c < MIN_CHAR_GREEK)
+    {
+      abort ();
+    }
+  else if (c <= MAX_CHAR_GREEK)
+    {
+      *charset = Vcharset_greek_iso8859_7;
+      *c1 = c - MIN_CHAR_GREEK + 0x20;
+      *c2 = 0;
+    }
+  else if (c < MIN_CHAR_CYRILLIC)
+    {
+      abort ();
+    }
+  else if (c <= MAX_CHAR_CYRILLIC)
+    {
+      *charset = Vcharset_cyrillic_iso8859_5;
+      *c1 = c - MIN_CHAR_CYRILLIC + 0x20;
+      *c2 = 0;
+    }
+  else if (c < MIN_CHAR_HEBREW)
+    {
+      abort ();
+    }
+  else if (c <= MAX_CHAR_HEBREW)
+    {
+      *charset = Vcharset_hebrew_iso8859_8;
+      *c1 = c - MIN_CHAR_HEBREW + 0x20;
+      *c2 = 0;
+    }
+  else if (c < MIN_CHAR_THAI)
+    {
+      abort ();
+    }
+  else if (c <= MAX_CHAR_THAI)
+    {
+      *charset = Vcharset_thai_tis620;
+      *c1 = c - MIN_CHAR_THAI + 0x20;
+      *c2 = 0;
+    }
+  else if (c < MIN_CHAR_HALFWIDTH_KATAKANA)
+    {
+      abort ();
+    }
+  else if (c <= MAX_CHAR_HALFWIDTH_KATAKANA)
+    {
+      *charset = Vcharset_katakana_jisx0201;
+      *c1 = c - MIN_CHAR_HALFWIDTH_KATAKANA + 0x20;
+      *c2 = 0;
+    }
+  else if (c < MIN_CHAR_PRIVATE_TYPE9NX9N)
+    {
+      *charset
+       = CHARSET_BY_LEADING_BYTE (CHAR_FIELD2_INTERNAL (c) +
+                                  FIELD2_TO_OFFICIAL_LEADING_BYTE);
+      *c1 = CHAR_FIELD3_INTERNAL(c);
+      *c2 = 0;
+    }
+  else if (c < MIN_CHAR_COMPOSITION)
+    {
+      *charset
+       = CHARSET_BY_LEADING_BYTE (CHAR_FIELD1 (c) +
+                                  FIELD1_TO_OFFICIAL_LEADING_BYTE);
+      *c1 = CHAR_FIELD2_INTERNAL(c);
+      *c2 = CHAR_FIELD3_INTERNAL(c);
+    }
+  else
+    {
+#ifdef ENABLE_COMPOSITE_CHARS
+      return LEADING_BYTE_COMPOSITE;
+#else
+      printf("u+%x", c);
+      abort();
+#endif /* ENABLE_COMPOSITE_CHARS */
+    }
 }
 
 #define BREAKUP_CHAR(c, charset, c1, c2) \
   breakup_char_1 (c, &(charset), &(c1), &(c2))
 
+INLINE Lisp_Object CHAR_CHARSET (Emchar c);
+INLINE Lisp_Object
+CHAR_CHARSET (Emchar c)
+{
+  Lisp_Object charset;
+  int c1, c2;
+
+  BREAKUP_CHAR(c, charset, c1, c2);
+  return charset;
+}
+
+#define CHAR_LEADING_BYTE(c) (XCHARSET_LEADING_BYTE(CHAR_CHARSET(c)))
 
 \f
 #ifdef ENABLE_COMPOSITE_CHARS