]> code.delx.au - gnu-emacs/blobdiff - src/charset.c
(Text): Replace inforef to emacs-xtra by conditional xref's, depending on
[gnu-emacs] / src / charset.c
index 81708d37b7fce26841205f3fe0f5fcf9c4a1a9e1..211de24ef8972a813fc4054d86510cca901a5e92 100644 (file)
@@ -1,7 +1,9 @@
 /* Basic multilingual character support.
-   Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN.
-   Licensed to the Free Software Foundation.
-   Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005,
+                 2006 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001
+     National Institute of Advanced Industrial Science and Technology (AIST)
+     Registration Number H14PRO021
 
 This file is part of GNU Emacs.
 
@@ -17,8 +19,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 /* At first, see the document in `charset.h' to understand the code in
    this file.  */
@@ -63,6 +65,9 @@ int charset_katakana_jisx0201;        /* JISX0201.Kana (Japanese Katakana) */
 int charset_latin_jisx0201;    /* JISX0201.Roman (Japanese Roman) */
 int charset_big5_1;            /* Big5 Level 1 (Chinese Traditional) */
 int charset_big5_2;            /* Big5 Level 2 (Chinese Traditional) */
+int charset_mule_unicode_0100_24ff;
+int charset_mule_unicode_2500_33ff;
+int charset_mule_unicode_e000_ffff;
 
 Lisp_Object Qcharset_table;
 
@@ -112,7 +117,7 @@ void
 invalid_character (c)
      int c;
 {
-  error ("Invalid character: 0%o, %d, 0x%x", c, c, c);
+  error ("Invalid character: %d, #o%o, #x%x", c, c, c);
 }
 
 /* Parse string STR of length LENGTH and fetch information of a
@@ -1340,6 +1345,10 @@ lisp_string_width (string, precision, nchars, nbytes)
 {
   int len = SCHARS (string);
   int len_byte = SBYTES (string);
+  /* This set multibyte to 0 even if STRING is multibyte when it
+     contains only ascii and eight-bit-graphic, but that's
+     intentional.  */
+  int multibyte = len < len_byte;
   const unsigned char *str = SDATA (string);
   int i = 0, i_byte = 0;
   int width = 0;
@@ -1362,8 +1371,12 @@ lisp_string_width (string, precision, nchars, nbytes)
        }
       else if (dp)
        {
-         int c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes);
+         int c;
 
+         if (multibyte)
+           c = STRING_CHAR_AND_LENGTH (str + i_byte, len - i_byte, bytes);
+         else
+           c = str[i_byte], bytes = 1;
          chars = 1;
          val = DISP_CHAR_VECTOR (dp, c);
          if (VECTORP (val))
@@ -1374,7 +1387,10 @@ lisp_string_width (string, precision, nchars, nbytes)
       else
        {
          chars = 1;
-         PARSE_MULTIBYTE_SEQ (str + i_byte, len_byte - i_byte, bytes);
+         if (multibyte)
+           PARSE_MULTIBYTE_SEQ (str + i_byte, len_byte - i_byte, bytes);
+         else
+           bytes = 1;
          thiswidth = ONE_BYTE_CHAR_WIDTH (str[i_byte]);
        }
 
@@ -1688,6 +1704,12 @@ DEFUN ("setup-special-charsets", Fsetup_special_charsets,
   charset_latin_jisx0201 = charset_id_internal ("latin-jisx0201");
   charset_big5_1 = charset_id_internal ("chinese-big5-1");
   charset_big5_2 = charset_id_internal ("chinese-big5-2");
+  charset_mule_unicode_0100_24ff
+    = charset_id_internal ("mule-unicode-0100-24ff");
+  charset_mule_unicode_2500_33ff
+    = charset_id_internal ("mule-unicode-2500-33ff");
+  charset_mule_unicode_e000_ffff
+    = charset_id_internal ("mule-unicode-e000-ffff");
   return Qnil;
 }
 
@@ -1839,7 +1861,6 @@ syms_of_charset ()
   defsubr (&Schar_width);
   defsubr (&Sstring_width);
   defsubr (&Schar_direction);
-  defsubr (&Schars_in_region);
   defsubr (&Sstring);
   defsubr (&Ssetup_special_charsets);