changeset 59993:22a410b2373b

* xselect.c (selection_data_to_lisp_data): For the special case type == XA_ATOM, data contains array of int, not array of Atom. (x_property_data_to_lisp, selection_data_to_lisp_data): Comment update: data must be array of int for format == 32.
author Jan Djärv <jan.h.d@swipnet.se>
date Tue, 08 Feb 2005 21:27:01 +0000
parents 6e49a3404a8e
children 3e0903b0d56d
files src/ChangeLog src/xselect.c
diffstat 2 files changed, 27 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Feb 08 20:49:16 2005 +0000
+++ b/src/ChangeLog	Tue Feb 08 21:27:01 2005 +0000
@@ -1,3 +1,10 @@
+2005-02-08  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xselect.c (selection_data_to_lisp_data): For the special case
+	type == XA_ATOM, data contains array of int, not array of Atom.
+	(x_property_data_to_lisp, selection_data_to_lisp_data): Comment
+	update: data must be array of int for format == 32.
+
 2005-02-08  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* undo.c (Fprimitive_undo): Check veracity of delta,start,end.
--- a/src/xselect.c	Tue Feb 08 20:49:16 2005 +0000
+++ b/src/xselect.c	Tue Feb 08 21:27:01 2005 +0000
@@ -1769,7 +1769,11 @@
 
    When converting an object to C, it may be of the form (SYMBOL . <data>)
    where SYMBOL is what we should claim that the type is.  Format and
-   representation are as above.  */
+   representation are as above.
+
+   Important: When format is 32, data should contain an array of int,
+   not an array of long as the X library returns.  This makes a difference
+   when sizeof(long) != sizeof(int).  */
 
 
 
@@ -1811,15 +1815,21 @@
   else if (type == XA_ATOM)
     {
       int i;
-      if (size == sizeof (Atom))
-	return x_atom_to_symbol (display, *((Atom *) data));
+      /* On a 64 bit machine sizeof(Atom) == sizeof(long) == 8.
+         But the callers of these function has made sure the data for
+         format == 32 is an array of int.  Thus, use int instead
+         of Atom.  */
+      int *idata = (int *) data;
+
+      if (size == sizeof (int))
+	return x_atom_to_symbol (display, (Atom) idata[0]);
       else
 	{
-	  Lisp_Object v = Fmake_vector (make_number (size / sizeof (Atom)),
+	  Lisp_Object v = Fmake_vector (make_number (size / sizeof (int)),
 					make_number (0));
-	  for (i = 0; i < size / sizeof (Atom); i++)
+	  for (i = 0; i < size / sizeof (int); i++)
 	    Faset (v, make_number (i),
-		   x_atom_to_symbol (display, ((Atom *) data) [i]));
+                   x_atom_to_symbol (display, (Atom) idata[i]));
 	  return v;
 	}
     }
@@ -2560,6 +2570,10 @@
    be stored in RET.
    SIZE is the number of elements in DATA.
 
+   Important: When format is 32, data should contain an array of int,
+   not an array of long as the X library returns.  This makes a difference
+   when sizeof(long) != sizeof(int).
+
    Also see comment for selection_data_to_lisp_data above.  */
 
 Lisp_Object