Merge from trunk.
[bpt/emacs.git] / src / charset.h
index c2a52a3..6d90792 100644 (file)
@@ -148,12 +148,12 @@ struct charset
   int id;
 
   /* Index to Vcharset_hash_table.  */
-  EMACS_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]
@@ -199,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
@@ -341,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));                            \
@@ -401,7 +401,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 +411,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 +420,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 +429,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,7 +437,7 @@ 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))))