Don't call r_alloc_inhibit_buffer_relocation from search.c.
[bpt/emacs.git] / src / charset.h
index 8c87ffe..98bf35f 100644 (file)
@@ -1,5 +1,5 @@
 /* Header for charset handler.
-   Copyright (C) 2001-2011 Free Software Foundation, Inc.
+   Copyright (C) 2001-2012 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
      2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
@@ -27,6 +27,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #ifndef EMACS_CHARSET_H
 #define EMACS_CHARSET_H
 
+#include <verify.h>
+
 /* Index to arguments of Fdefine_charset_internal.  */
 
 enum define_charset_arg_index
@@ -146,19 +148,20 @@ struct charset
   int id;
 
   /* Index to Vcharset_hash_table.  */
-  int hash_index;
+  ptrdiff_t hash_index;
 
   /* Dimension of the charset: 1, 2, 3, or 4.  */
   int dimension;
 
-  /* Byte code range of each dimension.  <code_space>[4N] is a mininum
+  /* Byte code range of each dimension.  <code_space>[4N] is a minimum
      byte code of the (N+1)th dimension, <code_space>[4N+1] is a
      maximum byte code of the (N+1)th dimension, <code_space>[4N+2] is
      (<code_space>[4N+1] - <code_space>[4N] + 1), <code_space>[4N+3]
-     is a number of characters containd in the first to (N+1)th
-     dismesions.  We get `char-index' of a `code-point' from this
+     is the number of characters contained in the first through (N+1)th
+     dimensions, except that there is no <code_space>[15].
+     We get `char-index' of a `code-point' from this
      information.  */
-  int code_space[16];
+  int code_space[15];
 
   /* If B is a byte of Nth dimension of a code-point, the (N-1)th bit
      of code_space_mask[B] is set.  This array is used to quickly
@@ -196,14 +199,14 @@ struct charset
   /* The method for encoding/decoding characters of the charset.  */
   enum charset_method method;
 
-  /* Mininum and Maximum code points of the charset.  */
+  /* Minimum and Maximum code points of the charset.  */
   unsigned min_code, max_code;
 
   /* Offset value used by macros CODE_POINT_TO_INDEX and
       INDEX_TO_CODE_POINT. .  */
   unsigned char_index_offset;
 
-  /* Mininum and Maximum character codes of the charset.  If the
+  /* Minimum and Maximum character codes of the charset.  If the
      charset is compatible with ASCII, min_char is a minimum non-ASCII
      character of the charset.  If the method of charset is
      CHARSET_METHOD_OFFSET, even if the charset is unified, min_char
@@ -235,7 +238,7 @@ struct charset
   int unified_p;
 };
 
-/* Hash table of charset symbols vs. the correponding attribute
+/* Hash table of charset symbols vs. the corresponding attribute
    vectors.  */
 extern Lisp_Object Vcharset_hash_table;
 
@@ -338,7 +341,7 @@ extern int emacs_mule_charset[256];
    number of the charset.  Otherwise, signal an error. */
 #define CHECK_CHARSET_GET_ID(x, id)                                    \
   do {                                                                 \
-    int idx;                                                           \
+    ptrdiff_t idx;                                                     \
                                                                        \
     if (! SYMBOLP (x) || (idx = CHARSET_SYMBOL_HASH_INDEX (x)) < 0)    \
       wrong_type_argument (Qcharsetp, (x));                            \
@@ -386,7 +389,7 @@ extern Lisp_Object Vchar_charset_set;
 #endif
 
 
-/* Return a character correponding to the code-point CODE of CHARSET.
+/* Return a character corresponding to the code-point CODE of CHARSET.
    Try some optimization before calling decode_char.  */
 
 #define DECODE_CHAR(charset, code)                                     \
@@ -423,28 +426,30 @@ extern Lisp_Object charset_work;
 /* Return a code point of CHAR in CHARSET.
    Try some optimization before calling encode_char.  */
 
-#define ENCODE_CHAR(charset, c)                                                 \
-  ((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p)                  \
-   ? (c)                                                                \
-   : ((charset)->unified_p                                              \
-      || (charset)->method == CHARSET_METHOD_SUBSET                     \
-      || (charset)->method == CHARSET_METHOD_SUPERSET)                  \
-   ? encode_char ((charset), (c))                                       \
-   : ((c) < (charset)->min_char || (c) > (charset)->max_char)           \
-   ? (charset)->invalid_code                                            \
-   : (charset)->method == CHARSET_METHOD_OFFSET                                 \
-   ? ((charset)->code_linear_p                                          \
-      ? (c) - (charset)->code_offset + (charset)->min_code              \
-      : encode_char ((charset), (c)))                                   \
-   : (charset)->method == CHARSET_METHOD_MAP                            \
-   ? (((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                                      \
-         : XFASTINT (charset_work)))                                    \
-      : encode_char ((charset), (c)))                                   \
-   : encode_char ((charset), (c)))
+#define ENCODE_CHAR(charset, c)                                                \
+  (verify_expr                                                         \
+   (sizeof (c) <= sizeof (int),                                                \
+    (ASCII_CHAR_P (c) && (charset)->ascii_compatible_p                 \
+     ? (c)                                                             \
+     : ((charset)->unified_p                                           \
+       || (charset)->method == CHARSET_METHOD_SUBSET                   \
+       || (charset)->method == CHARSET_METHOD_SUPERSET)                \
+     ? encode_char (charset, c)                                                \
+     : (c) < (charset)->min_char || (c) > (charset)->max_char          \
+     ? (charset)->invalid_code                                         \
+     : (charset)->method == CHARSET_METHOD_OFFSET                      \
+     ? ((charset)->code_linear_p                                       \
+       ? (c) - (charset)->code_offset + (charset)->min_code            \
+       : encode_char (charset, c))                                     \
+     : (charset)->method == CHARSET_METHOD_MAP                         \
+     ? (((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                                   \
+           : 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
@@ -517,9 +522,8 @@ extern int iso_charset_table[ISO_MAX_DIMENSION][ISO_MAX_CHARS][ISO_MAX_FINAL];
 
 extern Lisp_Object Qcharsetp;
 
-extern Lisp_Object Qascii, Qunicode;
+extern Lisp_Object Qascii;
 extern int charset_ascii, charset_eight_bit;
-extern int charset_iso_8859_1;
 extern int charset_unicode;
 extern int charset_jisx0201_roman;
 extern int charset_jisx0208_1978;