From: Paul Eggert Date: Thu, 9 Jun 2011 19:03:59 +0000 (-0700) Subject: * buffer.h (PTR_BYTE_POS, BUF_PTR_BYTE_POS): Remove harmful cast. X-Git-Tag: emacs-pretest-24.0.90~104^2~548^2~51 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=55daad71c7427e6ce811fa70f2ccdaf630e235e1;p=emacs.git * 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. --- 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)