]> git.eshelyaron.com Git - emacs.git/commitdiff
(INC_POS, DEC_POS): Don't increase or decrease too
authorKenichi Handa <handa@m17n.org>
Thu, 27 Feb 1997 11:11:46 +0000 (11:11 +0000)
committerKenichi Handa <handa@m17n.org>
Thu, 27 Feb 1997 11:11:46 +0000 (11:11 +0000)
much if there's binary code (invalid character code).

src/charset.h

index d51c6d6f91a2155dbcc27f0d71cfc6d39471f155..c7c4baecdab88d0b4f92df2ebd67e9acf33c1558 100644 (file)
@@ -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 */