summaryrefslogtreecommitdiff
path: root/src/charset.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-09-24 18:27:19 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-09-24 18:27:19 -0700
commit60ad3eab6fe6e4278cf7674606357bd8d79c5d68 (patch)
tree83671c0ea602ad101b7203a174dca492336ece5f /src/charset.h
parent3c7649c1859d6252444044fd64c7b27d8e487f68 (diff)
downloademacs-60ad3eab6fe6e4278cf7674606357bd8d79c5d68.tar.gz
* 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.
Diffstat (limited to 'src/charset.h')
-rw-r--r--src/charset.h18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/charset.h b/src/charset.h
index be02bc0feae..483b7e29f7b 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))))