bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in regexp matching in data readed in binary mode


From: Kenichi Handa
Subject: Re: Bug in regexp matching in data readed in binary mode
Date: Thu, 16 Jan 2003 09:31:41 +0900 (JST)
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.2.92 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI)

In article <2nvg0qqomo.fsf@zsh.cs.rochester.edu>, ShengHuo ZHU 
<zsh@cs.rochester.edu> writes:
> I can reproduce the bug, however I think the bug is probably related
> to the decoding part of the read_process_output function, which I am
> not familiar with.

> I hope that the following code (based on Alex's code) may illustrate
> the bug in a better way.  The first piece of code returns t, which is
> obviously wrong. But if we insert a space and delete it, it returns
> nil in the second piece.

Thank you for the test case.  The bug was in regex.c.  The
attached patch will fix it.  Please try it.  It also fixes
the bug of backward searching of eight-bit-graphic char.

Stefan, it seems that you are maintaining regex.c.  What
should I do for this change?  Can I directly install it in
HEAD (and perhaps in RC)?

---
Ken'ichi HANDA
handa@m17n.org

2003-01-16  Kenichi Handa  <handa@m17n.org>

        * regex.c (GET_CHAR_BEFORE_2): Fix for the case that the previous
        char is eight-bit-graphic.
        (re_search_2): Likewise.

*** regex.c.~1.183.~    Wed Dec  4 17:26:49 2002
--- regex.c     Thu Jan 16 09:27:28 2003
***************
*** 157,164 ****
         {                                                              \
         re_char *dtemp = (p) == (str2) ? (end1) : (p);                 \
         re_char *dlimit = ((p) > (str2) && (p) <= (end2)) ? (str2) : (str1); \
         while (dtemp-- > dlimit && !CHAR_HEAD_P (*dtemp));             \
!        c = STRING_CHAR (dtemp, (p) - dtemp);                          \
         }                                                              \
       else                                                             \
         (c = ((p) == (str2) ? (end1) : (p))[-1]);                      \
--- 157,168 ----
         {                                                              \
         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));             \
!        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]);                      \
***************
*** 4307,4324 ****
                p--, len++;
  
              /* Adjust it. */
- #if 0                         /* XXX */
              if (MULTIBYTE_FORM_LENGTH (p, len + 1) != (len + 1))
!               ;
!             else
! #endif
!               {
!                 range += len;
!                 if (range > 0)
!                   break;
  
!                 startpos -= len;
!               }
            }
        }
      }
--- 4311,4326 ----
                p--, len++;
  
              /* Adjust it. */
              if (MULTIBYTE_FORM_LENGTH (p, len + 1) != (len + 1))
!               /* 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;
            }
        }
      }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]