Mercurial > emacs
changeset 51351:32900e49a097
(VALID_LEADING_CODE_P): New macro.
(UNIBYTE_STR_AS_MULTIBYTE_P): Check more rigidly.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sat, 31 May 2003 00:10:46 +0000 |
parents | d555ff64edde |
children | a53ff6272121 |
files | src/charset.h |
diffstat | 1 files changed, 19 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/charset.h Fri May 30 23:40:13 2003 +0000 +++ b/src/charset.h Sat May 31 00:10:46 2003 +0000 @@ -441,21 +441,29 @@ #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