diff options
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/charset.h | 30 |
2 files changed, 24 insertions, 11 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 34f81336e6d..1ceb2ec3134 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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 diff --git a/src/charset.h b/src/charset.h index 97b9801464e..fd8905e47d8 100644 --- a/src/charset.h +++ b/src/charset.h @@ -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 |