(GET_CHAR_BEFORE_2): Fix for the case that the previous EMACS_21_3
authorKenichi Handa <handa@m17n.org>
Thu, 16 Jan 2003 01:44:22 +0000 (01:44 +0000)
committerKenichi Handa <handa@m17n.org>
Thu, 16 Jan 2003 01:44:22 +0000 (01:44 +0000)
char is eight-bit-graphic.
(re_search_2): Likewise.

regex.c

diff --git a/regex.c b/regex.c
index 15ce02a..f9ea4a5 100644 (file)
--- a/regex.c
+++ b/regex.c
        {                                                               \
         re_char *dtemp = (p) == (str2) ? (end1) : (p);                 \
         re_char *dlimit = ((p) > (str2) && (p) <= (end2)) ? (str2) : (str1); \
+        re_char *d0 = dtemp;                                           \
         while (dtemp-- > dlimit && !CHAR_HEAD_P (*dtemp));             \
-        c = STRING_CHAR (dtemp, (p) - dtemp);                          \
+        if (MULTIBYTE_FORM_LENGTH (dtemp, d0 - dtemp) == d0 - dtemp)   \
+          c = STRING_CHAR (dtemp, d0 - dtemp);                         \
+        else                                                           \
+          c = d0[-1];                                                  \
        }                                                               \
      else                                                              \
        (c = ((p) == (str2) ? (end1) : (p))[-1]);                       \
@@ -4046,18 +4050,16 @@ re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop)
                p--, len++;
 
              /* Adjust it. */
-#if 0                          /* XXX */
              if (MULTIBYTE_FORM_LENGTH (p, len + 1) != (len + 1))
-               ;
-             else
-#endif
-               {
-                 range += len;
-                 if (range > 0)
-                   break;
+               /* The previous character is eight-bit-graphic which
+                  is represented by one byte even in a multibyte
+                  buffer/string.  */
+               len = 0;
+             range += len;
+             if (range > 0)
+               break;
 
-                 startpos -= len;
-               }
+             startpos -= len;
            }
        }
     }