573 |
CHARIDX++; \ |
CHARIDX++; \ |
574 |
if (STRING_MULTIBYTE (STRING)) \ |
if (STRING_MULTIBYTE (STRING)) \ |
575 |
{ \ |
{ \ |
576 |
unsigned char *ptr = &XSTRING (STRING)->data[BYTEIDX]; \ |
const unsigned char *ptr = SDATA (STRING) + BYTEIDX; \ |
577 |
int space_left = XSTRING (STRING)->size_byte - BYTEIDX; \ |
int space_left = SBYTES (STRING) - BYTEIDX; \ |
578 |
int actual_len; \ |
int actual_len; \ |
579 |
\ |
\ |
580 |
OUTPUT = STRING_CHAR_AND_LENGTH (ptr, space_left, actual_len); \ |
OUTPUT = STRING_CHAR_AND_LENGTH (ptr, space_left, actual_len); \ |
581 |
BYTEIDX += actual_len; \ |
BYTEIDX += actual_len; \ |
582 |
} \ |
} \ |
583 |
else \ |
else \ |
584 |
OUTPUT = XSTRING (STRING)->data[BYTEIDX++]; \ |
OUTPUT = SREF (STRING, BYTEIDX++); \ |
585 |
} \ |
} \ |
586 |
else |
else |
587 |
|
|
590 |
#define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \ |
#define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \ |
591 |
if (1) \ |
if (1) \ |
592 |
{ \ |
{ \ |
593 |
unsigned char *fetch_string_char_ptr = &XSTRING (STRING)->data[BYTEIDX]; \ |
const unsigned char *fetch_string_char_ptr = SDATA (STRING) + BYTEIDX; \ |
594 |
int fetch_string_char_space_left = XSTRING (STRING)->size_byte - BYTEIDX; \ |
int fetch_string_char_space_left = SBYTES (STRING) - BYTEIDX; \ |
595 |
int actual_len; \ |
int actual_len; \ |
596 |
\ |
\ |
597 |
OUTPUT \ |
OUTPUT \ |
634 |
? 1 \ |
? 1 \ |
635 |
: multibyte_form_length (str, len)) |
: multibyte_form_length (str, len)) |
636 |
|
|
637 |
|
/* If P is before LIMIT, advance P to the next character boundary. It |
638 |
|
assumes that P is already at a character boundary of the sane |
639 |
|
mulitbyte form whose end address is LIMIT. */ |
640 |
|
|
641 |
|
#define NEXT_CHAR_BOUNDARY(p, limit) \ |
642 |
|
do { \ |
643 |
|
if ((p) < (limit)) \ |
644 |
|
(p) += BYTES_BY_CHAR_HEAD (*(p)); \ |
645 |
|
} while (0) |
646 |
|
|
647 |
|
|
648 |
|
/* If P is after LIMIT, advance P to the previous character boundary. |
649 |
|
It assumes that P is already at a character boundary of the sane |
650 |
|
mulitbyte form whose beginning address is LIMIT. */ |
651 |
|
|
652 |
|
#define PREV_CHAR_BOUNDARY(p, limit) \ |
653 |
|
do { \ |
654 |
|
if ((p) > (limit)) \ |
655 |
|
{ \ |
656 |
|
const unsigned char *p0 = (p); \ |
657 |
|
do { \ |
658 |
|
p0--; \ |
659 |
|
} while (p0 >= limit && ! CHAR_HEAD_P (*p0)); \ |
660 |
|
(p) = (BYTES_BY_CHAR_HEAD (*p0) == (p) - p0) ? p0 : (p) - 1; \ |
661 |
|
} \ |
662 |
|
} while (0) |
663 |
|
|
664 |
|
|
665 |
#ifdef emacs |
#ifdef emacs |
666 |
|
|
667 |
/* Increase the buffer byte position POS_BYTE of the current buffer to |
/* Increase the buffer byte position POS_BYTE of the current buffer to |
822 |
extern int string_to_char P_ ((const unsigned char *, int, int *)); |
extern int string_to_char P_ ((const unsigned char *, int, int *)); |
823 |
extern int char_printable_p P_ ((int c)); |
extern int char_printable_p P_ ((int c)); |
824 |
extern int multibyte_form_length P_ ((const unsigned char *, int)); |
extern int multibyte_form_length P_ ((const unsigned char *, int)); |
825 |
extern void parse_str_as_multibyte P_ ((unsigned char *, int, int *, int *)); |
extern void parse_str_as_multibyte P_ ((const unsigned char *, int, int *, |
826 |
|
int *)); |
827 |
extern int str_as_multibyte P_ ((unsigned char *, int, int, int *)); |
extern int str_as_multibyte P_ ((unsigned char *, int, int, int *)); |
828 |
extern int parse_str_to_multibyte P_ ((unsigned char *, int)); |
extern int parse_str_to_multibyte P_ ((unsigned char *, int)); |
829 |
extern int str_to_multibyte P_ ((unsigned char *, int, int)); |
extern int str_to_multibyte P_ ((unsigned char *, int, int)); |
830 |
extern int str_as_unibyte P_ ((unsigned char *, int)); |
extern int str_as_unibyte P_ ((unsigned char *, int)); |
831 |
extern int get_charset_id P_ ((Lisp_Object)); |
extern int get_charset_id P_ ((Lisp_Object)); |
832 |
extern int find_charset_in_text P_ ((unsigned char *, int, int, int *, |
extern int find_charset_in_text P_ ((const unsigned char *, int, int, int *, |
833 |
Lisp_Object)); |
Lisp_Object)); |
834 |
extern int strwidth P_ ((unsigned char *, int)); |
extern int strwidth P_ ((unsigned char *, int)); |
835 |
extern int c_string_width P_ ((unsigned char *, int, int, int *, int *)); |
extern int c_string_width P_ ((const unsigned char *, int, int, int *, int *)); |
836 |
extern int lisp_string_width P_ ((Lisp_Object, int, int *, int *)); |
extern int lisp_string_width P_ ((Lisp_Object, int, int *, int *)); |
837 |
extern int char_bytes P_ ((int)); |
extern int char_bytes P_ ((int)); |
838 |
extern int char_valid_p P_ ((int, int)); |
extern int char_valid_p P_ ((int, int)); |
839 |
|
|
840 |
|
EXFUN (Funibyte_char_to_multibyte, 1); |
841 |
|
|
842 |
extern Lisp_Object Vtranslation_table_vector; |
extern Lisp_Object Vtranslation_table_vector; |
843 |
|
|
844 |
/* Return a translation table of id number ID. */ |
/* Return a translation table of id number ID. */ |
856 |
#define BCOPY_SHORT(from, to, len) \ |
#define BCOPY_SHORT(from, to, len) \ |
857 |
do { \ |
do { \ |
858 |
int i = len; \ |
int i = len; \ |
859 |
unsigned char *from_p = from, *to_p = to; \ |
const unsigned char *from_p = from; \ |
860 |
|
unsigned char *to_p = to; \ |
861 |
while (i--) *to_p++ = *from_p++; \ |
while (i--) *to_p++ = *from_p++; \ |
862 |
} while (0) |
} while (0) |
863 |
|
|