comparison src/xselect.c @ 20104:6128508b0c31

Include buffer.h. (selection_data_to_lisp_data): Do not perform code conversion if the default value of enable-multibyte-characters is nil. (lisp_data_to_selection_data): Likewise. Access the array `charsets' in the correct way.
author Kenichi Handa <handa@m17n.org>
date Tue, 21 Oct 1997 10:43:40 +0000
parents 09d4a6c290ae
children 8c8f90c95569
comparison
equal deleted inserted replaced
20103:7867bb9ff46a 20104:6128508b0c31
25 #include "lisp.h" 25 #include "lisp.h"
26 #include "xterm.h" /* for all of the X includes */ 26 #include "xterm.h" /* for all of the X includes */
27 #include "dispextern.h" /* frame.h seems to want this */ 27 #include "dispextern.h" /* frame.h seems to want this */
28 #include "frame.h" /* Need this to get the X window of selected_frame */ 28 #include "frame.h" /* Need this to get the X window of selected_frame */
29 #include "blockinput.h" 29 #include "blockinput.h"
30 #include "buffer.h"
30 #include "charset.h" 31 #include "charset.h"
31 #include "coding.h" 32 #include "coding.h"
32 33
33 #define CUT_BUFFER_SUPPORT 34 #define CUT_BUFFER_SUPPORT
34 35
1466 else if (format == 8) 1467 else if (format == 8)
1467 { 1468 {
1468 Lisp_Object str; 1469 Lisp_Object str;
1469 int require_encoding = 0; 1470 int require_encoding = 0;
1470 1471
1471 /* If TYPE is `TEXT' or `COMPOUND_TEXT', we should decode DATA 1472 if (! NILP (buffer_defaults.enable_multibyte_characters))
1472 to Emacs internal format because DATA may be encoded in
1473 compound text format. In addtion, if TYPE is `STRING' and
1474 DATA contains any 8-bit Latin-1 code, we should also decode
1475 it. */
1476 if (type == dpyinfo->Xatom_TEXT || type == dpyinfo->Xatom_COMPOUND_TEXT)
1477 require_encoding = 1;
1478 else if (type == XA_STRING)
1479 { 1473 {
1480 int i; 1474 /* If TYPE is `TEXT' or `COMPOUND_TEXT', we should decode
1481 for (i = 0; i < size; i++) 1475 DATA to Emacs internal format because DATA may be encoded
1476 in compound text format. In addtion, if TYPE is `STRING'
1477 and DATA contains any 8-bit Latin-1 code, we should also
1478 decode it. */
1479 if (type == dpyinfo->Xatom_TEXT
1480 || type == dpyinfo->Xatom_COMPOUND_TEXT)
1481 require_encoding = 1;
1482 else if (type == XA_STRING)
1482 { 1483 {
1483 if (data[i] >= 0x80) 1484 int i;
1485 for (i = 0; i < size; i++)
1484 { 1486 {
1485 require_encoding = 1; 1487 if (data[i] >= 0x80)
1486 break; 1488 {
1489 require_encoding = 1;
1490 break;
1491 }
1487 } 1492 }
1488 } 1493 }
1489 } 1494 }
1490 if (!require_encoding) 1495 if (!require_encoding)
1491 str = make_string ((char *) data, size); 1496 str = make_string ((char *) data, size);
1606 1611
1607 *format_ret = 8; 1612 *format_ret = 8;
1608 *size_ret = XSTRING (obj)->size; 1613 *size_ret = XSTRING (obj)->size;
1609 *data_ret = XSTRING (obj)->data; 1614 *data_ret = XSTRING (obj)->data;
1610 bzero (charsets, (MAX_CHARSET + 1) * sizeof (int)); 1615 bzero (charsets, (MAX_CHARSET + 1) * sizeof (int));
1611 num = ((*size_ret <= 1) /* Check the possibility of short cut. */ 1616 num = ((*size_ret <= 1 /* Check the possibility of short cut. */
1617 || NILP (buffer_defaults.enable_multibyte_characters))
1612 ? 0 1618 ? 0
1613 : find_charset_in_str (*data_ret, *size_ret, charsets, Qnil)); 1619 : find_charset_in_str (*data_ret, *size_ret, charsets, Qnil));
1614 1620
1615 if (!num || (num == 1 && charsets[CHARSET_ASCII])) 1621 if (!num || (num == 1 && charsets[CHARSET_ASCII]))
1616 { 1622 {
1634 bufsize = encoding_buffer_size (&coding, *size_ret); 1640 bufsize = encoding_buffer_size (&coding, *size_ret);
1635 buf = (unsigned char *) xmalloc (bufsize); 1641 buf = (unsigned char *) xmalloc (bufsize);
1636 *size_ret = encode_coding (&coding, *data_ret, buf, 1642 *size_ret = encode_coding (&coding, *data_ret, buf,
1637 *size_ret, bufsize, &dummy); 1643 *size_ret, bufsize, &dummy);
1638 *data_ret = buf; 1644 *data_ret = buf;
1639 if (charsets[get_charset_id(charset_latin_iso8859_1)] 1645 if (charsets[charset_latin_iso8859_1]
1640 && (num == 1 || (num == 2 && charsets[CHARSET_ASCII]))) 1646 && (num == 1 || (num == 2 && charsets[CHARSET_ASCII])))
1641 { 1647 {
1642 /* Ok, we can return it as `STRING'. */ 1648 /* Ok, we can return it as `STRING'. */
1643 if (NILP (type)) type = QSTRING; 1649 if (NILP (type)) type = QSTRING;
1644 } 1650 }