From: Richard M. Stallman Date: Fri, 6 Mar 1998 21:50:44 +0000 (+0000) Subject: (Fmake_string): Handle the case INIT is a multibyte character correctly. X-Git-Tag: emacs-20.3~1990 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e54daa22b060568e8d8e1b07eee3ed6905c3279c;p=emacs.git (Fmake_string): Handle the case INIT is a multibyte character correctly. --- diff --git a/src/alloc.c b/src/alloc.c index fa5a3461fd7..5ae44416943 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. */ #include "frame.h" #include "blockinput.h" #include "keyboard.h" +#include "charset.h" #endif #include "syssignal.h" @@ -1186,16 +1187,37 @@ Both LENGTH and INIT must be numbers.") Lisp_Object length, init; { register Lisp_Object val; - register unsigned char *p, *end, c; + register unsigned char *p, *end; + int c, nbytes; CHECK_NATNUM (length, 0); CHECK_NUMBER (init, 1); - val = make_uninit_string (XFASTINT (length)); + c = XINT (init); - p = XSTRING (val)->data; - end = p + XSTRING (val)->size; - while (p != end) - *p++ = c; + if (SINGLE_BYTE_CHAR_P (c)) + { + nbytes = XINT (length); + val = make_uninit_multibyte_string (nbytes, nbytes); + p = XSTRING (val)->data; + end = p + XSTRING (val)->size; + while (p != end) + *p++ = c; + } + else + { + unsigned char work[4], *str; + int len = CHAR_STRING (c, work, str); + + nbytes = len * XINT (length); + val = make_uninit_multibyte_string (XINT (length), nbytes); + p = XSTRING (val)->data; + end = p + nbytes; + while (p != end) + { + bcopy (str, p, len); + p += len; + } + } *p = 0; return val; }