Merge from emacs-24; up to 2012-05-07T14:57:18Z!michael.albinus@gmx.de
[bpt/emacs.git] / src / charset.h
index 98bf35f..50d2304 100644 (file)
@@ -29,6 +29,11 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <verify.h>
 
+INLINE_HEADER_BEGIN
+#ifndef CHARSET_INLINE
+# define CHARSET_INLINE INLINE
+#endif
+
 /* Index to arguments of Fdefine_charset_internal.  */
 
 enum define_charset_arg_index
@@ -168,12 +173,24 @@ struct charset
      check if a code-point is in a valid range.  */
   unsigned char *code_space_mask;
 
-  /* 1 if there's no gap in code-points.  */
-  int code_linear_p;
+  /* True if there's no gap in code-points.  */
+  unsigned code_linear_p : 1;
+
+  /* True if the charset is treated as 96 chars in ISO-2022
+     as opposed to 94 chars.  */
+  unsigned iso_chars_96 : 1;
+
+  /* True if the charset is compatible with ASCII.  */
+  unsigned ascii_compatible_p : 1;
 
-  /* If the charset is treated as 94-chars in ISO-2022, the value is 0.
-     If the charset is treated as 96-chars in ISO-2022, the value is 1.  */
-  int iso_chars_96;
+  /* True if the charset is supplementary.  */
+  unsigned supplementary_p : 1;
+
+  /* True if all the code points are representable by Lisp_Int.  */
+  unsigned compact_codes_p : 1;
+
+  /* True if the charset is unified with Unicode.  */
+  unsigned unified_p : 1;
 
   /* ISO final byte of the charset: 48..127.  It may be -1 if the
      charset doesn't conform to ISO-2022.  */
@@ -187,15 +204,6 @@ struct charset
      version.  Otherwise, -1.  */
   int emacs_mule_id;
 
-  /* Nonzero if the charset is compatible with ASCII.  */
-  int ascii_compatible_p;
-
-  /* Nonzero if the charset is supplementary.  */
-  int supplementary_p;
-
-  /* Nonzero if all the code points are representable by Lisp_Int.  */
-  int compact_codes_p;
-
   /* The method for encoding/decoding characters of the charset.  */
   enum charset_method method;
 
@@ -234,8 +242,6 @@ struct charset
   /* Offset value to calculate a character code from code-point, and
      visa versa.  */
   int code_offset;
-
-  int unified_p;
 };
 
 /* Hash table of charset symbols vs. the corresponding attribute
@@ -325,6 +331,13 @@ extern int emacs_mule_charset[256];
 #define CHARSET_DEUNIFIER(charset)     \
   (CHARSET_ATTR_DEUNIFIER (CHARSET_ATTRIBUTES (charset)))
 
+CHARSET_INLINE void
+set_charset_attr (struct charset *charset, enum charset_attr_index idx,
+                 Lisp_Object val)
+{
+  ASET (CHARSET_ATTRIBUTES (charset), idx, val);
+}
+
 
 /* Nonzero if OBJ is a valid charset symbol.  */
 #define CHARSETP(obj) (CHARSET_SYMBOL_HASH_INDEX (obj) >= 0)
@@ -401,7 +414,7 @@ extern Lisp_Object Vchar_charset_set;
    ? decode_char ((charset), (code))                                   \
    : (charset)->method == CHARSET_METHOD_OFFSET                                \
    ? ((charset)->code_linear_p                                         \
-      ? (code) - (charset)->min_code + (charset)->code_offset          \
+      ? (int) ((code) - (charset)->min_code) + (charset)->code_offset  \
       : decode_char ((charset), (code)))                               \
    : (charset)->method == CHARSET_METHOD_MAP                           \
    ? (((charset)->code_linear_p                                                \
@@ -411,16 +424,6 @@ extern Lisp_Object Vchar_charset_set;
       : decode_char ((charset), (code)))                               \
    : decode_char ((charset), (code)))
 
-
-/* If CHARSET is a simple offset base charset, return it's offset,
-   otherwise return -1.  */
-#define CHARSET_OFFSET(charset)                                \
-  (((charset)->method == CHARSET_METHOD_OFFSET         \
-    && (charset)->code_linear_p                                \
-    && ! (charset)->unified_p)                         \
-   ? (charset)->code_offset - (charset)->min_code      \
-   : -1)
-
 extern Lisp_Object charset_work;
 
 /* Return a code point of CHAR in CHARSET.
@@ -430,7 +433,7 @@ extern Lisp_Object charset_work;
   (verify_expr                                                         \
    (sizeof (c) <= sizeof (int),                                                \
     (ASCII_CHAR_P (c) && (charset)->ascii_compatible_p                 \
-     ? (c)                                                             \
+     ? (unsigned) (c)                                                  \
      : ((charset)->unified_p                                           \
        || (charset)->method == CHARSET_METHOD_SUBSET                   \
        || (charset)->method == CHARSET_METHOD_SUPERSET)                \
@@ -439,7 +442,7 @@ extern Lisp_Object charset_work;
      ? (charset)->invalid_code                                         \
      : (charset)->method == CHARSET_METHOD_OFFSET                      \
      ? ((charset)->code_linear_p                                       \
-       ? (c) - (charset)->code_offset + (charset)->min_code            \
+       ? (unsigned) ((c) - (charset)->code_offset) + (charset)->min_code \
        : encode_char (charset, c))                                     \
      : (charset)->method == CHARSET_METHOD_MAP                         \
      ? (((charset)->compact_codes_p                                    \
@@ -447,14 +450,14 @@ extern Lisp_Object charset_work;
        ? (charset_work = CHAR_TABLE_REF (CHARSET_ENCODER (charset), c), \
           (NILP (charset_work)                                         \
            ? (charset)->invalid_code                                   \
-           : XFASTINT (charset_work)))                                 \
+           : (unsigned) XFASTINT (charset_work)))                      \
        : encode_char (charset, c))                                     \
      : encode_char (charset, c))))
 
 
 /* Set to 1 when a charset map is loaded to warn that a buffer text
    and a string data may be relocated.  */
-extern int charset_map_loaded;
+extern bool charset_map_loaded;
 
 
 /* Set CHARSET to the charset highest priority of C, CODE to the
@@ -472,10 +475,10 @@ extern int charset_map_loaded;
    macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR).  */
 extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
 
-/* A charset of type iso2022 who has DIMENSION, CHARS, and FINAL
+/* A charset of type iso2022 who has DIMENSION, CHARS_96, and FINAL
    (final character).  */
 #define ISO_CHARSET_TABLE(dimension, chars_96, final)  \
-  iso_charset_table[(dimension) - 1][(chars_96)][(final)]
+  iso_charset_table[(dimension) - 1][chars_96][final]
 
 /* Nonzero if the charset who has FAST_MAP may contain C.  */
 #define CHARSET_FAST_MAP_REF(c, fast_map)              \
@@ -493,7 +496,7 @@ extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
 
 
 
-/* 1 if CHARSET may contain the character C.  */
+/* True if CHARSET may contain the character C.  */
 #define CHAR_CHARSET_P(c, charset)                                      \
   ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p)                  \
    || ((CHARSET_UNIFIED_P (charset)                                     \
@@ -544,4 +547,6 @@ extern void map_charset_chars (void (*) (Lisp_Object, Lisp_Object),
                                Lisp_Object, Lisp_Object,
                                struct charset *, unsigned, unsigned);
 
+INLINE_HEADER_END
+
 #endif /* EMACS_CHARSET_H */