comparison src/fns.c @ 18311:8b716cb12cdd

(concat): Pay attention to multibyte characters when TARGET_TYPE is Lisp_String.
author Kenichi Handa <handa@m17n.org>
date Wed, 18 Jun 1997 13:09:05 +0000
parents af791b0f0657
children 618cc7b75c06
comparison
equal deleted inserted replaced
18310:a97ed8efcb6a 18311:8b716cb12cdd
404 404
405 for (argnum = 0, leni = 0; argnum < nargs; argnum++) 405 for (argnum = 0, leni = 0; argnum < nargs; argnum++)
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);
413 429
414 if (target_type == Lisp_Cons) 430 if (target_type == Lisp_Cons)
488 else 504 else
489 { 505 {
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 }
504 } 525 }
505 if (!NILP (prev)) 526 if (!NILP (prev))