]> code.delx.au - gnu-emacs/commitdiff
(Fstring): If there is a multibyte char among
authorGerd Moellmann <gerd@gnu.org>
Tue, 25 Jan 2000 21:44:04 +0000 (21:44 +0000)
committerGerd Moellmann <gerd@gnu.org>
Tue, 25 Jan 2000 21:44:04 +0000 (21:44 +0000)
the args, always return a multibyte string.

src/ChangeLog
src/charset.c

index adcfb0089f942d099ae6cd1d801c064b38365a71..f3a765f5661e7a9fb1a784746655ed9fc61f8da2 100644 (file)
@@ -1,3 +1,8 @@
+2000-01-25  Gerd Moellmann  <gerd@gnu.org>
+
+       * charset.c (Fstring): If there is a multibyte char among
+       the args, always return a multibyte string.
+
 2000-01-25  Gerd Moellmann  <gerd@gnu.org>
 
        * sysdep.c (sys_select): Turn atimers off and on instead of
index 104756ded651efbb713d9d89697eff893f11c73f..eb930ccf074d05f43cf8ed2860101e723e2fb0c1 100644 (file)
@@ -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;
 }