Commit 60ad3eab authored by Paul Eggert's avatar Paul Eggert

* 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.
parent 3c7649c1
......@@ -119,6 +119,13 @@
(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.
......
......@@ -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))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment