diff options
| author | Richard M. Stallman | 1997-12-31 21:49:31 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-12-31 21:49:31 +0000 |
| commit | c399b46133cc44fec697b4d124b10ee8b987d48c (patch) | |
| tree | f6c5a7e0202f5279b2a1b7fb9269bb30a5d4a1fe | |
| parent | a50545d958cc5a89fb35f5dfd86664e86104ee08 (diff) | |
| download | emacs-c399b46133cc44fec697b4d124b10ee8b987d48c.tar.gz emacs-c399b46133cc44fec697b4d124b10ee8b987d48c.zip | |
(CHAR_HEAD_P): Take char, not pointer, as arg.
(INC_POS, DEC_POS): Fix because arg is a bufpos.
(BUF_INC_POS, BUF_DEC_POS): New macros.
(INC_BOTH, DEC_BOTH): New macros.
| -rw-r--r-- | src/charset.h | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/src/charset.h b/src/charset.h index 2286e67e351..d2e500a83a7 100644 --- a/src/charset.h +++ b/src/charset.h | |||
| @@ -134,9 +134,9 @@ extern int charset_latin_jisx0201; /* JISX0201.Roman (Japanese Roman) */ | |||
| 134 | extern int charset_big5_1; /* Big5 Level 1 (Chinese Traditional) */ | 134 | extern int charset_big5_1; /* Big5 Level 1 (Chinese Traditional) */ |
| 135 | extern int charset_big5_2; /* Big5 Level 2 (Chinese Traditional) */ | 135 | extern int charset_big5_2; /* Big5 Level 2 (Chinese Traditional) */ |
| 136 | 136 | ||
| 137 | /* Check if STR points the head of multi-byte form, i.e. *STR is an | 137 | /* Check if CH is the head of multi-byte form, i.e., |
| 138 | ASCII character or a base leading-code. */ | 138 | an ASCII character or a base leading-code. */ |
| 139 | #define CHAR_HEAD_P(str) ((unsigned char) *(str) < 0xA0) | 139 | #define CHAR_HEAD_P(ch) ((unsigned char) (ch) < 0xA0) |
| 140 | 140 | ||
| 141 | /*** GENERAL NOTE on CHARACTER REPRESENTATION *** | 141 | /*** GENERAL NOTE on CHARACTER REPRESENTATION *** |
| 142 | 142 | ||
| @@ -599,10 +599,10 @@ extern int iso_charset_table[2][2][128]; | |||
| 599 | range checking of POS. */ | 599 | range checking of POS. */ |
| 600 | #define INC_POS(pos) \ | 600 | #define INC_POS(pos) \ |
| 601 | do { \ | 601 | do { \ |
| 602 | unsigned char *p = POS_ADDR (pos); \ | 602 | unsigned char *p = BYTE_POS_ADDR (pos); \ |
| 603 | pos++; \ | 603 | pos++; \ |
| 604 | if (*p++ >= 0x80) \ | 604 | if (*p++ >= 0x80) \ |
| 605 | while (!CHAR_HEAD_P (p)) p++, pos++; \ | 605 | while (!CHAR_HEAD_P (*p)) p++, pos++; \ |
| 606 | } while (0) | 606 | } while (0) |
| 607 | 607 | ||
| 608 | /* Decrease the buffer point POS of the current buffer to the previous | 608 | /* Decrease the buffer point POS of the current buffer to the previous |
| @@ -611,11 +611,63 @@ extern int iso_charset_table[2][2][128]; | |||
| 611 | do { \ | 611 | do { \ |
| 612 | unsigned char *p, *p_min; \ | 612 | unsigned char *p, *p_min; \ |
| 613 | int pos_saved = --pos; \ | 613 | int pos_saved = --pos; \ |
| 614 | if (pos < GPT) \ | 614 | if (pos < GPT_BYTE) \ |
| 615 | p = BEG_ADDR + pos - 1, p_min = BEG_ADDR; \ | 615 | p = BEG_ADDR + pos - 1, p_min = BEG_ADDR; \ |
| 616 | else \ | 616 | else \ |
| 617 | p = BEG_ADDR + GAP_SIZE + pos - 1, p_min = GAP_END_ADDR; \ | 617 | p = BEG_ADDR + GAP_SIZE + pos - 1, p_min = GAP_END_ADDR; \ |
| 618 | while (p > p_min && !CHAR_HEAD_P (p)) p--, pos--; \ | 618 | while (p > p_min && !CHAR_HEAD_P (*p)) p--, pos--; \ |
| 619 | if (*p < 0x80 && pos != pos_saved) pos = pos_saved; \ | ||
| 620 | } while (0) | ||
| 621 | |||
| 622 | /* Increment both CHARPOS and BYTEPOS, each in the appropriate way. */ | ||
| 623 | |||
| 624 | #define INC_BOTH(charpos, bytepos) \ | ||
| 625 | do \ | ||
| 626 | { \ | ||
| 627 | (charpos)++; \ | ||
| 628 | INC_POS ((bytepos)); \ | ||
| 629 | } \ | ||
| 630 | while (0) | ||
| 631 | |||
| 632 | /* Decrement both CHARPOS and BYTEPOS, each in the appropriate way. */ | ||
| 633 | |||
| 634 | #define DEC_BOTH(charpos, bytepos) \ | ||
| 635 | do \ | ||
| 636 | { \ | ||
| 637 | (charpos)--; \ | ||
| 638 | DEC_POS ((bytepos)); \ | ||
| 639 | } \ | ||
| 640 | while (0) | ||
| 641 | |||
| 642 | /* Increase the buffer point POS of the current buffer to the next | ||
| 643 | character boundary. This macro relies on the fact that *GPT_ADDR | ||
| 644 | and *Z_ADDR are always accessible and the values are '\0'. No | ||
| 645 | range checking of POS. */ | ||
| 646 | #define BUF_INC_POS(buf, pos) \ | ||
| 647 | do { \ | ||
| 648 | unsigned char *p = BUF_BYTE_ADDRESS (buf, pos); \ | ||
| 649 | pos++; \ | ||
| 650 | if (*p++ >= 0x80) \ | ||
| 651 | while (!CHAR_HEAD_P (*p)) p++, pos++; \ | ||
| 652 | } while (0) | ||
| 653 | |||
| 654 | /* Decrease the buffer point POS of the current buffer to the previous | ||
| 655 | character boundary. No range checking of POS. */ | ||
| 656 | #define BUF_DEC_POS(buf, pos) \ | ||
| 657 | do { \ | ||
| 658 | unsigned char *p, *p_min; \ | ||
| 659 | int pos_saved = --pos; \ | ||
| 660 | if (pos < BUF_GPT_BYTE (buf)) \ | ||
| 661 | { \ | ||
| 662 | p = BUF_BEG_ADDR (buf) + pos - 1; \ | ||
| 663 | p_min = BUF_BEG_ADDR (buf); \ | ||
| 664 | } \ | ||
| 665 | else \ | ||
| 666 | { \ | ||
| 667 | p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos - 1; \ | ||
| 668 | p_min = BUF_GAP_END_ADDR (buf); \ | ||
| 669 | } \ | ||
| 670 | while (p > p_min && !CHAR_HEAD_P (*p)) p--, pos--; \ | ||
| 619 | if (*p < 0x80 && pos != pos_saved) pos = pos_saved; \ | 671 | if (*p < 0x80 && pos != pos_saved) pos = pos_saved; \ |
| 620 | } while (0) | 672 | } while (0) |
| 621 | 673 | ||