changeset 23424:982f97638a8e

(clear_string_char_byte_cache): New function. (Ffillarray): Handle multibyte string correctly.
author Kenichi Handa <handa@m17n.org>
date Mon, 12 Oct 1998 12:00:44 +0000
parents 4817632d3428
children 3ae4cc2b716c
files src/fns.c
diffstat 1 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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))
     {