diff options
| author | Kenichi Handa | 1997-02-27 11:11:46 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1997-02-27 11:11:46 +0000 |
| commit | 28a29eb02272b03b9bdd16dd73d7471054f486b1 (patch) | |
| tree | ced4fd83599257f627ed98706df9a63c96dd235c /src | |
| parent | e0e989f659d1b8fffcc9055028a50c8dc0c153fb (diff) | |
| download | emacs-28a29eb02272b03b9bdd16dd73d7471054f486b1.tar.gz emacs-28a29eb02272b03b9bdd16dd73d7471054f486b1.zip | |
(INC_POS, DEC_POS): Don't increase or decrease too
much if there's binary code (invalid character code).
Diffstat (limited to 'src')
| -rw-r--r-- | src/charset.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/charset.h b/src/charset.h index d51c6d6f91a..c7c4baecdab 100644 --- a/src/charset.h +++ b/src/charset.h | |||
| @@ -579,11 +579,12 @@ extern int iso_charset_table[2][2][128]; | |||
| 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 |
| @@ -591,11 +592,13 @@ extern int iso_charset_table[2][2][128]; | |||
| 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 */ |