changeset 5629:0d05accafc63

Don't lose bits in make_fixnum / make_char_1. See xemacs-patches message with ID <CAHCOHQnRTjm6c5gWVO3iizWJ9Jb7GvEyFe3aQ19hAXhcR_mrrA@mail.gmail.com>.
author Jerry James <james@xemacs.org>
date Wed, 28 Dec 2011 11:30:47 -0700
parents 81fee4aee9b6
children f5315ccbf005
files src/ChangeLog src/lisp-disunion.h
diffstat 2 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Dec 28 11:21:38 2011 +0100
+++ b/src/ChangeLog	Wed Dec 28 11:30:47 2011 -0700
@@ -1,3 +1,9 @@
+2011-12-28  Jerry James  <james@xemacs.org>
+
+	* lisp-disunion.h (make_fixnum): avoid losing bits off the left end
+	if the value is of large magnitude and narrow type.
+	(make_char_1): ditto.
+
 2011-12-28  Didier Verna  <didier@xemacs.org>
 
 	* console-impl.h (struct console_methods): Have the text_width
--- a/src/lisp-disunion.h	Wed Dec 28 11:21:38 2011 +0100
+++ b/src/lisp-disunion.h	Wed Dec 28 11:30:47 2011 -0700
@@ -96,9 +96,9 @@
   return obj;
 }
 
-#define make_fixnum(x) ((Lisp_Object) (((x) << FIXNUM_GCBITS) | Lisp_Type_Fixnum_Bit))
+#define make_fixnum(x) ((Lisp_Object) ((((EMACS_INT)(x)) << FIXNUM_GCBITS) | Lisp_Type_Fixnum_Bit))
 
-#define make_char_1(x) ((Lisp_Object) (((x) << GCBITS) | Lisp_Type_Char))
+#define make_char_1(x) ((Lisp_Object) ((((EMACS_UINT)(x)) << GCBITS) | Lisp_Type_Char))
 
 #define FIXNUMP(x) ((EMACS_UINT)(x) & Lisp_Type_Fixnum_Bit)
 #define FIXNUM_PLUS(x,y)  ((x)+(y)-Lisp_Type_Fixnum_Bit)