(VALID_LEADING_CODE_P): New macro.

(UNIBYTE_STR_AS_MULTIBYTE_P): Check more rigidly.
This commit is contained in:
Kenichi Handa 2003-05-31 00:11:28 +00:00
parent a2f3f87b0b
commit 1efcd78f5e
2 changed files with 24 additions and 11 deletions

View file

@ -1,3 +1,8 @@
2003-05-31 Kenichi Handa <handa@m17n.org>
* charset.h (VALID_LEADING_CODE_P): New macro.
(UNIBYTE_STR_AS_MULTIBYTE_P): Check more rigidly.
2003-05-30 Kenichi Handa <handa@m17n.org>
* coding.c (ccl_coding_driver): Set ccl->eight_bit_control

View file

@ -441,21 +441,29 @@ extern int width_by_char_head[256];
#endif /* not BYTE_COMBINING_DEBUG */
#define VALID_LEADING_CODE_P(code) \
(! NILP (CHARSET_TABLE_ENTRY (code)))
/* 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])))))))
#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) <= (length) \
&& !CHAR_HEAD_P ((str)[1]) \
&& ((bytes) == 2 \
? (str)[0] != LEADING_CODE_8_BIT_CONTROL \
: (!CHAR_HEAD_P ((str)[2]) \
&& ((bytes) == 3 \
? (((str)[0] != LEADING_CODE_PRIVATE_11 \
&& (str)[0] != LEADING_CODE_PRIVATE_12) \
|| VALID_LEADING_CODE_P (str[1])) \
: (!CHAR_HEAD_P ((str)[3]) \
&& VALID_LEADING_CODE_P (str[1]))))))))
/* 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