# HG changeset patch # User Kenichi Handa # Date 866639345 0 # Node ID 8b716cb12cdd12a4e1c6d98d76717bcb831ca93e # Parent a97ed8efcb6aa3fbba085c35e663ac334acdbf39 (concat): Pay attention to multibyte characters when TARGET_TYPE is Lisp_String. diff -r a97ed8efcb6a -r 8b716cb12cdd src/fns.c --- a/src/fns.c Wed Jun 18 13:09:00 1997 +0000 +++ b/src/fns.c Wed Jun 18 13:09:05 1997 +0000 @@ -406,7 +406,23 @@ { this = args[argnum]; len = Flength (this); - leni += XFASTINT (len); + if (VECTORP (this) && target_type == Lisp_String) + { + /* We must pay attention to a multibyte character which + takes more than one byte in string. */ + int i; + Lisp_Object ch; + + for (i = 0; i < XFASTINT (len); i++) + { + ch = XVECTOR (this)->contents[i]; + if (! INTEGERP (ch)) + wrong_type_argument (Qintegerp, ch); + leni += Fchar_bytes (ch); + } + } + else + leni += XFASTINT (len); } XSETFASTINT (len, leni); @@ -490,14 +506,19 @@ while (!INTEGERP (elt)) elt = wrong_type_argument (Qintegerp, elt); { + int c = XINT (elt); + unsigned char work[4], *str; + int i = CHAR_STRING (c, work, str); + #ifdef MASSC_REGISTER_BUG /* Even removing all "register"s doesn't disable this bug! Nothing simpler than this seems to work. */ - unsigned char *p = & XSTRING (val)->data[toindex++]; - *p = XINT (elt); + unsigned char *p = & XSTRING (val)->data[toindex]; + bcopy (str, p, i); #else - XSTRING (val)->data[toindex++] = XINT (elt); + bcopy (str, & XSTRING (val)->data[toindex], i); #endif + toindex += i; } } }