-#define MAKE_CHAR(charset, c1, c2) \
- ((charset) == CHARSET_ASCII \
- ? (c1) \
- : MAKE_NON_ASCII_CHAR ((charset), (c1) & 0x7F, (c2) & 0x7F))
-
-/* 1 if C is in the range of possible character code Emacs can have. */
-#define VALID_CHAR_P(c) \
- ((c) >= 0 \
- && (SINGLE_BYTE_CHAR_P (c) \
- || ((c) < MIN_CHAR_COMPOSITION \
- ? ((c) & CHAR_FIELD1_MASK \
- ? (CHAR_FIELD2 (c) >= 32 && CHAR_FIELD3 (c) >= 32) \
- : (CHAR_FIELD2 (c) >= 16 && CHAR_FIELD3 (c) >= 32)) \
- : (c) < MIN_CHAR_COMPOSITION + n_cmpchars)))
-
-/* The charset of non-ASCII character C is set to CHARSET, and the
- position-codes of C are set to C1 and C2. C2 of DIMENSION1 character
- is -1. */
-#define SPLIT_NON_ASCII_CHAR(c, charset, c1, c2) \
- ((c) < MIN_CHAR_OFFICIAL_DIMENSION2 \
- ? (charset = CHAR_FIELD2 (c) + 0x70, \
- c1 = CHAR_FIELD3 (c), \
- c2 = -1) \
- : (charset = ((c) < MIN_CHAR_COMPOSITION \
- ? (CHAR_FIELD1 (c) \
- + ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)) \
- : CHARSET_COMPOSITION), \
- c1 = CHAR_FIELD2 (c), \
- c2 = CHAR_FIELD3 (c)))
-
-/* The charset of character C is set to CHARSET, and the
- position-codes of C are set to C1 and C2. C2 of DIMENSION1 character
- is -1. */
-#define SPLIT_CHAR(c, charset, c1, c2) \
- (SINGLE_BYTE_CHAR_P (c) \
- ? charset = CHARSET_ASCII, c1 = (c), c2 = -1 \
- : SPLIT_NON_ASCII_CHAR (c, charset, c1, c2))
-
-/* The charset of the character at STR is set to CHARSET, and the
- position-codes are set to C1 and C2. C2 of DIMENSION1 character is -1.
- If the character is a composite character, the upper 7-bit and
- lower 7-bit of CMPCHAR-ID are set in C1 and C2 respectively. No
- range checking. */
-#define SPLIT_STRING(str, len, charset, c1, c2) \
- ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) < 2 \
- || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > len \
- || split_non_ascii_string (str, len, &charset, &c1, &c2, 0) < 0) \
- ? c1 = *(str), charset = CHARSET_ASCII \
+#define MAKE_CHAR(charset, c1, c2) \
+ ((charset) == CHARSET_ASCII \
+ ? (c1) & 0x7F \
+ : (((charset) == CHARSET_8_BIT_CONTROL \
+ || (charset) == CHARSET_8_BIT_GRAPHIC) \
+ ? ((c1) & 0x7F) | 0x80 \
+ : ((CHARSET_DEFINED_P (charset) \
+ ? CHARSET_DIMENSION (charset) == 1 \
+ : (charset) < MIN_CHARSET_PRIVATE_DIMENSION2) \
+ ? (((charset) - 0x70) << 7) | ((c1) <= 0 ? 0 : ((c1) & 0x7F)) \
+ : ((((charset) \
+ - ((charset) < MIN_CHARSET_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)) \
+ << 14) \
+ | ((c2) <= 0 ? 0 : ((c2) & 0x7F)) \
+ | ((c1) <= 0 ? 0 : (((c1) & 0x7F) << 7))))))
+
+
+/* If GENERICP is nonzero, return nonzero iff C is a valid normal or
+ generic character. If GENERICP is zero, return nonzero iff C is a
+ valid normal character. */
+#define CHAR_VALID_P(c, genericp) \
+ ((c) >= 0 \
+ && (SINGLE_BYTE_CHAR_P (c) || char_valid_p (c, genericp)))
+
+/* This default value is used when nonascii-translation-table or
+ nonascii-insert-offset fail to convert unibyte character to a valid
+ multibyte character. This makes a Latin-1 character. */
+
+#define DEFAULT_NONASCII_INSERT_OFFSET 0x800
+
+/* Parse multibyte string STR of length LENGTH and set BYTES to the
+ byte length of a character at STR. */
+
+#ifdef BYTE_COMBINING_DEBUG
+
+#define PARSE_MULTIBYTE_SEQ(str, length, bytes) \
+ do { \
+ int i = 1; \
+ while (i < (length) && ! CHAR_HEAD_P ((str)[i])) i++; \
+ (bytes) = BYTES_BY_CHAR_HEAD ((str)[0]); \
+ if ((bytes) > i) \
+ abort (); \
+ } while (0)
+
+#else /* not BYTE_COMBINING_DEBUG */
+
+#define PARSE_MULTIBYTE_SEQ(str, length, bytes) \
+ (bytes) = BYTES_BY_CHAR_HEAD ((str)[0])
+
+#endif /* not BYTE_COMBINING_DEBUG */
+
+/* Return 1 iff the byte sequence at unibyte string STR (LENGTH bytes)
+ is valid as a multibyte form. If valid, by a side effect, BYTES is
+ set to the byte length of the multibyte form. */
+
+#define UNIBYTE_STR_AS_MULTIBYTE_P(str, length, bytes) \
+ (((str)[0] < 0x80 || (str)[0] >= 0xA0) \
+ ? ((bytes) = 1) \
+ : (((bytes) = BYTES_BY_CHAR_HEAD ((str)[0])), \
+ ((bytes) > 1 && (bytes) <= (length) \
+ && (str)[0] != LEADING_CODE_8_BIT_CONTROL \
+ && !CHAR_HEAD_P ((str)[1]) \
+ && ((bytes) == 2 \
+ || (!CHAR_HEAD_P ((str)[2]) \
+ && ((bytes) == 3 \
+ || !CHAR_HEAD_P ((str)[3])))))))
+
+/* Return 1 iff the byte sequence at multibyte string STR is valid as
+ a unibyte form. By a side effect, BYTES is set to the byte length
+ of one character at STR. */
+
+#define MULTIBYTE_STR_AS_UNIBYTE_P(str, bytes) \
+ ((bytes) = BYTES_BY_CHAR_HEAD ((str)[0]), \
+ (str)[0] != LEADING_CODE_8_BIT_CONTROL)
+
+/* The charset of character C is stored in CHARSET, and the
+ position-codes of C are stored in C1 and C2.
+ We store -1 in C2 if the dimension of the charset is 1. */
+
+#define SPLIT_CHAR(c, charset, c1, c2) \
+ (SINGLE_BYTE_CHAR_P (c) \
+ ? ((charset \
+ = (ASCII_BYTE_P (c) \
+ ? CHARSET_ASCII \
+ : ((c) < 0xA0 ? CHARSET_8_BIT_CONTROL : CHARSET_8_BIT_GRAPHIC))), \
+ c1 = (c), c2 = -1) \
+ : ((c) & CHAR_FIELD1_MASK \
+ ? (charset = (CHAR_FIELD1 (c) \
+ + ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)), \
+ c1 = CHAR_FIELD2 (c), \
+ c2 = CHAR_FIELD3 (c)) \
+ : (charset = CHAR_FIELD2 (c) + 0x70, \
+ c1 = CHAR_FIELD3 (c), \
+ c2 = -1)))
+
+/* Return 1 iff character C has valid printable glyph. */
+#define CHAR_PRINTABLE_P(c) (ASCII_BYTE_P (c) || char_printable_p (c))
+
+/* The charset of the character at STR is stored in CHARSET, and the
+ position-codes are stored in C1 and C2.
+ We store -1 in C2 if the character is just 2 bytes. */
+
+#define SPLIT_STRING(str, len, charset, c1, c2) \
+ ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) < 2 \
+ || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > len \
+ || split_string (str, len, &charset, &c1, &c2) < 0) \
+ ? c1 = *(str), charset = CHARSET_ASCII \