# HG changeset patch # User Kenichi Handa # Date 908193644 0 # Node ID 982f97638a8e877f0e176469852f9d772f1cf6c1 # Parent 4817632d3428d765cf9fa81ddf82d09453840af4 (clear_string_char_byte_cache): New function. (Ffillarray): Handle multibyte string correctly. diff -r 4817632d3428 -r 982f97638a8e src/fns.c --- a/src/fns.c Mon Oct 12 12:00:44 1998 +0000 +++ b/src/fns.c Mon Oct 12 12:00:44 1998 +0000 @@ -788,6 +788,12 @@ static int string_char_byte_cache_charpos; static int string_char_byte_cache_bytepos; +void +clear_string_char_byte_cache () +{ + string_char_byte_cache_string = Qnil; +} + /* Return the character index corresponding to CHAR_INDEX in STRING. */ int @@ -1782,8 +1788,26 @@ CHECK_NUMBER (item, 1); charval = XINT (item); size = XSTRING (array)->size; - for (index = 0; index < size; index++) - p[index] = charval; + if (STRING_MULTIBYTE (array)) + { + unsigned char workbuf[4], *str; + int len = CHAR_STRING (charval, workbuf, str); + int size_byte = STRING_BYTES (XSTRING (array)); + unsigned char *p1 = p, *endp = p + size_byte; + int this_len, i; + + for (i = 0; i < size; i++) + { + this_len = MULTIBYTE_FORM_LENGTH (p1, endp - p1); + if (len != this_len) + error ("Attempt to change byte length of a string"); + } + for (i = 0; i < size_byte; i++) + *p++ = str[i % len]; + } + else + for (index = 0; index < size; index++) + p[index] = charval; } else if (BOOL_VECTOR_P (array)) {