aboutsummaryrefslogtreecommitdiffstats
path: root/src/xselect.c
diff options
context:
space:
mode:
authorKenichi Handa2000-05-20 00:08:10 +0000
committerKenichi Handa2000-05-20 00:08:10 +0000
commit9846d9dbcfa265d686e6eebe4e050d5a0e7fd7e0 (patch)
tree8495f13f2286a37f6b58744c348254272b5bc7a5 /src/xselect.c
parentc5924f47e9335d100b81184d176d1a68ffaac5ea (diff)
downloademacs-9846d9dbcfa265d686e6eebe4e050d5a0e7fd7e0.tar.gz
emacs-9846d9dbcfa265d686e6eebe4e050d5a0e7fd7e0.zip
(selection_data_to_lisp_data): Setup members
src_multibyte and dst_multibyte of coding. Adjusted for the change for find_charset_in_str. (lisp_data_to_selection_data): Likewise.
Diffstat (limited to 'src/xselect.c')
-rw-r--r--src/xselect.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/xselect.c b/src/xselect.c
index 27bb4689bcb..e785960b863 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1539,15 +1539,15 @@ selection_data_to_lisp_data (display, data, size, type, format)
1539 Vnext_selection_coding_system = Vselection_coding_system; 1539 Vnext_selection_coding_system = Vselection_coding_system;
1540 setup_coding_system 1540 setup_coding_system
1541 (Fcheck_coding_system(Vnext_selection_coding_system), &coding); 1541 (Fcheck_coding_system(Vnext_selection_coding_system), &coding);
1542 coding.src_multibyte = 0;
1543 coding.dst_multibyte = 1;
1542 Vnext_selection_coding_system = Qnil; 1544 Vnext_selection_coding_system = Qnil;
1543 coding.mode |= CODING_MODE_LAST_BLOCK; 1545 coding.mode |= CODING_MODE_LAST_BLOCK;
1544 bufsize = decoding_buffer_size (&coding, size); 1546 bufsize = decoding_buffer_size (&coding, size);
1545 buf = (unsigned char *) xmalloc (bufsize); 1547 buf = (unsigned char *) xmalloc (bufsize);
1546 decode_coding (&coding, data, buf, size, bufsize); 1548 decode_coding (&coding, data, buf, size, bufsize);
1547 size = (coding.fake_multibyte 1549 str = make_string_from_bytes ((char *) buf,
1548 ? multibyte_chars_in_text (buf, coding.produced) 1550 coding.produced_char, coding.produced);
1549 : coding.produced_char);
1550 str = make_string_from_bytes ((char *) buf, size, coding.produced);
1551 xfree (buf); 1551 xfree (buf);
1552 Vlast_coding_system_used = coding.symbol; 1552 Vlast_coding_system_used = coding.symbol;
1553 } 1553 }
@@ -1648,22 +1648,17 @@ lisp_data_to_selection_data (display, obj,
1648 { 1648 {
1649 /* Since we are now handling multilingual text, we must consider 1649 /* Since we are now handling multilingual text, we must consider
1650 sending back compound text. */ 1650 sending back compound text. */
1651 int charsets[MAX_CHARSET + 1]; 1651 unsigned char *ptr = XSTRING (obj)->data;
1652 int num; 1652 int nbytes = STRING_BYTES (XSTRING (obj));
1653 1653 int charset_info = find_charset_in_text (ptr, XSTRING (obj)->size,
1654 nbytes, NULL, Qnil);
1654 *format_ret = 8; 1655 *format_ret = 8;
1655 *size_ret = STRING_BYTES (XSTRING (obj)); 1656
1656 *data_ret = XSTRING (obj)->data; 1657 if (charset_info == 0)
1657 bzero (charsets, (MAX_CHARSET + 1) * sizeof (int));
1658 num = ((*size_ret <= 1 /* Check the possibility of short cut. */
1659 || !STRING_MULTIBYTE (obj)
1660 || *size_ret == XSTRING (obj)->size)
1661 ? 0
1662 : find_charset_in_str (*data_ret, *size_ret, charsets, Qnil, 1));
1663
1664 if (!num || (num == 1 && charsets[CHARSET_ASCII]))
1665 { 1658 {
1666 /* No multibyte character in OBJ. We need not encode it. */ 1659 /* No multibyte character in OBJ. We need not encode it. */
1660 *size_ret = nbytes;
1661 *data_ret = ptr;
1667 *nofree_ret = 1; 1662 *nofree_ret = 1;
1668 if (NILP (type)) type = QSTRING; 1663 if (NILP (type)) type = QSTRING;
1669 Vlast_coding_system_used = Qraw_text; 1664 Vlast_coding_system_used = Qraw_text;
@@ -1682,15 +1677,16 @@ lisp_data_to_selection_data (display, obj,
1682 Vnext_selection_coding_system = Vselection_coding_system; 1677 Vnext_selection_coding_system = Vselection_coding_system;
1683 setup_coding_system 1678 setup_coding_system
1684 (Fcheck_coding_system (Vnext_selection_coding_system), &coding); 1679 (Fcheck_coding_system (Vnext_selection_coding_system), &coding);
1680 coding.src_multibyte = 1;
1681 coding.dst_multibyte = 0;
1685 Vnext_selection_coding_system = Qnil; 1682 Vnext_selection_coding_system = Qnil;
1686 coding.mode |= CODING_MODE_LAST_BLOCK; 1683 coding.mode |= CODING_MODE_LAST_BLOCK;
1687 bufsize = encoding_buffer_size (&coding, *size_ret); 1684 bufsize = encoding_buffer_size (&coding, nbytes);
1688 buf = (unsigned char *) xmalloc (bufsize); 1685 buf = (unsigned char *) xmalloc (bufsize);
1689 encode_coding (&coding, *data_ret, buf, *size_ret, bufsize); 1686 encode_coding (&coding, ptr, buf, nbytes, bufsize);
1690 *size_ret = coding.produced; 1687 *size_ret = coding.produced;
1691 *data_ret = buf; 1688 *data_ret = buf;
1692 if (charsets[charset_latin_iso8859_1] 1689 if (charset_info == 1)
1693 && (num == 1 || (num == 2 && charsets[CHARSET_ASCII])))
1694 { 1690 {
1695 /* Ok, we can return it as `STRING'. */ 1691 /* Ok, we can return it as `STRING'. */
1696 if (NILP (type)) type = QSTRING; 1692 if (NILP (type)) type = QSTRING;