From 28a29eb02272b03b9bdd16dd73d7471054f486b1 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Thu, 27 Feb 1997 11:11:46 +0000 Subject: [PATCH] (INC_POS, DEC_POS): Don't increase or decrease too much if there's binary code (invalid character code). --- src/charset.h | 15 +++++++++------ 1 file 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]; character boundary. This macro relies on the fact that *GPT_ADDR and *Z_ADDR are always accessible and the values are '\0'. No range checking of POS. */ -#define INC_POS(pos) \ - do { \ - unsigned char *p = POS_ADDR (pos) + 1; \ - pos++; \ - while (!CHAR_HEAD_P (p)) p++, pos++; \ +#define INC_POS(pos) \ + do { \ + unsigned char *p = POS_ADDR (pos); \ + pos++; \ + if (*p++ >= 0x80) \ + while (!CHAR_HEAD_P (p)) p++, pos++; \ } while (0) /* Decrease the buffer point POS of the current buffer to the previous @@ -591,11 +592,13 @@ extern int iso_charset_table[2][2][128]; #define DEC_POS(pos) \ do { \ unsigned char *p, *p_min; \ - if (--pos < GPT) \ + int pos_saved = --pos; \ + if (pos < GPT) \ p = BEG_ADDR + pos - 1, p_min = BEG_ADDR; \ else \ p = BEG_ADDR + GAP_SIZE + pos - 1, p_min = GAP_END_ADDR; \ while (p > p_min && !CHAR_HEAD_P (p)) p--, pos--; \ + if (*p < 0x80 && pos != pos_saved) pos = pos_saved; \ } while (0) #endif /* emacs */ -- 2.39.5