From ca2f68f8d937e36d9aea9e1acc7d091a6a0140de Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Thu, 22 Jan 1998 01:26:45 +0000 Subject: [PATCH] (Faset): Allow setting a multibyte character in a multibyte string as far as it doesn't change the size_byte of the string. --- src/data.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/data.c b/src/data.c index aa2cfe06fd2..b9f440c93aa 100644 --- a/src/data.c +++ b/src/data.c @@ -1743,22 +1743,25 @@ IDX starts at 0.") } else if (STRING_MULTIBYTE (array)) { - Lisp_Object val; + Lisp_Object new_len; int c, idxval_byte, actual_len; + unsigned char *p, *str; if (idxval < 0 || idxval >= XSTRING (array)->size) args_out_of_range (array, idx); idxval_byte = string_char_to_byte (array, idxval); + p = &XSTRING (array)->data[idxval_byte]; - c = STRING_CHAR_AND_LENGTH (&XSTRING (array)->data[idxval_byte], - XSTRING (array)->size_byte - idxval_byte, - actual_len); - if (actual_len != 1) - error ("Attempt to store a multibyte character into a string"); + actual_len + = MULTIBYTE_FORM_LENGTH (p, XSTRING (array)->size_byte - idxval_byte); + new_len = Fchar_bytes (newelt); + if (actual_len != XINT (new_len)) + error ("Attempt to change byte length of a string"); - CHECK_NUMBER (newelt, 2); - XSTRING (array)->data[idxval_byte] = XINT (newelt); + CHAR_STRING (XINT (newelt), p, str); + if (p != str) + bcopy (str, p, actual_len); } else { -- 2.39.2