diff options
| author | Paul Eggert | 2011-09-24 18:27:19 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-09-24 18:27:19 -0700 |
| commit | 60ad3eab6fe6e4278cf7674606357bd8d79c5d68 (patch) | |
| tree | 83671c0ea602ad101b7203a174dca492336ece5f /src | |
| parent | 3c7649c1859d6252444044fd64c7b27d8e487f68 (diff) | |
| download | emacs-60ad3eab6fe6e4278cf7674606357bd8d79c5d68.tar.gz emacs-60ad3eab6fe6e4278cf7674606357bd8d79c5d68.zip | |
* 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')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/charset.h | 18 |
2 files changed, 11 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 7973cc277e2..2e632bc5ad8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -119,6 +119,13 @@ | |||
| 119 | (load_charset_map): Pass unsigned, not int, as 2nd arg of | 119 | (load_charset_map): Pass unsigned, not int, as 2nd arg of |
| 120 | INDEX_TO_CODE_POINT, as that's what it expects. | 120 | INDEX_TO_CODE_POINT, as that's what it expects. |
| 121 | (Funify_charset, encode_char): Don't stuff unsigned vals into int vars. | 121 | (Funify_charset, encode_char): Don't stuff unsigned vals into int vars. |
| 122 | * charset.h (DECODE_CHAR): Return int, not unsigned; | ||
| 123 | this is what was intended anyway, and it avoids undefined behavior. | ||
| 124 | (CHARSET_OFFSET): Remove unused macro, instead of fixing its | ||
| 125 | integer-overflow issues. | ||
| 126 | (ENCODE_CHAR): Return unsigned on all hosts, not just on 32-bit hosts. | ||
| 127 | Formerly, it returned EMACS_INT on 64-bit hosts in the common case | ||
| 128 | where the argument is EMACS_INT, and this behavior is not intended. | ||
| 122 | * chartab.c (Fmake_char_table, Fset_char_table_range) | 129 | * chartab.c (Fmake_char_table, Fset_char_table_range) |
| 123 | (uniprop_get_decoder, uniprop_get_encoder): | 130 | (uniprop_get_decoder, uniprop_get_encoder): |
| 124 | Don't assume fixnum fits in int. | 131 | Don't assume fixnum fits in int. |
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; | |||
| 401 | ? decode_char ((charset), (code)) \ | 401 | ? decode_char ((charset), (code)) \ |
| 402 | : (charset)->method == CHARSET_METHOD_OFFSET \ | 402 | : (charset)->method == CHARSET_METHOD_OFFSET \ |
| 403 | ? ((charset)->code_linear_p \ | 403 | ? ((charset)->code_linear_p \ |
| 404 | ? (code) - (charset)->min_code + (charset)->code_offset \ | 404 | ? (int) ((code) - (charset)->min_code) + (charset)->code_offset \ |
| 405 | : decode_char ((charset), (code))) \ | 405 | : decode_char ((charset), (code))) \ |
| 406 | : (charset)->method == CHARSET_METHOD_MAP \ | 406 | : (charset)->method == CHARSET_METHOD_MAP \ |
| 407 | ? (((charset)->code_linear_p \ | 407 | ? (((charset)->code_linear_p \ |
| @@ -411,16 +411,6 @@ extern Lisp_Object Vchar_charset_set; | |||
| 411 | : decode_char ((charset), (code))) \ | 411 | : decode_char ((charset), (code))) \ |
| 412 | : decode_char ((charset), (code))) | 412 | : decode_char ((charset), (code))) |
| 413 | 413 | ||
| 414 | |||
| 415 | /* If CHARSET is a simple offset base charset, return it's offset, | ||
| 416 | otherwise return -1. */ | ||
| 417 | #define CHARSET_OFFSET(charset) \ | ||
| 418 | (((charset)->method == CHARSET_METHOD_OFFSET \ | ||
| 419 | && (charset)->code_linear_p \ | ||
| 420 | && ! (charset)->unified_p) \ | ||
| 421 | ? (charset)->code_offset - (charset)->min_code \ | ||
| 422 | : -1) | ||
| 423 | |||
| 424 | extern Lisp_Object charset_work; | 414 | extern Lisp_Object charset_work; |
| 425 | 415 | ||
| 426 | /* Return a code point of CHAR in CHARSET. | 416 | /* Return a code point of CHAR in CHARSET. |
| @@ -430,7 +420,7 @@ extern Lisp_Object charset_work; | |||
| 430 | (verify_expr \ | 420 | (verify_expr \ |
| 431 | (sizeof (c) <= sizeof (int), \ | 421 | (sizeof (c) <= sizeof (int), \ |
| 432 | (ASCII_CHAR_P (c) && (charset)->ascii_compatible_p \ | 422 | (ASCII_CHAR_P (c) && (charset)->ascii_compatible_p \ |
| 433 | ? (c) \ | 423 | ? (unsigned) (c) \ |
| 434 | : ((charset)->unified_p \ | 424 | : ((charset)->unified_p \ |
| 435 | || (charset)->method == CHARSET_METHOD_SUBSET \ | 425 | || (charset)->method == CHARSET_METHOD_SUBSET \ |
| 436 | || (charset)->method == CHARSET_METHOD_SUPERSET) \ | 426 | || (charset)->method == CHARSET_METHOD_SUPERSET) \ |
| @@ -439,7 +429,7 @@ extern Lisp_Object charset_work; | |||
| 439 | ? (charset)->invalid_code \ | 429 | ? (charset)->invalid_code \ |
| 440 | : (charset)->method == CHARSET_METHOD_OFFSET \ | 430 | : (charset)->method == CHARSET_METHOD_OFFSET \ |
| 441 | ? ((charset)->code_linear_p \ | 431 | ? ((charset)->code_linear_p \ |
| 442 | ? (c) - (charset)->code_offset + (charset)->min_code \ | 432 | ? (unsigned) ((c) - (charset)->code_offset) + (charset)->min_code \ |
| 443 | : encode_char (charset, c)) \ | 433 | : encode_char (charset, c)) \ |
| 444 | : (charset)->method == CHARSET_METHOD_MAP \ | 434 | : (charset)->method == CHARSET_METHOD_MAP \ |
| 445 | ? (((charset)->compact_codes_p \ | 435 | ? (((charset)->compact_codes_p \ |
| @@ -447,7 +437,7 @@ extern Lisp_Object charset_work; | |||
| 447 | ? (charset_work = CHAR_TABLE_REF (CHARSET_ENCODER (charset), c), \ | 437 | ? (charset_work = CHAR_TABLE_REF (CHARSET_ENCODER (charset), c), \ |
| 448 | (NILP (charset_work) \ | 438 | (NILP (charset_work) \ |
| 449 | ? (charset)->invalid_code \ | 439 | ? (charset)->invalid_code \ |
| 450 | : XFASTINT (charset_work))) \ | 440 | : (unsigned) XFASTINT (charset_work))) \ |
| 451 | : encode_char (charset, c)) \ | 441 | : encode_char (charset, c)) \ |
| 452 | : encode_char (charset, c)))) | 442 | : encode_char (charset, c)))) |
| 453 | 443 | ||