emacs-devel
[Top][All Lists]
Advanced

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

Re: Questionable code in handling of wordend in the regexp engine in reg


From: Alan Mackenzie
Subject: Re: Questionable code in handling of wordend in the regexp engine in regex-emacs.c
Date: Sat, 2 Mar 2019 13:18:01 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

Hello, Eli.

On Sat, Mar 02, 2019 at 14:18:00 +0200, Eli Zaretskii wrote:
> > Date: Sat, 2 Mar 2019 11:16:40 +0000
> > Cc: address@hidden, address@hidden
> > From: Alan Mackenzie <address@hidden>

> > On the coding tests, we fail in one of them when bytepos == 1, and the
> > first byte in the buffer is 0xa4.  The Lisp call stack at the time is

> > Lisp Backtrace:
> > "decode-coding-region" (0xc35b5cb0)

> Ah, yes.  We should do this to prevent such false alarms:

>   eassert (NILP (BVAR (b, enable_multibyte_characters))
>            || bytepos >= BUF_Z_BYTE (b)
>          || CHAR_HEAD_P (BUF_FETCH_BYTE (b, bytepos)));

> IOW, this test is irrelevant in unibyte buffers.

Instead I moved the eassert to after the bit where it checks for unibyte
buffers, giving this:



diff --git a/src/marker.c b/src/marker.c
index b58051a8c2..0b2e1bf5c6 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -332,6 +332,10 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t 
bytepos)
   if (best_above == best_above_byte)
     return bytepos;
 
+  /* Check bytepos is not in the middle of a character. */
+  eassert (bytepos >= BUF_Z_BYTE (b)
+           || CHAR_HEAD_P (BUF_FETCH_BYTE (b, bytepos)));
+
   best_below = BEG;
   best_below_byte = BEG_BYTE;
 

I now no longer see the failed easserts in make check.

So I'll commit this sometime (real life is a bit urgent right now).

> Thanks.

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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