GNU bug report logs - #41125
28.0.50; Fwindow_text_pixel_size uses FETCH_CHAR (charpos)

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> gmail.com>

Date: Thu, 7 May 2020 11:56:02 UTC

Severity: normal

Found in version 28.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#41125: closed (28.0.50; Fwindow_text_pixel_size uses
 FETCH_CHAR (charpos))
Date: Fri, 08 May 2020 10:39:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Fri, 08 May 2020 13:37:42 +0300
with message-id <83sggaiufd.fsf <at> gnu.org>
and subject line Re: bug#41125: 28.0.50; Fwindow_text_pixel_size uses FETCH_CHAR (charpos)
has caused the debbugs.gnu.org bug report #41125,
regarding 28.0.50; Fwindow_text_pixel_size uses FETCH_CHAR (charpos)
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
41125: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=41125
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Pip Cet <pipcet <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; Fwindow_text_pixel_size uses FETCH_CHAR (charpos)
Date: Thu, 7 May 2020 11:55:07 +0000
Fwindow_text_pixel_size contains this code:

      start = pos = BEGV;
      while ((pos++ < ZV) && (c = FETCH_CHAR (pos))
         && (c == ' ' || c == '\t' || c == '\n' || c == '\r'))
    start = pos;
      while ((pos-- > BEGV) && (c = FETCH_CHAR (pos)) && (c == ' ' ||
c == '\t'))
    start = pos;

which cannot possibly be correct: FETCH_CHAR takes a byte position,
not a character position, but BEGV and ZV are measured in characters.

(I'm familiarizing myself with the xdisp.c code, partly by replacing
bytepos/charpos pairs of variables with a combined pos_t type
variable. I think that's a good idea partly because it would prevent
precisely this kind of bug.)


[Message part 3 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 41125-done <at> debbugs.gnu.org, pipcet <at> gmail.com
Subject: Re: bug#41125: 28.0.50; Fwindow_text_pixel_size uses FETCH_CHAR
 (charpos)
Date: Fri, 08 May 2020 13:37:42 +0300
> Cc: 41125 <at> debbugs.gnu.org
> From: martin rudalics <rudalics <at> gmx.at>
> Date: Fri, 8 May 2020 09:18:27 +0200
> 
>  >> which cannot possibly be correct: FETCH_CHAR takes a byte position,
>  >> not a character position, but BEGV and ZV are measured in characters.
>  >
>  > Ouch!  Thanks.  Does the patch below look good?
> 
> It does.  Thanks for fixing yet another of my blunders in this function.
> And thanks to Pip for catching it.

Thanks, I pushed the fix to the emacs-27 branch.


This bug report was last modified 5 years and 11 days ago.

Previous Next


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