aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2011-06-12 16:25:12 -0700
committerPaul Eggert2011-06-12 16:25:12 -0700
commitea204efb8a3e81a4d9b04d2a36cb8c2a1c74662c (patch)
treeb209feeebf1bdb6994f46217e29ba860dcc6c7ba /src/lisp.h
parent78cf1fe8a256ffc91533b43eb851bf4519e9fbcc (diff)
downloademacs-ea204efb8a3e81a4d9b04d2a36cb8c2a1c74662c.tar.gz
emacs-ea204efb8a3e81a4d9b04d2a36cb8c2a1c74662c.zip
* lisp.h (UNSIGNED_CMP): New macro.
This fixes comparison bugs on 64-bit hosts. (ASCII_CHAR_P): Use it. * casefiddle.c (casify_object): * character.h (ASCII_BYTE_P, CHAR_VALID_P): (SINGLE_BYTE_CHAR_P, CHAR_STRING): * composite.h (COMPOSITION_ENCODE_RULE_VALID): * dispextern.h (FACE_FROM_ID): * keyboard.c (read_char): Use UNSIGNED_CMP.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 6003daee8fa..4dfed319490 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -911,8 +911,18 @@ struct Lisp_Vector
911 911
912#endif /* not __GNUC__ */ 912#endif /* not __GNUC__ */
913 913
914/* Compute A OP B, using the unsigned comparison operator OP. A and B
915 should be integer expressions. This is not the same as
916 mathemeatical comparison; for example, UNSIGNED_CMP (0, <, -1)
917 returns 1. For efficiency, prefer plain unsigned comparison if A
918 and B's sizes both fit (after integer promotion). */
919#define UNSIGNED_CMP(a, op, b) \
920 (max (sizeof ((a) + 0), sizeof ((b) + 0)) <= sizeof (unsigned) \
921 ? ((a) + (unsigned) 0) op ((b) + (unsigned) 0) \
922 : ((a) + (uintmax_t) 0) op ((b) + (uintmax_t) 0))
923
914/* Nonzero iff C is an ASCII character. */ 924/* Nonzero iff C is an ASCII character. */
915#define ASCII_CHAR_P(c) ((unsigned) (c) < 0x80) 925#define ASCII_CHAR_P(c) UNSIGNED_CMP (c, <, 0x80)
916 926
917/* Almost equivalent to Faref (CT, IDX) with optimization for ASCII 927/* Almost equivalent to Faref (CT, IDX) with optimization for ASCII
918 characters. Do not check validity of CT. */ 928 characters. Do not check validity of CT. */