emacs-diffs
[Top][All Lists]
Advanced

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

master a492013: Fix more single-byte accesses caused by bytepos/charpos


From: Lars Ingebrigtsen
Subject: master a492013: Fix more single-byte accesses caused by bytepos/charpos confusion
Date: Sun, 27 Sep 2020 11:40:22 -0400 (EDT)

branch: master
commit a492013d07c59fab8eb9779924b384181e878a1a
Author: Pip Cet <pipcet@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix more single-byte accesses caused by bytepos/charpos confusion
    
    * src/cmds.c (internal_self_insert): Use FETCH_BYTE, not
    FETCH_CHAR, for a decremented byte position (bug#41520).
    
    * src/xdisp.c (Fwindow_text_pixel_size, trailing_whitespace_p): Ditto.
---
 src/cmds.c  | 2 +-
 src/xdisp.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/cmds.c b/src/cmds.c
index 9052661..c29cf00 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -390,7 +390,7 @@ internal_self_insert (int c, EMACS_INT n)
                     by spaces so that the remaining text won't move.  */
                  ptrdiff_t actual = PT_BYTE;
                  actual -= prev_char_len (actual);
-                 if (FETCH_CHAR (actual) == '\t')
+                 if (FETCH_BYTE (actual) == '\t')
                    /* Rather than add spaces, let's just keep the tab. */
                    chars_to_delete--;
                  else
diff --git a/src/xdisp.c b/src/xdisp.c
index 3d40878..ecd23e0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10619,7 +10619,7 @@ include the height of both, if present, in the return 
value.  */)
       while (bpos > BEGV_BYTE)
        {
          dec_both (&start, &bpos);
-         c = FETCH_CHAR (bpos);
+         c = FETCH_BYTE (bpos);
          if (!(c == ' ' || c == '\t'))
            break;
        }
@@ -10641,7 +10641,7 @@ include the height of both, if present, in the return 
value.  */)
       while (bpos > BEGV_BYTE)
        {
          dec_both (&end, &bpos);
-         c = FETCH_CHAR (bpos);
+         c = FETCH_BYTE (bpos);
          if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r'))
            break;
        }
@@ -22277,7 +22277,7 @@ trailing_whitespace_p (ptrdiff_t charpos)
   int c = 0;
 
   while (bytepos < ZV_BYTE
-        && (c = FETCH_CHAR (bytepos),
+        && (c = FETCH_BYTE (bytepos),
             c == ' ' || c == '\t'))
     ++bytepos;
 



reply via email to

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