Mercurial > emacs
comparison src/charset.h @ 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 | 37a13dfcd8c2 |
children | 695cf19ef79e |
comparison
equal
deleted
inserted
replaced
51350:d555ff64edde | 51351:32900e49a097 |
---|---|
439 #define PARSE_MULTIBYTE_SEQ(str, length, bytes) \ | 439 #define PARSE_MULTIBYTE_SEQ(str, length, bytes) \ |
440 ((void)(length), (bytes) = BYTES_BY_CHAR_HEAD ((str)[0])) | 440 ((void)(length), (bytes) = BYTES_BY_CHAR_HEAD ((str)[0])) |
441 | 441 |
442 #endif /* not BYTE_COMBINING_DEBUG */ | 442 #endif /* not BYTE_COMBINING_DEBUG */ |
443 | 443 |
444 #define VALID_LEADING_CODE_P(code) \ | |
445 (! NILP (CHARSET_TABLE_ENTRY (code))) | |
446 | |
444 /* Return 1 iff the byte sequence at unibyte string STR (LENGTH bytes) | 447 /* Return 1 iff the byte sequence at unibyte string STR (LENGTH bytes) |
445 is valid as a multibyte form. If valid, by a side effect, BYTES is | 448 is valid as a multibyte form. If valid, by a side effect, BYTES is |
446 set to the byte length of the multibyte form. */ | 449 set to the byte length of the multibyte form. */ |
447 | 450 |
448 #define UNIBYTE_STR_AS_MULTIBYTE_P(str, length, bytes) \ | 451 #define UNIBYTE_STR_AS_MULTIBYTE_P(str, length, bytes) \ |
449 (((str)[0] < 0x80 || (str)[0] >= 0xA0) \ | 452 (((str)[0] < 0x80 || (str)[0] >= 0xA0) \ |
450 ? ((bytes) = 1) \ | 453 ? ((bytes) = 1) \ |
451 : (((bytes) = BYTES_BY_CHAR_HEAD ((str)[0])), \ | 454 : (((bytes) = BYTES_BY_CHAR_HEAD ((str)[0])), \ |
452 ((bytes) > 1 && (bytes) <= (length) \ | 455 ((bytes) <= (length) \ |
453 && (str)[0] != LEADING_CODE_8_BIT_CONTROL \ | 456 && !CHAR_HEAD_P ((str)[1]) \ |
454 && !CHAR_HEAD_P ((str)[1]) \ | 457 && ((bytes) == 2 \ |
455 && ((bytes) == 2 \ | 458 ? (str)[0] != LEADING_CODE_8_BIT_CONTROL \ |
456 || (!CHAR_HEAD_P ((str)[2]) \ | 459 : (!CHAR_HEAD_P ((str)[2]) \ |
457 && ((bytes) == 3 \ | 460 && ((bytes) == 3 \ |
458 || !CHAR_HEAD_P ((str)[3]))))))) | 461 ? (((str)[0] != LEADING_CODE_PRIVATE_11 \ |
462 && (str)[0] != LEADING_CODE_PRIVATE_12) \ | |
463 || VALID_LEADING_CODE_P (str[1])) \ | |
464 : (!CHAR_HEAD_P ((str)[3]) \ | |
465 && VALID_LEADING_CODE_P (str[1])))))))) | |
466 | |
459 | 467 |
460 /* Return 1 iff the byte sequence at multibyte string STR is valid as | 468 /* Return 1 iff the byte sequence at multibyte string STR is valid as |
461 a unibyte form. By a side effect, BYTES is set to the byte length | 469 a unibyte form. By a side effect, BYTES is set to the byte length |
462 of one character at STR. */ | 470 of one character at STR. */ |
463 | 471 |