From ccd9a01aa7b67dd3d71b49e3c30df04dd39b4cae Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 31 May 2011 19:49:12 -0700 Subject: [PATCH] Minor fixes for signed vs unsigned integers. * character.h (MAYBE_UNIFY_CHAR): * charset.c (maybe_unify_char): * keyboard.c (read_char, reorder_modifiers): XINT -> XFASTINT, since the integer must be nonnegative. * ftfont.c (ftfont_spec_pattern): * keymap.c (access_keymap, silly_event_symbol_error): XUINT -> XFASTINT, since the integer must be nonnegative. (Fsingle_key_description, preferred_sequence_p): XUINT -> XINT, since it makes no difference and we prefer signed. * keyboard.c (record_char): Use XUINT when all the neighbors do. (access_keymap): NATNUMP -> INTEGERP, since the integer must be nonnegative. --- src/ChangeLog | 16 ++++++++++++++++ src/character.h | 2 +- src/charset.c | 4 ++-- src/ftfont.c | 2 +- src/keyboard.c | 8 ++++---- src/keymap.c | 14 +++++++------- 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index fa8022b0d4..4a9e651e4d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,19 @@ +2011-06-01 Paul Eggert + + Minor fixes for signed vs unsigned integers. + * character.h (MAYBE_UNIFY_CHAR): + * charset.c (maybe_unify_char): + * keyboard.c (read_char, reorder_modifiers): + XINT -> XFASTINT, since the integer must be nonnegative. + * ftfont.c (ftfont_spec_pattern): + * keymap.c (access_keymap, silly_event_symbol_error): + XUINT -> XFASTINT, since the integer must be nonnegative. + (Fsingle_key_description, preferred_sequence_p): XUINT -> XINT, + since it makes no difference and we prefer signed. + * keyboard.c (record_char): Use XUINT when all the neighbors do. + (access_keymap): NATNUMP -> INTEGERP, since the integer must be + nonnegative. + 2011-05-31 Paul Eggert Use 'inline', not 'INLINE'. diff --git a/src/character.h b/src/character.h index 31e3b0a941..884833775d 100644 --- a/src/character.h +++ b/src/character.h @@ -544,7 +544,7 @@ along with GNU Emacs. If not, see . */ Lisp_Object val; \ val = CHAR_TABLE_REF (Vchar_unify_table, c); \ if (INTEGERP (val)) \ - c = XINT (val); \ + c = XFASTINT (val); \ else if (! NILP (val)) \ c = maybe_unify_char (c, val); \ } \ diff --git a/src/charset.c b/src/charset.c index b1b4993d27..5423cd3216 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1637,7 +1637,7 @@ maybe_unify_char (int c, Lisp_Object val) struct charset *charset; if (INTEGERP (val)) - return XINT (val); + return XFASTINT (val); if (NILP (val)) return c; @@ -1647,7 +1647,7 @@ maybe_unify_char (int c, Lisp_Object val) { val = CHAR_TABLE_REF (Vchar_unify_table, c); if (! NILP (val)) - c = XINT (val); + c = XFASTINT (val); } else { diff --git a/src/ftfont.c b/src/ftfont.c index 47425e853d..cd8829a3e5 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -815,7 +815,7 @@ ftfont_spec_pattern (Lisp_Object spec, char *otlayout, struct OpenTypeSpec **ots goto err; for (chars = XCDR (chars); CONSP (chars); chars = XCDR (chars)) if (CHARACTERP (XCAR (chars)) - && ! FcCharSetAddChar (charset, XUINT (XCAR (chars)))) + && ! FcCharSetAddChar (charset, XFASTINT (XCAR (chars)))) goto err; } } diff --git a/src/keyboard.c b/src/keyboard.c index 7bc406aab3..179557080c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2395,8 +2395,8 @@ read_char (int commandflag, int nmaps, Lisp_Object *maps, Lisp_Object prev_event c = Faref (Vexecuting_kbd_macro, make_number (executing_kbd_macro_index)); if (STRINGP (Vexecuting_kbd_macro) - && (XINT (c) & 0x80) && (XUINT (c) <= 0xff)) - XSETFASTINT (c, CHAR_META | (XINT (c) & ~0x80)); + && (XFASTINT (c) & 0x80) && (XFASTINT (c) <= 0xff)) + XSETFASTINT (c, CHAR_META | (XFASTINT (c) & ~0x80)); executing_kbd_macro_index++; @@ -3321,7 +3321,7 @@ record_char (Lisp_Object c) if (INTEGERP (c)) { if (XUINT (c) < 0x100) - putc (XINT (c), dribble); + putc (XUINT (c), dribble); else fprintf (dribble, " 0x%"pI"x", XUINT (c)); } @@ -6370,7 +6370,7 @@ reorder_modifiers (Lisp_Object symbol) Lisp_Object parsed; parsed = parse_modifiers (symbol); - return apply_modifiers ((int) XINT (XCAR (XCDR (parsed))), + return apply_modifiers (XFASTINT (XCAR (XCDR (parsed))), XCAR (parsed)); } diff --git a/src/keymap.c b/src/keymap.c index 79481833bd..6ef2a716b6 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -462,7 +462,7 @@ access_keymap (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int au XSETFASTINT (idx, XINT (idx) & (CHAR_META | (CHAR_META - 1))); /* Handle the special meta -> esc mapping. */ - if (INTEGERP (idx) && XUINT (idx) & meta_modifier) + if (INTEGERP (idx) && XFASTINT (idx) & meta_modifier) { /* See if there is a meta-map. If there's none, there is no binding for IDX, unless a default binding exists in MAP. */ @@ -480,7 +480,7 @@ access_keymap (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int au if (CONSP (event_meta_map)) { map = event_meta_map; - idx = make_number (XUINT (idx) & ~meta_modifier); + idx = make_number (XFASTINT (idx) & ~meta_modifier); } else if (t_ok) /* Set IDX to t, so that we only find a default binding. */ @@ -529,7 +529,7 @@ access_keymap (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int au } else if (VECTORP (binding)) { - if (NATNUMP (idx) && XFASTINT (idx) < ASIZE (binding)) + if (INTEGERP (idx) && XFASTINT (idx) < ASIZE (binding)) val = AREF (binding, XFASTINT (idx)); } else if (CHAR_TABLE_P (binding)) @@ -537,7 +537,7 @@ access_keymap (Lisp_Object map, Lisp_Object idx, int t_ok, int noinherit, int au /* Character codes with modifiers are not included in a char-table. All character codes without modifiers are included. */ - if (NATNUMP (idx) && (XFASTINT (idx) & CHAR_MODIFIER_MASK) == 0) + if (INTEGERP (idx) && (XFASTINT (idx) & CHAR_MODIFIER_MASK) == 0) { val = Faref (binding, idx); /* `nil' has a special meaning for char-tables, so @@ -1357,7 +1357,7 @@ silly_event_symbol_error (Lisp_Object c) int modifiers; parsed = parse_modifiers (c); - modifiers = (int) XUINT (XCAR (XCDR (parsed))); + modifiers = XFASTINT (XCAR (XCDR (parsed))); base = XCAR (parsed); name = Fsymbol_name (base); /* This alist includes elements such as ("RET" . "\\r"). */ @@ -2416,7 +2416,7 @@ around function keys and event symbols. */) { char tem[KEY_DESCRIPTION_SIZE]; - *push_key_description (XUINT (key), tem, 1) = 0; + *push_key_description (XINT (key), tem, 1) = 0; return build_string (tem); } else if (SYMBOLP (key)) /* Function key or event-symbol */ @@ -2515,7 +2515,7 @@ preferred_sequence_p (Lisp_Object seq) return 0; else { - int modifiers = XUINT (elt) & (CHAR_MODIFIER_MASK & ~CHAR_META); + int modifiers = XINT (elt) & (CHAR_MODIFIER_MASK & ~CHAR_META); if (modifiers == where_is_preferred_modifier) result = 2; else if (modifiers) -- 2.20.1