]> code.delx.au - gnu-emacs/blobdiff - src/charset.c
(print_error_message): Print data of `end-of-file'
[gnu-emacs] / src / charset.c
index 302f243ad5afb3cc995f29402f08a074e08d68ba..52ba5f28c5f0160e44c8f4fe25fcd4e45471ab9f 100644 (file)
@@ -773,7 +773,7 @@ find_charset_in_str (str, len, charsets, table, multibyte)
      Lisp_Object table;
      int multibyte;
 {
-  register int num = 0, c;
+  register int num = 0;
 
   if (! multibyte)
     {
@@ -808,7 +808,7 @@ find_charset_in_str (str, len, charsets, table, multibyte)
        {
          int c1 = translate_char (table, -1, charset, c1, c2);
          if (c1 >= 0)
-           charset = CHAR_CHARSET (c);
+           charset = CHAR_CHARSET (c1);
        }
 
       if (!charsets[charset])
@@ -961,8 +961,8 @@ DEFUN ("make-char-internal", Fmake_char_internal, Smake_char_internal, 1, 3, 0,
   if (c1 == 0
       ? c2 != 0
       : (c2 == 0
-        ? !CHAR_COMPONENTS_VALID_P (charset, c1, 0x20)
-        : !CHAR_COMPONENTS_VALID_P (charset, c1, c2)))
+        ? !CHAR_COMPONENTS_VALID_P (charset_id, c1, 0x20)
+        : !CHAR_COMPONENTS_VALID_P (charset_id, c1, c2)))
     error ("Invalid code points for charset ID %d: %d %d", charset_id, c1, c2);
 
   return make_number (MAKE_CHAR (charset_id, c1, c2));
@@ -1161,7 +1161,7 @@ char_bytes (c)
 {
   int charset;
 
-  if (SINGLE_BYTE_CHAR_P (c) || (c & ~GLYPH_MASK_CHAR))
+  if (SINGLE_BYTE_CHAR_P (c) || (c & ~((1 << CHARACTERBITS) - 1)))
     return 1;
 
   charset = CHAR_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);
+  /* Here, we can't use make_string_from_bytes because of the byte
+     combining problem.  Make a multibyte string if there is any
+     multibyte character in ARGS to make sure that `(string 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;
 }