Mercurial > emacs
comparison src/charset.h @ 17120:c9c1bc92b8f8
(INC_POS, DEC_POS): Don't increase or decrease too
much if there's binary code (invalid character code).
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 27 Feb 1997 11:11:46 +0000 |
parents | 70194012fb3a |
children | 0d5a1bae9d73 |
comparison
equal
deleted
inserted
replaced
17119:2cfb31c15ced | 17120:c9c1bc92b8f8 |
---|---|
577 | 577 |
578 /* Increase the buffer point POS of the current buffer to the next | 578 /* Increase the buffer point POS of the current buffer to the next |
579 character boundary. This macro relies on the fact that *GPT_ADDR | 579 character boundary. This macro relies on the fact that *GPT_ADDR |
580 and *Z_ADDR are always accessible and the values are '\0'. No | 580 and *Z_ADDR are always accessible and the values are '\0'. No |
581 range checking of POS. */ | 581 range checking of POS. */ |
582 #define INC_POS(pos) \ | 582 #define INC_POS(pos) \ |
583 do { \ | 583 do { \ |
584 unsigned char *p = POS_ADDR (pos) + 1; \ | 584 unsigned char *p = POS_ADDR (pos); \ |
585 pos++; \ | 585 pos++; \ |
586 while (!CHAR_HEAD_P (p)) p++, pos++; \ | 586 if (*p++ >= 0x80) \ |
587 while (!CHAR_HEAD_P (p)) p++, pos++; \ | |
587 } while (0) | 588 } while (0) |
588 | 589 |
589 /* Decrease the buffer point POS of the current buffer to the previous | 590 /* Decrease the buffer point POS of the current buffer to the previous |
590 character boundary. No range checking of POS. */ | 591 character boundary. No range checking of POS. */ |
591 #define DEC_POS(pos) \ | 592 #define DEC_POS(pos) \ |
592 do { \ | 593 do { \ |
593 unsigned char *p, *p_min; \ | 594 unsigned char *p, *p_min; \ |
594 if (--pos < GPT) \ | 595 int pos_saved = --pos; \ |
596 if (pos < GPT) \ | |
595 p = BEG_ADDR + pos - 1, p_min = BEG_ADDR; \ | 597 p = BEG_ADDR + pos - 1, p_min = BEG_ADDR; \ |
596 else \ | 598 else \ |
597 p = BEG_ADDR + GAP_SIZE + pos - 1, p_min = GAP_END_ADDR; \ | 599 p = BEG_ADDR + GAP_SIZE + pos - 1, p_min = GAP_END_ADDR; \ |
598 while (p > p_min && !CHAR_HEAD_P (p)) p--, pos--; \ | 600 while (p > p_min && !CHAR_HEAD_P (p)) p--, pos--; \ |
601 if (*p < 0x80 && pos != pos_saved) pos = pos_saved; \ | |
599 } while (0) | 602 } while (0) |
600 | 603 |
601 #endif /* emacs */ | 604 #endif /* emacs */ |
602 | 605 |
603 /* Maximum counts of components in one composite character. */ | 606 /* Maximum counts of components in one composite character. */ |