From d0c037d81d868a35c1c5d0dffefc6324134c7cd3 Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Tue, 25 Jan 2000 21:44:04 +0000 Subject: [PATCH] (Fstring): If there is a multibyte char among the args, always return a multibyte string. --- src/ChangeLog | 5 +++++ src/charset.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index adcfb0089f9..f3a765f5661 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2000-01-25 Gerd Moellmann + + * charset.c (Fstring): If there is a multibyte char among + the args, always return a multibyte string. + 2000-01-25 Gerd Moellmann * sysdep.c (sys_select): Turn atimers off and on instead of diff --git a/src/charset.c b/src/charset.c index 104756ded65..eb930ccf074 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1361,19 +1361,26 @@ DEFUN ("string", Fstring, Sstring, 1, MANY, 0, unsigned char *buf = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH * n); unsigned char *p = buf; Lisp_Object val; - int c; + int c, multibyte_p = 0; for (i = 0; i < n; i++) { - if (!INTEGERP (args[i])) - CHECK_NUMBER (args[i], 0); + CHECK_NUMBER (args[i], 0); c = XINT (args[i]); p += CHAR_STRING (c, p); + + if (!SINGLE_BYTE_CHAR_P (c)) + multibyte_p = 1; } /* Here, we can't use make_string_from_bytes because of byte - combining problem. */ - val = make_string (buf, p - buf); + combining problem. Make a multibyte string if there is any + multibyte character in ARGS to make sure that `(insert 2276)' + returns a multibyte string if running --unibyte. */ + if (multibyte_p) + val = make_multibyte_string (buf, n, p - buf); + else + val = make_unibyte_string (buf, p - buf); return val; } -- 2.39.5