From 5235bd3eb16b94dc5dcef3b1447f821fc09ea930 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 11 May 2011 16:16:52 -0700 Subject: [PATCH] * xterm.c: Use EMACS_INT for Emacs modifiers, and int for X modifiers. Before, the code was not consistent. These values cannot exceed 2**31 - 1 so there's no need to make them unsigned. (x_x_to_emacs_modifiers): Accept int and return EMACS_INT. (x_emacs_to_x_modifiers): Accept EMACS_INT and return int. (x_x_to_emacs_modifiers, x_emacs_to_x_modifiers): Reject non-integers as modifiers. * xterm.h (x_x_to_emacs_modifiers): Adjust to signature change. --- src/ChangeLog | 9 +++++++++ src/xterm.c | 40 ++++++++++++++++++++-------------------- src/xterm.h | 3 +-- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 550dd28eb24..da468d47db3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,14 @@ 2011-05-11 Paul Eggert + * xterm.c: Use EMACS_INT for Emacs modifiers, and int for X modifiers. + Before, the code was not consistent. These values cannot exceed + 2**31 - 1 so there's no need to make them unsigned. + (x_x_to_emacs_modifiers): Accept int and return EMACS_INT. + (x_emacs_to_x_modifiers): Accept EMACS_INT and return int. + (x_x_to_emacs_modifiers, x_emacs_to_x_modifiers): Reject non-integers + as modifiers. + * xterm.h (x_x_to_emacs_modifiers): Adjust to signature change. + * lisp.h (XINT) [USE_LISP_UNION_TYPE]: Cast to EMACS_INT. (XUINT) [USE_LISP_UNION_TYPE]: Cast to EMACS_UINT. Otherwise, GCC 4.6.0 warns about printf (pI, XINT (...)), diff --git a/src/xterm.c b/src/xterm.c index 20259b7ab2e..f5886ab9628 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -3609,23 +3609,23 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo) /* Convert between the modifier bits X uses and the modifier bits Emacs uses. */ -unsigned int -x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, unsigned int state) +EMACS_INT +x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, int state) { - EMACS_UINT mod_meta = meta_modifier; - EMACS_UINT mod_alt = alt_modifier; - EMACS_UINT mod_hyper = hyper_modifier; - EMACS_UINT mod_super = super_modifier; + EMACS_INT mod_meta = meta_modifier; + EMACS_INT mod_alt = alt_modifier; + EMACS_INT mod_hyper = hyper_modifier; + EMACS_INT mod_super = super_modifier; Lisp_Object tem; tem = Fget (Vx_alt_keysym, Qmodifier_value); - if (! EQ (tem, Qnil)) mod_alt = XUINT (tem); + if (INTEGERP (tem)) mod_alt = XINT (tem); tem = Fget (Vx_meta_keysym, Qmodifier_value); - if (! EQ (tem, Qnil)) mod_meta = XUINT (tem); + if (INTEGERP (tem)) mod_meta = XINT (tem); tem = Fget (Vx_hyper_keysym, Qmodifier_value); - if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem); + if (INTEGERP (tem)) mod_hyper = XINT (tem); tem = Fget (Vx_super_keysym, Qmodifier_value); - if (! EQ (tem, Qnil)) mod_super = XUINT (tem); + if (INTEGERP (tem)) mod_super = XINT (tem); return ( ((state & (ShiftMask | dpyinfo->shift_lock_mask)) ? shift_modifier : 0) @@ -3636,24 +3636,24 @@ x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, unsigned int state) | ((state & dpyinfo->hyper_mod_mask) ? mod_hyper : 0)); } -static unsigned int -x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, unsigned int state) +static int +x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state) { - EMACS_UINT mod_meta = meta_modifier; - EMACS_UINT mod_alt = alt_modifier; - EMACS_UINT mod_hyper = hyper_modifier; - EMACS_UINT mod_super = super_modifier; + int mod_meta = meta_modifier; + int mod_alt = alt_modifier; + int mod_hyper = hyper_modifier; + int mod_super = super_modifier; Lisp_Object tem; tem = Fget (Vx_alt_keysym, Qmodifier_value); - if (! EQ (tem, Qnil)) mod_alt = XUINT (tem); + if (INTEGERP (tem)) mod_alt = XINT (tem); tem = Fget (Vx_meta_keysym, Qmodifier_value); - if (! EQ (tem, Qnil)) mod_meta = XUINT (tem); + if (INTEGERP (tem)) mod_meta = XINT (tem); tem = Fget (Vx_hyper_keysym, Qmodifier_value); - if (! EQ (tem, Qnil)) mod_hyper = XUINT (tem); + if (INTEGERP (tem)) mod_hyper = XINT (tem); tem = Fget (Vx_super_keysym, Qmodifier_value); - if (! EQ (tem, Qnil)) mod_super = XUINT (tem); + if (INTEGERP (tem)) mod_super = XINT (tem); return ( ((state & mod_alt) ? dpyinfo->alt_mod_mask : 0) diff --git a/src/xterm.h b/src/xterm.h index fbd638fe73b..1b90b6d8ff4 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -989,8 +989,7 @@ extern void x_mouse_leave (struct x_display_info *); #ifdef USE_X_TOOLKIT extern int x_dispatch_event (XEvent *, Display *); #endif -extern unsigned int x_x_to_emacs_modifiers (struct x_display_info *, - unsigned); +extern EMACS_INT x_x_to_emacs_modifiers (struct x_display_info *, int); extern int x_display_pixel_height (struct x_display_info *); extern int x_display_pixel_width (struct x_display_info *); -- 2.39.2