comparison src/xselect.c @ 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 501c2e5945ff
children e41b38ec1a82 89ac10c67e45 3ebd9bdb4fe5
comparison
equal deleted inserted replaced
59992:6e49a3404a8e 59993:22a410b2373b
1767 of format 16 if every element in the vector is an integer, and is assumed 1767 of format 16 if every element in the vector is an integer, and is assumed
1768 to be of format 32 if any element is a cons of two integers. 1768 to be of format 32 if any element is a cons of two integers.
1769 1769
1770 When converting an object to C, it may be of the form (SYMBOL . <data>) 1770 When converting an object to C, it may be of the form (SYMBOL . <data>)
1771 where SYMBOL is what we should claim that the type is. Format and 1771 where SYMBOL is what we should claim that the type is. Format and
1772 representation are as above. */ 1772 representation are as above.
1773
1774 Important: When format is 32, data should contain an array of int,
1775 not an array of long as the X library returns. This makes a difference
1776 when sizeof(long) != sizeof(int). */
1773 1777
1774 1778
1775 1779
1776 static Lisp_Object 1780 static Lisp_Object
1777 selection_data_to_lisp_data (display, data, size, type, format) 1781 selection_data_to_lisp_data (display, data, size, type, format)
1809 a vector of symbols. 1813 a vector of symbols.
1810 */ 1814 */
1811 else if (type == XA_ATOM) 1815 else if (type == XA_ATOM)
1812 { 1816 {
1813 int i; 1817 int i;
1814 if (size == sizeof (Atom)) 1818 /* On a 64 bit machine sizeof(Atom) == sizeof(long) == 8.
1815 return x_atom_to_symbol (display, *((Atom *) data)); 1819 But the callers of these function has made sure the data for
1820 format == 32 is an array of int. Thus, use int instead
1821 of Atom. */
1822 int *idata = (int *) data;
1823
1824 if (size == sizeof (int))
1825 return x_atom_to_symbol (display, (Atom) idata[0]);
1816 else 1826 else
1817 { 1827 {
1818 Lisp_Object v = Fmake_vector (make_number (size / sizeof (Atom)), 1828 Lisp_Object v = Fmake_vector (make_number (size / sizeof (int)),
1819 make_number (0)); 1829 make_number (0));
1820 for (i = 0; i < size / sizeof (Atom); i++) 1830 for (i = 0; i < size / sizeof (int); i++)
1821 Faset (v, make_number (i), 1831 Faset (v, make_number (i),
1822 x_atom_to_symbol (display, ((Atom *) data) [i])); 1832 x_atom_to_symbol (display, (Atom) idata[i]));
1823 return v; 1833 return v;
1824 } 1834 }
1825 } 1835 }
1826 1836
1827 /* Convert a single 16 or small 32 bit number to a Lisp_Int. 1837 /* Convert a single 16 or small 32 bit number to a Lisp_Int.
2558 each number in DATA to its corresponfing X atom as a symbol. 2568 each number in DATA to its corresponfing X atom as a symbol.
2559 FORMAT is 8, 16 or 32 and gives the size in bits for each C value to 2569 FORMAT is 8, 16 or 32 and gives the size in bits for each C value to
2560 be stored in RET. 2570 be stored in RET.
2561 SIZE is the number of elements in DATA. 2571 SIZE is the number of elements in DATA.
2562 2572
2573 Important: When format is 32, data should contain an array of int,
2574 not an array of long as the X library returns. This makes a difference
2575 when sizeof(long) != sizeof(int).
2576
2563 Also see comment for selection_data_to_lisp_data above. */ 2577 Also see comment for selection_data_to_lisp_data above. */
2564 2578
2565 Lisp_Object 2579 Lisp_Object
2566 x_property_data_to_lisp (f, data, type, format, size) 2580 x_property_data_to_lisp (f, data, type, format, size)
2567 struct frame *f; 2581 struct frame *f;