This is for reasons similar to the recent CHAR_STRING fix.
* charset.c (Fencode_char): Check that character arg is actually
a character. Pass an int to ENCODE_CHAR.
* charset.h (ENCODE_CHAR): Verify that the character argument is no
wider than 'int', as a compile-time check to prevent future regressions
in this area.
2011-06-13 Paul Eggert <eggert@cs.ucla.edu>
+ Make sure a 64-bit char is never passed to ENCODE_CHAR.
+ This is for reasons similar to the recent CHAR_STRING fix.
+ * charset.c (Fencode_char): Check that character arg is actually
+ a character. Pass an int to ENCODE_CHAR.
+ * charset.h (ENCODE_CHAR): Verify that the character argument is no
+ wider than 'int', as a compile-time check to prevent future regressions
+ in this area.
+
* character.c (char_string): Remove unnecessary casts.
Make sure a 64-bit char is never passed to CHAR_STRING.
code-point in CCS. Currently not supported and just ignored. */)
(Lisp_Object ch, Lisp_Object charset, Lisp_Object restriction)
{
- int id;
+ int c, id;
unsigned code;
struct charset *charsetp;
CHECK_CHARSET_GET_ID (charset, id);
- CHECK_NATNUM (ch);
+ CHECK_CHARACTER (ch);
+ c = XFASTINT (ch);
charsetp = CHARSET_FROM_ID (id);
- code = ENCODE_CHAR (charsetp, XINT (ch));
+ code = ENCODE_CHAR (charsetp, c);
if (code == CHARSET_INVALID_CODE (charsetp))
return Qnil;
return INTEGER_TO_CONS (code);
#ifndef EMACS_CHARSET_H
#define EMACS_CHARSET_H
+#include <verify.h>
+
/* Index to arguments of Fdefine_charset_internal. */
enum define_charset_arg_index
#define ENCODE_CHAR(charset, c) \
((ASCII_CHAR_P (c) && (charset)->ascii_compatible_p) \
? (c) \
- : ((charset)->unified_p \
+ : (!verify_true (sizeof (c) <= sizeof (int)) \
+ || (charset)->unified_p \
|| (charset)->method == CHARSET_METHOD_SUBSET \
|| (charset)->method == CHARSET_METHOD_SUPERSET) \
? encode_char ((charset), (c)) \