From 60ad3eab6fe6e4278cf7674606357bd8d79c5d68 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 24 Sep 2011 18:27:19 -0700 Subject: * 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. --- src/charset.h | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/charset.h') diff --git a/src/charset.h b/src/charset.h index be02bc0fea..483b7e29f7 100644 --- a/src/charset.h +++ b/src/charset.h @@ -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)))) -- cgit v1.2.3