From 55daad71c7427e6ce811fa70f2ccdaf630e235e1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 9 Jun 2011 12:03:59 -0700 Subject: [PATCH] * buffer.h (PTR_BYTE_POS, BUF_PTR_BYTE_POS): Remove harmful cast. The cast incorrectly truncated 64-bit byte offsets to 32 bits, and isn't needed on 32-bit machines. --- src/ChangeLog | 4 +++- src/buffer.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f4de3d991d9..1222c04d091 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -5,7 +5,9 @@ * xfns.c (x_set_scroll_bar_default_width): Remove unused 'int' locals. - * buffer.h (PTR_BYTE_POS): Don't assume a byte count fits in 'unsigned'. + * buffer.h (PTR_BYTE_POS, BUF_PTR_BYTE_POS): Remove harmful cast. + The cast incorrectly truncated 64-bit byte offsets to 32 bits, and + isn't needed on 32-bit machines. * buffer.c (Fgenerate_new_buffer_name): Use EMACS_INT for count, not int. (advance_to_char_boundary): Return EMACS_INT, not int. diff --git a/src/buffer.h b/src/buffer.h index ba48a8105a2..725e4edb638 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -337,7 +337,7 @@ while (0) #define PTR_BYTE_POS(ptr) \ ((ptr) - (current_buffer)->text->beg \ - - (ptr - (current_buffer)->text->beg <= (size_t) (GPT_BYTE - BEG_BYTE) ? 0 : GAP_SIZE) \ + - (ptr - (current_buffer)->text->beg <= GPT_BYTE - BEG_BYTE ? 0 : GAP_SIZE) \ + BEG_BYTE) /* Return character at byte position POS. */ @@ -396,7 +396,7 @@ extern unsigned char *_fetch_multibyte_char_p; #define BUF_PTR_BYTE_POS(buf, ptr) \ ((ptr) - (buf)->text->beg \ - - (ptr - (buf)->text->beg <= (unsigned) (BUF_GPT_BYTE ((buf)) - BEG_BYTE)\ + - (ptr - (buf)->text->beg <= BUF_GPT_BYTE (buf) - BEG_BYTE \ ? 0 : BUF_GAP_SIZE ((buf))) \ + BEG_BYTE) -- 2.39.2