comparison src/charset.h @ 23653:67907ea2c6ac

(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid character correctly. (STRING_CHAR): Handle an invalid charater correctly.
author Kenichi Handa <handa@m17n.org>
date Fri, 06 Nov 1998 10:59:09 +0000
parents 06e645781762
children 0351c9791549
comparison
equal deleted inserted replaced
23652:42bf6553a2e9 23653:67907ea2c6ac
506 We store -1 in C2 if the character is just 2 bytes. 506 We store -1 in C2 if the character is just 2 bytes.
507 507
508 Do not use this macro for an ASCII character. */ 508 Do not use this macro for an ASCII character. */
509 509
510 #define SPLIT_NON_ASCII_CHAR(c, charset, c1, c2) \ 510 #define SPLIT_NON_ASCII_CHAR(c, charset, c1, c2) \
511 ((c) < MIN_CHAR_OFFICIAL_DIMENSION2 \ 511 ((c) & CHAR_FIELD1_MASK \
512 ? (charset = CHAR_FIELD2 (c) + 0x70, \ 512 ? (charset = ((c) < MIN_CHAR_COMPOSITION \
513 c1 = CHAR_FIELD3 (c), \
514 c2 = -1) \
515 : (charset = ((c) < MIN_CHAR_COMPOSITION \
516 ? (CHAR_FIELD1 (c) \ 513 ? (CHAR_FIELD1 (c) \
517 + ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)) \ 514 + ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)) \
518 : CHARSET_COMPOSITION), \ 515 : CHARSET_COMPOSITION), \
519 c1 = CHAR_FIELD2 (c), \ 516 c1 = CHAR_FIELD2 (c), \
520 c2 = CHAR_FIELD3 (c))) 517 c2 = CHAR_FIELD3 (c)) \
518 : (charset = CHAR_FIELD2 (c) + 0x70, \
519 c1 = CHAR_FIELD3 (c), \
520 c2 = -1))
521 521
522 /* The charset of character C is stored in CHARSET, and the 522 /* The charset of character C is stored in CHARSET, and the
523 position-codes of C are stored in C1 and C2. 523 position-codes of C are stored in C1 and C2.
524 We store -1 in C2 if the character is just 2 bytes. */ 524 We store -1 in C2 if the character is just 2 bytes. */
525 525
574 574
575 /* Return a character code of the character of which multi-byte form 575 /* Return a character code of the character of which multi-byte form
576 is at STR and the length is LEN. If STR doesn't contain valid 576 is at STR and the length is LEN. If STR doesn't contain valid
577 multi-byte form, only the first byte in STR is returned. */ 577 multi-byte form, only the first byte in STR is returned. */
578 578
579 #define STRING_CHAR(str, len) \ 579 #define STRING_CHAR(str, len) \
580 ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \ 580 (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \
581 || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > (len)) \ 581 ? (unsigned char) *(str) \
582 ? (unsigned char) *(str) \
583 : string_to_non_ascii_char (str, len, 0, 0)) 582 : string_to_non_ascii_char (str, len, 0, 0))
584 583
585 /* This is like STRING_CHAR but the third arg ACTUAL_LEN is set to 584 /* This is like STRING_CHAR but the third arg ACTUAL_LEN is set to
586 the length of the multi-byte form. Just to know the length, use 585 the length of the multi-byte form. Just to know the length, use
587 MULTIBYTE_FORM_LENGTH. */ 586 MULTIBYTE_FORM_LENGTH. */