Mercurial > emacs
comparison src/charset.h @ 20932:3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
(DEC_POS): Make the behaviour consistent with INC_POS.
(BUF_INC_POS, BUF_DEC_POS): Likewise.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 20 Feb 1998 01:40:47 +0000 |
parents | 79d73f468e38 |
children | 9f32198e0d9f |
comparison
equal
deleted
inserted
replaced
20931:068eb408c911 | 20932:3c2c8431c51d |
---|---|
626 range checking of POS. */ | 626 range checking of POS. */ |
627 #define INC_POS(pos) \ | 627 #define INC_POS(pos) \ |
628 do { \ | 628 do { \ |
629 unsigned char *p = BYTE_POS_ADDR (pos); \ | 629 unsigned char *p = BYTE_POS_ADDR (pos); \ |
630 pos++; \ | 630 pos++; \ |
631 if (*p++ >= 0x80) \ | 631 if (BASE_LEADING_CODE_P (*p++)) \ |
632 while (!CHAR_HEAD_P (*p)) p++, pos++; \ | 632 while (!CHAR_HEAD_P (*p)) p++, pos++; \ |
633 } while (0) | 633 } while (0) |
634 | 634 |
635 /* Decrease the buffer point POS of the current buffer to the previous | 635 /* Decrease the buffer point POS of the current buffer to the previous |
636 character boundary. No range checking of POS. */ | 636 character boundary. No range checking of POS. */ |
637 #define DEC_POS(pos) \ | 637 #define DEC_POS(pos) \ |
638 do { \ | 638 do { \ |
639 unsigned char *p, *p_min; \ | 639 unsigned char *p, *p_min; \ |
640 int pos_saved = --pos; \ | 640 \ |
641 if (pos < GPT_BYTE) \ | 641 pos--; \ |
642 p = BEG_ADDR + pos - 1, p_min = BEG_ADDR; \ | 642 if (pos < GPT_BYTE) \ |
643 else \ | 643 p = BEG_ADDR + pos - 1, p_min = BEG_ADDR; \ |
644 else \ | |
644 p = BEG_ADDR + GAP_SIZE + pos - 1, p_min = GAP_END_ADDR; \ | 645 p = BEG_ADDR + GAP_SIZE + pos - 1, p_min = GAP_END_ADDR; \ |
645 while (p > p_min && !CHAR_HEAD_P (*p)) p--, pos--; \ | 646 if (p > p_min && !CHAR_HEAD_P (*p)) \ |
646 if (*p < 0x80 && pos != pos_saved) pos = pos_saved; \ | 647 { \ |
648 int pos_saved = pos--; \ | |
649 p--; \ | |
650 while (p > p_min && !CHAR_HEAD_P (*p)) p--, pos--; \ | |
651 if (!BASE_LEADING_CODE_P (*p)) pos = pos_saved; \ | |
652 } \ | |
647 } while (0) | 653 } while (0) |
648 | 654 |
649 /* Increment both CHARPOS and BYTEPOS, each in the appropriate way. */ | 655 /* Increment both CHARPOS and BYTEPOS, each in the appropriate way. */ |
650 | 656 |
651 #define INC_BOTH(charpos, bytepos) \ | 657 #define INC_BOTH(charpos, bytepos) \ |
674 | 680 |
675 /* Increase the buffer point POS of the current buffer to the next | 681 /* Increase the buffer point POS of the current buffer to the next |
676 character boundary. This macro relies on the fact that *GPT_ADDR | 682 character boundary. This macro relies on the fact that *GPT_ADDR |
677 and *Z_ADDR are always accessible and the values are '\0'. No | 683 and *Z_ADDR are always accessible and the values are '\0'. No |
678 range checking of POS. */ | 684 range checking of POS. */ |
679 #define BUF_INC_POS(buf, pos) \ | 685 #define BUF_INC_POS(buf, pos) \ |
680 do { \ | 686 do { \ |
681 unsigned char *p = BUF_BYTE_ADDRESS (buf, pos); \ | 687 unsigned char *p = BUF_BYTE_ADDRESS (buf, pos); \ |
682 pos++; \ | 688 pos++; \ |
683 if (*p++ >= 0x80) \ | 689 if (BASE_LEADING_CODE_P (*p++)) \ |
684 while (!CHAR_HEAD_P (*p)) p++, pos++; \ | 690 while (!CHAR_HEAD_P (*p)) p++, pos++; \ |
685 } while (0) | 691 } while (0) |
686 | 692 |
687 /* Decrease the buffer point POS of the current buffer to the previous | 693 /* Decrease the buffer point POS of the current buffer to the previous |
688 character boundary. No range checking of POS. */ | 694 character boundary. No range checking of POS. */ |
689 #define BUF_DEC_POS(buf, pos) \ | 695 #define BUF_DEC_POS(buf, pos) \ |
698 else \ | 704 else \ |
699 { \ | 705 { \ |
700 p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos - 1; \ | 706 p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos - 1; \ |
701 p_min = BUF_GAP_END_ADDR (buf); \ | 707 p_min = BUF_GAP_END_ADDR (buf); \ |
702 } \ | 708 } \ |
703 while (p > p_min && !CHAR_HEAD_P (*p)) p--, pos--; \ | 709 if (p > p_min && !CHAR_HEAD_P (*p)) \ |
704 if (*p < 0x80 && pos != pos_saved) pos = pos_saved; \ | 710 { \ |
711 int pos_saved = pos--; \ | |
712 p--; \ | |
713 while (p > p_min && !CHAR_HEAD_P (*p)) p--, pos--; \ | |
714 if (!BASE_LEADING_CODE_P (*p)) pos = pos_saved; \ | |
715 } \ | |
705 } while (0) | 716 } while (0) |
706 | 717 |
707 #endif /* emacs */ | 718 #endif /* emacs */ |
708 | 719 |
709 /* Maximum counts of components in one composite character. */ | 720 /* Maximum counts of components in one composite character. */ |
753 /* This is the maximum length of multi-byte form. */ | 764 /* This is the maximum length of multi-byte form. */ |
754 #define MAX_LENGTH_OF_MULTI_BYTE_FORM (MAX_COMPONENT_COUNT * 6) | 765 #define MAX_LENGTH_OF_MULTI_BYTE_FORM (MAX_COMPONENT_COUNT * 6) |
755 | 766 |
756 /* Maximum character code currently used. */ | 767 /* Maximum character code currently used. */ |
757 #define MAX_CHAR (MIN_CHAR_COMPOSITION + n_cmpchars) | 768 #define MAX_CHAR (MIN_CHAR_COMPOSITION + n_cmpchars) |
769 | |
770 extern void invalid_character P_ ((int)); | |
758 | 771 |
759 extern int unify_char P_ ((Lisp_Object, int, int, int, int)); | 772 extern int unify_char P_ ((Lisp_Object, int, int, int, int)); |
760 extern int split_non_ascii_string P_ ((unsigned char *, int, int *, | 773 extern int split_non_ascii_string P_ ((unsigned char *, int, int *, |
761 unsigned char *, unsigned char *)); | 774 unsigned char *, unsigned char *)); |
762 extern int string_to_non_ascii_char P_ ((unsigned char *, int, int *)); | 775 extern int string_to_non_ascii_char P_ ((unsigned char *, int, int *)); |