tally_consing (needed);
}
-/* Reallocate the data for STRING when a single character is replaced.
+/* Reallocate multibyte STRING data when a single character is replaced.
The character is at byte offset CIDX_BYTE in the string.
The character being replaced is CLEN bytes long,
and the character that will replace it is NEW_CLEN bytes long.
resize_string_data (Lisp_Object string, ptrdiff_t cidx_byte,
int clen, int new_clen)
{
+ eassume (STRING_MULTIBYTE (string));
sdata *old_sdata = SDATA_OF_STRING (XSTRING (string));
ptrdiff_t nchars = SCHARS (string);
ptrdiff_t nbytes = SBYTES (string);
{
/* No need to reallocate, as the size change falls within the
alignment slop. */
+ XSTRING (string)->u.s.size_byte = new_nbytes;
new_charaddr = data + cidx_byte;
memmove (new_charaddr + new_clen, new_charaddr + clen,
nbytes - (cidx_byte + (clen - 1)));
(should-not (eq x y))
(dotimes (i 4)
(should (eql (aref x i) (aref y i))))))
+
+;; Bug#39207
+(ert-deftest aset-nbytes-change ()
+ (let ((s (make-string 1 ?a)))
+ (dolist (c (list 10003 ?b 128 ?c ?d (max-char) ?e))
+ (aset s 0 c)
+ (should (equal s (make-string 1 c))))))