(load_charset_map): Pass unsigned, not int, as 2nd arg of
INDEX_TO_CODE_POINT, as that's what it expects.
(Funify_charset, encode_char): Don't stuff unsigned vals into int vars.
+ * charset.h (DECODE_CHAR): Return int, not unsigned;
+ this is what was intended anyway, and it avoids undefined behavior.
+ (CHARSET_OFFSET): Remove unused macro, instead of fixing its
+ integer-overflow issues.
+ (ENCODE_CHAR): Return unsigned on all hosts, not just on 32-bit hosts.
+ Formerly, it returned EMACS_INT on 64-bit hosts in the common case
+ where the argument is EMACS_INT, and this behavior is not intended.
* chartab.c (Fmake_char_table, Fset_char_table_range)
(uniprop_get_decoder, uniprop_get_encoder):
Don't assume fixnum fits in int.
? 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 \
: 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.
(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) \
? (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 \
? (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))))