Fix decoding of emacs-mule coding system.
[bpt/emacs.git] / src / charset.h
index 6d34a5f..7afe654 100644 (file)
@@ -1,8 +1,8 @@
 /* Header for charset handler.
    Copyright (C) 2001, 2002, 2003, 2004, 2005,
 /* Header for charset handler.
    Copyright (C) 2001, 2002, 2003, 2004, 2005,
-                 2006, 2007 Free Software Foundation, Inc.
+                 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-     2005, 2006, 2007
+     2005, 2006, 2007, 2008, 2009, 2010
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H14PRO021
 
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H14PRO021
 
 
 This file is part of GNU Emacs.
 
 
 This file is part of GNU Emacs.
 
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,9 +23,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 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., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef EMACS_CHARSET_H
 #define EMACS_CHARSET_H
 
 #ifndef EMACS_CHARSET_H
 #define EMACS_CHARSET_H
@@ -68,9 +66,9 @@ enum charset_attr_index
     /* Property list of the charset.  */
     charset_plist,
 
     /* Property list of the charset.  */
     charset_plist,
 
-    /* If the method of the charset is `MAP_DEFERRED', the value is a
-       mapping vector or a file name that contains mapping vector.
-       Otherwise, nil.  */
+    /* If the method of the charset is `MAP', the value is a mapping
+       vector or a file name that contains mapping vector.  Otherwise,
+       nil.  */
     charset_map,
 
     /* If the method of the charset is `MAP', the value is a vector
     charset_map,
 
     /* If the method of the charset is `MAP', the value is a vector
@@ -102,9 +100,9 @@ enum charset_attr_index
 
        (CHARSET-ID . OFFSET)
 
 
        (CHARSET-ID . OFFSET)
 
-      CHARSET-IDs are ID numbers of parent charsets.  OFFSET is an
-      integer value to add to a code point of the parent charset to
-      get the corresponding code point of this charset.  */
+       CHARSET-IDs are ID numbers of parent charsets.  OFFSET is an
+       integer value to add to a code point of the parent charset to
+       get the corresponding code point of this charset.  */
     charset_superset,
 
     /* The value is a mapping vector or a file name that contains the
     charset_superset,
 
     /* The value is a mapping vector or a file name that contains the
@@ -136,11 +134,6 @@ enum charset_method
        conversion.  */
     CHARSET_METHOD_MAP,
 
        conversion.  */
     CHARSET_METHOD_MAP,
 
-    /* Same as above but decoder and encoder are loaded from a file on
-       demand.  Once loaded, the method is changed to
-       CHARSET_METHOD_MAP.  */
-    CHARSET_METHOD_MAP_DEFERRED,
-
     /* A charset of this method is a subset of another charset.  */
     CHARSET_METHOD_SUBSET,
 
     /* A charset of this method is a subset of another charset.  */
     CHARSET_METHOD_SUBSET,
 
@@ -253,6 +246,7 @@ extern struct charset *charset_table;
 #define CHARSET_FROM_ID(id) (charset_table + (id))
 
 extern Lisp_Object Vcharset_ordered_list;
 #define CHARSET_FROM_ID(id) (charset_table + (id))
 
 extern Lisp_Object Vcharset_ordered_list;
+extern Lisp_Object Vcharset_non_preferred_head;
 
 /* Incremented everytime we change the priority of charsets.  */
 extern unsigned short charset_ordered_list_tick;
 
 /* Incremented everytime we change the priority of charsets.  */
 extern unsigned short charset_ordered_list_tick;
@@ -261,8 +255,9 @@ extern Lisp_Object Vcharset_list;
 extern Lisp_Object Viso_2022_charset_list;
 extern Lisp_Object Vemacs_mule_charset_list;
 
 extern Lisp_Object Viso_2022_charset_list;
 extern Lisp_Object Vemacs_mule_charset_list;
 
-extern struct charset *emacs_mule_charset[256];
+extern int emacs_mule_charset[256];
 
 
+extern Lisp_Object Vcurrent_iso639_language;
 
 /* Macros to access information about charset.  */
 
 
 /* Macros to access information about charset.  */
 
@@ -339,7 +334,7 @@ extern struct charset *emacs_mule_charset[256];
 #define CHECK_CHARSET(x)                                       \
   do {                                                         \
     if (! SYMBOLP (x) || CHARSET_SYMBOL_HASH_INDEX (x) < 0)    \
 #define CHECK_CHARSET(x)                                       \
   do {                                                         \
     if (! SYMBOLP (x) || CHARSET_SYMBOL_HASH_INDEX (x) < 0)    \
-      x = wrong_type_argument (Qcharsetp, (x));                        \
+      wrong_type_argument (Qcharsetp, (x));                    \
   } while (0)
 
 
   } while (0)
 
 
@@ -350,7 +345,7 @@ extern struct charset *emacs_mule_charset[256];
     int idx;                                                           \
                                                                        \
     if (! SYMBOLP (x) || (idx = CHARSET_SYMBOL_HASH_INDEX (x)) < 0)    \
     int idx;                                                           \
                                                                        \
     if (! SYMBOLP (x) || (idx = CHARSET_SYMBOL_HASH_INDEX (x)) < 0)    \
-      x = wrong_type_argument (Qcharsetp, (x));                                \
+      wrong_type_argument (Qcharsetp, (x));                            \
     id = XINT (AREF (HASH_VALUE (XHASH_TABLE (Vcharset_hash_table), idx), \
                     charset_id));                                      \
   } while (0)
     id = XINT (AREF (HASH_VALUE (XHASH_TABLE (Vcharset_hash_table), idx), \
                     charset_id));                                      \
   } while (0)
@@ -361,7 +356,7 @@ extern struct charset *emacs_mule_charset[256];
 #define CHECK_CHARSET_GET_ATTR(x, attr)                                \
   do {                                                                 \
     if (!SYMBOLP (x) || NILP (attr = CHARSET_SYMBOL_ATTRIBUTES (x)))   \
 #define CHECK_CHARSET_GET_ATTR(x, attr)                                \
   do {                                                                 \
     if (!SYMBOLP (x) || NILP (attr = CHARSET_SYMBOL_ATTRIBUTES (x)))   \
-      x = wrong_type_argument (Qcharsetp, (x));                                \
+      wrong_type_argument (Qcharsetp, (x));                            \
   } while (0)
 
 
   } while (0)
 
 
@@ -373,7 +368,7 @@ extern struct charset *emacs_mule_charset[256];
   } while (0)
 
 
   } while (0)
 
 
-/* Lookup Vcharset_order_list and return the first charset that
+/* Lookup Vcharset_ordered_list and return the first charset that
    contains the character C.  */
 #define CHAR_CHARSET(c)                                \
   ((c) < 0x80 ? CHARSET_FROM_ID (charset_ascii)        \
    contains the character C.  */
 #define CHAR_CHARSET(c)                                \
   ((c) < 0x80 ? CHARSET_FROM_ID (charset_ascii)        \
@@ -410,9 +405,10 @@ extern Lisp_Object Vchar_charset_set;
       ? (code) - (charset)->min_code + (charset)->code_offset          \
       : decode_char ((charset), (code)))                               \
    : (charset)->method == CHARSET_METHOD_MAP                           \
       ? (code) - (charset)->min_code + (charset)->code_offset          \
       : decode_char ((charset), (code)))                               \
    : (charset)->method == CHARSET_METHOD_MAP                           \
-   ? ((charset)->code_linear_p                                         \
+   ? (((charset)->code_linear_p                                                \
+       && VECTORP (CHARSET_DECODER (charset)))                         \
       ? XINT (AREF (CHARSET_DECODER (charset),                         \
       ? XINT (AREF (CHARSET_DECODER (charset),                         \
-                       (code) - (charset)->min_code))                  \
+                   (code) - (charset)->min_code))                      \
       : decode_char ((charset), (code)))                               \
    : decode_char ((charset), (code)))
 
       : decode_char ((charset), (code)))                               \
    : decode_char ((charset), (code)))
 
@@ -445,7 +441,8 @@ extern Lisp_Object charset_work;
       ? (c) - (charset)->code_offset + (charset)->min_code              \
       : encode_char ((charset), (c)))                                   \
    : (charset)->method == CHARSET_METHOD_MAP                            \
       ? (c) - (charset)->code_offset + (charset)->min_code              \
       : encode_char ((charset), (c)))                                   \
    : (charset)->method == CHARSET_METHOD_MAP                            \
-   ? ((charset)->compact_codes_p                                        \
+   ? (((charset)->compact_codes_p                                       \
+       && CHAR_TABLE_P (CHARSET_ENCODER (charset)))                     \
       ? (charset_work = CHAR_TABLE_REF (CHARSET_ENCODER (charset), (c)), \
         (NILP (charset_work)                                            \
          ? (charset)->invalid_code                                      \
       ? (charset_work = CHAR_TABLE_REF (CHARSET_ENCODER (charset), (c)), \
         (NILP (charset_work)                                            \
          ? (charset)->invalid_code                                      \
@@ -506,7 +503,8 @@ extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
          && ((charset)->method == CHARSET_METHOD_OFFSET                 \
              ? (c) >= (charset)->min_char && (c) <= (charset)->max_char \
              : ((charset)->method == CHARSET_METHOD_MAP                 \
          && ((charset)->method == CHARSET_METHOD_OFFSET                 \
              ? (c) >= (charset)->min_char && (c) <= (charset)->max_char \
              : ((charset)->method == CHARSET_METHOD_MAP                 \
-                && (charset)->compact_codes_p)                          \
+                && (charset)->compact_codes_p                           \
+                && CHAR_TABLE_P (CHARSET_ENCODER (charset)))            \
              ? ! NILP (CHAR_TABLE_REF (CHARSET_ENCODER (charset), (c))) \
              : encode_char ((charset), (c)) != (charset)->invalid_code))))
 
              ? ! NILP (CHAR_TABLE_REF (CHARSET_ENCODER (charset), (c))) \
              : encode_char ((charset), (c)) != (charset)->invalid_code))))
 
@@ -519,8 +517,6 @@ extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
 #define EMACS_MULE_LEADING_CODE_PRIVATE_21     0x9C /* 2/2 */
 #define EMACS_MULE_LEADING_CODE_PRIVATE_22     0x9D /* 2/2 */
 
 #define EMACS_MULE_LEADING_CODE_PRIVATE_21     0x9C /* 2/2 */
 #define EMACS_MULE_LEADING_CODE_PRIVATE_22     0x9D /* 2/2 */
 
-extern struct charset *emacs_mule_charset[256];
-
 \f
 
 extern Lisp_Object Qcharsetp;
 \f
 
 extern Lisp_Object Qcharsetp;
@@ -532,12 +528,14 @@ extern int charset_unicode;
 extern int charset_jisx0201_roman;
 extern int charset_jisx0208_1978;
 extern int charset_jisx0208;
 extern int charset_jisx0201_roman;
 extern int charset_jisx0208_1978;
 extern int charset_jisx0208;
+extern int charset_ksc5601;
 
 extern int charset_unibyte;
 
 extern struct charset *char_charset P_ ((int, Lisp_Object, unsigned *));
 extern Lisp_Object charset_attributes P_ ((int));
 
 
 extern int charset_unibyte;
 
 extern struct charset *char_charset P_ ((int, Lisp_Object, unsigned *));
 extern Lisp_Object charset_attributes P_ ((int));
 
+extern int maybe_unify_char P_ ((int, Lisp_Object));
 extern int decode_char P_ ((struct charset *, unsigned));
 extern unsigned encode_char P_ ((struct charset *, int));
 extern int string_xstring_p P_ ((Lisp_Object));
 extern int decode_char P_ ((struct charset *, unsigned));
 extern unsigned encode_char P_ ((struct charset *, int));
 extern int string_xstring_p P_ ((Lisp_Object));