aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorKenichi Handa1998-10-12 12:00:44 +0000
committerKenichi Handa1998-10-12 12:00:44 +0000
commitdbda4aad5605d7b984de04c89bd3a7024eb9a4a8 (patch)
tree15fc04f87c612a3623649ba13b53a13686f91d5f /src/data.c
parent57247650fbe47e56ae4148f6db9e105d944192f6 (diff)
downloademacs-dbda4aad5605d7b984de04c89bd3a7024eb9a4a8.tar.gz
emacs-dbda4aad5605d7b984de04c89bd3a7024eb9a4a8.zip
(Faset): If ARRAY is a multibyte string, pay attention to
byte-combining situation.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/data.c b/src/data.c
index f704c8fa049..da9d86f81bc 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1853,7 +1853,8 @@ IDX starts at 0.")
1853 else if (STRING_MULTIBYTE (array)) 1853 else if (STRING_MULTIBYTE (array))
1854 { 1854 {
1855 int c, idxval_byte, new_len, actual_len; 1855 int c, idxval_byte, new_len, actual_len;
1856 unsigned char *p, *str; 1856 unsigned char *p, workbuf[4], *str;
1857 int recount = 0;
1857 1858
1858 if (idxval < 0 || idxval >= XSTRING (array)->size) 1859 if (idxval < 0 || idxval >= XSTRING (array)->size)
1859 args_out_of_range (array, idx); 1860 args_out_of_range (array, idx);
@@ -1864,13 +1865,22 @@ IDX starts at 0.")
1864 actual_len 1865 actual_len
1865 = MULTIBYTE_FORM_LENGTH (p, STRING_BYTES (XSTRING (array)) - idxval_byte); 1866 = MULTIBYTE_FORM_LENGTH (p, STRING_BYTES (XSTRING (array)) - idxval_byte);
1866 CHECK_NUMBER (newelt, 2); 1867 CHECK_NUMBER (newelt, 2);
1867 new_len = CHAR_BYTES (XINT (newelt)); 1868 new_len = CHAR_STRING (XINT (newelt), workbuf, str);
1868 if (actual_len != new_len) 1869 if (actual_len != new_len)
1869 error ("Attempt to change byte length of a string"); 1870 error ("Attempt to change byte length of a string");
1870 1871 if (!CHAR_HEAD_P (*str)
1871 CHAR_STRING (XINT (newelt), p, str); 1872 || !CHAR_HEAD_P (XSTRING (array)->data[idxval_byte + actual_len]))
1872 if (p != str) 1873 /* We may have to combine bytes. */
1873 bcopy (str, p, actual_len); 1874 recount = 1;
1875 while (new_len--)
1876 *p++ = *str++;
1877 if (recount)
1878 {
1879 XSTRING (array)->size =
1880 chars_in_text (XSTRING (array)->data,
1881 STRING_BYTES (XSTRING (array)));
1882 clear_string_char_byte_cache ();
1883 }
1874 } 1884 }
1875 else 1885 else
1876 { 1886 {