Mercurial > emacs
changeset 44323:fcc0f55d734f
(DEC_POS, BUF_DEC_POS): Use BEG_BYTE.
Bound the search with MAX_MULTIBYTE_LENGTH to avoid pathological case.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 01 Apr 2002 22:58:39 +0000 |
parents | fca902769bf4 |
children | def57419f6ec |
files | src/charset.h |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/charset.h Mon Apr 01 22:54:03 2002 +0000 +++ b/src/charset.h Mon Apr 01 22:58:39 2002 +0000 @@ -675,13 +675,15 @@ \ pos_byte--; \ if (pos_byte < GPT_BYTE) \ - p = BEG_ADDR + pos_byte - 1, p_min = BEG_ADDR; \ + p = BEG_ADDR + pos_byte - BEG_BYTE, p_min = BEG_ADDR; \ else \ - p = BEG_ADDR + GAP_SIZE + pos_byte - 1, p_min = GAP_END_ADDR; \ + p = BEG_ADDR + GAP_SIZE + pos_byte - BEG_BYTE, p_min = GAP_END_ADDR;\ if (p > p_min && !CHAR_HEAD_P (*p)) \ { \ unsigned char *pend = p--; \ int len, bytes; \ + if (p_min < p - MAX_MULTIBYTE_LENGTH) \ + p_min = p - MAX_MULTIBYTE_LENGTH; \ while (p > p_min && !CHAR_HEAD_P (*p)) p--; \ len = pend + 1 - p; \ PARSE_MULTIBYTE_SEQ (p, len, bytes); \ @@ -755,18 +757,20 @@ pos_byte--; \ if (pos_byte < BUF_GPT_BYTE (buf)) \ { \ - p = BUF_BEG_ADDR (buf) + pos_byte - 1; \ + p = BUF_BEG_ADDR (buf) + pos_byte - BEG_BYTE; \ p_min = BUF_BEG_ADDR (buf); \ } \ else \ { \ - p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - 1; \ + p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - BEG_BYTE;\ p_min = BUF_GAP_END_ADDR (buf); \ } \ if (p > p_min && !CHAR_HEAD_P (*p)) \ { \ unsigned char *pend = p--; \ int len, bytes; \ + if (p_min < p - MAX_MULTIBYTE_LENGTH) \ + p_min = p - MAX_MULTIBYTE_LENGTH; \ while (p > p_min && !CHAR_HEAD_P (*p)) p--; \ len = pend + 1 - p; \ PARSE_MULTIBYTE_SEQ (p, len, bytes); \