-/* Parse a multibyte character string STR of length LENGTH (>= 2) set
- BYTES to the length of actual multibyte sequence, CHARSET, C1, and
- C2 to such values that MAKE_CHAR can make the multibyte character
- from them.
-
- It is assumed that *STR is one of base leading codes and the
- following (LENGTH - 1) bytes satisfy !CHAR_HEAD_P.
-
- This macro should be called only from SPLIT_MULTIBYTE_SEQ. */
-
-#define SPLIT_CHARACTER_SEQ(str, length, bytes, charset, c1, c2) \
- do { \
- (bytes) = 1; \
- (charset) = (str)[0]; \
- if ((charset) >= LEADING_CODE_PRIVATE_11 \
- && (charset) <= LEADING_CODE_PRIVATE_22) \
- (charset) = (str)[(bytes)++]; \
- if ((bytes) < (length)) \
- { \
- (c1) = (str)[(bytes)++] & 0x7F; \
- if ((bytes) < (length)) \
- (c2) = (str)[(bytes)++] & 0x7F; \
- else \
- (c2) = -1; \
- } \
- else \
- (c1) = (c2) = -1; \
- } while (0)
-
-/* Parse string STR of length LENGTH and check if a multibyte
- characters is at STR. Set BYTES to the actual length, CHARSET, C1,
- C2 to proper values for that character. */
-
-#define SPLIT_MULTIBYTE_SEQ(str, length, bytes, charset, c1, c2) \
- do { \
- int i; \
- if (ASCII_BYTE_P ((str)[0])) \
- i = 1; \
- else \
- for (i = 1; i < (length) && ! CHAR_HEAD_P ((str)[i]); i++); \
- if (i == 1) \
- (bytes) = 1, (charset) = CHARSET_ASCII, (c1) = (str)[0] ; \
- else \
- { \
- if (i > BYTES_BY_CHAR_HEAD ((str)[0])) \
- i = BYTES_BY_CHAR_HEAD ((str)[0]); \
- SPLIT_CHARACTER_SEQ (str, i, bytes, charset, c1, c2); \
- } \
+/* Parse string STR of length LENGTH and fetch information of a
+ character at STR. Set BYTES to the byte length the character
+ occupies, CHARSET, C1, C2 to proper values of the character. */
+
+#define SPLIT_MULTIBYTE_SEQ(str, length, bytes, charset, c1, c2) \
+ do { \
+ (c1) = *(str); \
+ (bytes) = BYTES_BY_CHAR_HEAD (c1); \
+ if ((bytes) == 1) \
+ (charset) = ASCII_BYTE_P (c1) ? CHARSET_ASCII : CHARSET_8_BIT_GRAPHIC; \
+ else if ((bytes) == 2) \
+ { \
+ if ((c1) == LEADING_CODE_8_BIT_CONTROL) \
+ (charset) = CHARSET_8_BIT_CONTROL, (c1) = (str)[1] - 0x20; \
+ else \
+ (charset) = (c1), (c1) = (str)[1] & 0x7F; \
+ } \
+ else if ((bytes) == 3) \
+ { \
+ if ((c1) < LEADING_CODE_PRIVATE_11) \
+ (charset) = (c1), (c1) = (str)[1] & 0x7F, (c2) = (str)[2] & 0x7F; \
+ else \
+ (charset) = (str)[1], (c1) = (str)[2] & 0x7F; \
+ } \
+ else \
+ (charset) = (str)[1], (c1) = (str)[2] & 0x7F, (c2) = (str)[3] & 0x7F; \