Mercurial > emacs
comparison src/charset.h @ 23202:750deb2c6c0b
(STRING_CHAR_AND_LENGTH): Return correct value in
ACTUAL_LEN even if LEN is too short to have a valid multibyte
form.
(STRING_CHAR_AND_CHAR_LENGTH): Likewise.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 07 Sep 1998 13:39:15 +0000 |
parents | f2cee3bcef78 |
children | 958ab288116d |
comparison
equal
deleted
inserted
replaced
23201:392b44751a22 | 23202:750deb2c6c0b |
---|---|
585 /* This is like STRING_CHAR but the third arg ACTUAL_LEN is set to | 585 /* 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 | 586 the length of the multi-byte form. Just to know the length, use |
587 MULTIBYTE_FORM_LENGTH. */ | 587 MULTIBYTE_FORM_LENGTH. */ |
588 | 588 |
589 #define STRING_CHAR_AND_LENGTH(str, len, actual_len) \ | 589 #define STRING_CHAR_AND_LENGTH(str, len, actual_len) \ |
590 ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \ | 590 (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \ |
591 || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > (len)) \ | |
592 ? (actual_len = 1), (unsigned char) *(str) \ | 591 ? (actual_len = 1), (unsigned char) *(str) \ |
593 : string_to_non_ascii_char (str, len, &actual_len, 0)) | 592 : string_to_non_ascii_char (str, len, &actual_len, 0)) |
594 | 593 |
595 /* This is like STRING_CHAR_AND_LENGTH but the third arg ACTUAL_LEN | 594 /* This is like STRING_CHAR_AND_LENGTH but the third arg ACTUAL_LEN |
596 does not include garbage bytes following the multibyte character. */ | 595 does not include garbage bytes following the multibyte character. */ |
597 #define STRING_CHAR_AND_CHAR_LENGTH(str, len, actual_len) \ | 596 #define STRING_CHAR_AND_CHAR_LENGTH(str, len, actual_len) \ |
598 ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \ | 597 (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \ |
599 || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > (len)) \ | |
600 ? (actual_len = 1), (unsigned char) *(str) \ | 598 ? (actual_len = 1), (unsigned char) *(str) \ |
601 : string_to_non_ascii_char (str, len, &actual_len, 1)) | 599 : string_to_non_ascii_char (str, len, &actual_len, 1)) |
602 | 600 |
603 /* Fetch the "next" multibyte character from Lisp string STRING | 601 /* Fetch the "next" multibyte character from Lisp string STRING |
604 at byte position BYTEIDX, character position CHARIDX. | 602 at byte position BYTEIDX, character position CHARIDX. |