GNU bug report logs - #77924
31.0.50; [Feature branch] Change marker implementation

Previous Next

Package: emacs;

Reported by: Gerd Möllmann <gerd.moellmann <at> gmail.com>

Date: Sat, 19 Apr 2025 16:06:02 UTC

Severity: normal

Found in version 31.0.50

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Gerd Möllmann <gerd.moellmann <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, stefankangas <at> gmail.com, 77924 <at> debbugs.gnu.org
Subject: bug#77924: 31.0.50; [Feature branch] Change marker implementation
Date: Sat, 26 Apr 2025 19:19:52 -0400
> -  /* Don't scan forward if CHARPOS is exactly on the previous known
> -     position because the index bytepos can be in the middle of a
> -     character, which is found by scanning backwards.  */
> -  ptrdiff_t bytepos
> -    = (charpos == prev.charpos ? bytepos_of_head (b, prev.bytepos)
> -       : (charpos - prev.charpos < next.charpos - charpos
> -	  ? bytepos_forward_to_charpos (b, prev, charpos)
> -	  : bytepos_backward_to_charpos (b, next, charpos)));
> +  /* Scan forward if the distance to the previous known position is
> +     smaller than the distance to the next known position.  */
> +  const ptrdiff_t bytepos
> +    = (charpos - prev.charpos < next.charpos - charpos
> +       ? bytepos_forward_to_charpos (b, prev, charpos)
> +       : bytepos_backward_to_charpos (b, next, charpos));

I don't understand: `prev` can point into the middle of a char, so if
`charpos == prev.charpos`, `bytepos_forward_to_charpos` may return an
incorrect `bytepos` (it'll return `prev.bytepos` which can be in the
middle of that char).


        Stefan





This bug report was last modified 106 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.