aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1997-06-18 13:09:05 +0000
committerKenichi Handa1997-06-18 13:09:05 +0000
commit5b6dddaac2774bfa81e6d07328205c264ffcc22c (patch)
tree3ba2d7fe67cfd038a54b0a37946202a02ec63cdf /src
parent765a2ca545241008efc95cb47b68424c765d3b8b (diff)
downloademacs-5b6dddaac2774bfa81e6d07328205c264ffcc22c.tar.gz
emacs-5b6dddaac2774bfa81e6d07328205c264ffcc22c.zip
(concat): Pay attention to multibyte characters when
TARGET_TYPE is Lisp_String.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/fns.c b/src/fns.c
index 24c737141cc..d8f51afbde0 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -406,7 +406,23 @@ concat (nargs, args, target_type, last_special)
406 { 406 {
407 this = args[argnum]; 407 this = args[argnum];
408 len = Flength (this); 408 len = Flength (this);
409 leni += XFASTINT (len); 409 if (VECTORP (this) && target_type == Lisp_String)
410 {
411 /* We must pay attention to a multibyte character which
412 takes more than one byte in string. */
413 int i;
414 Lisp_Object ch;
415
416 for (i = 0; i < XFASTINT (len); i++)
417 {
418 ch = XVECTOR (this)->contents[i];
419 if (! INTEGERP (ch))
420 wrong_type_argument (Qintegerp, ch);
421 leni += Fchar_bytes (ch);
422 }
423 }
424 else
425 leni += XFASTINT (len);
410 } 426 }
411 427
412 XSETFASTINT (len, leni); 428 XSETFASTINT (len, leni);
@@ -490,14 +506,19 @@ concat (nargs, args, target_type, last_special)
490 while (!INTEGERP (elt)) 506 while (!INTEGERP (elt))
491 elt = wrong_type_argument (Qintegerp, elt); 507 elt = wrong_type_argument (Qintegerp, elt);
492 { 508 {
509 int c = XINT (elt);
510 unsigned char work[4], *str;
511 int i = CHAR_STRING (c, work, str);
512
493#ifdef MASSC_REGISTER_BUG 513#ifdef MASSC_REGISTER_BUG
494 /* Even removing all "register"s doesn't disable this bug! 514 /* Even removing all "register"s doesn't disable this bug!
495 Nothing simpler than this seems to work. */ 515 Nothing simpler than this seems to work. */
496 unsigned char *p = & XSTRING (val)->data[toindex++]; 516 unsigned char *p = & XSTRING (val)->data[toindex];
497 *p = XINT (elt); 517 bcopy (str, p, i);
498#else 518#else
499 XSTRING (val)->data[toindex++] = XINT (elt); 519 bcopy (str, & XSTRING (val)->data[toindex], i);
500#endif 520#endif
521 toindex += i;
501 } 522 }
502 } 523 }
503 } 524 }