Commit e54daa22 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(Fmake_string): Handle the case INIT is a multibyte character correctly.

parent 846f93fd
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment