ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RP] get_input problem on Solaris


From: Andreas Voegele
Subject: [RP] get_input problem on Solaris
Date: Thu Oct 30 09:30:03 2003
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

On Solaris 2.8, I get lots of extra characters in the input buffer.
It seems that XLookupString() does not terminate its return buffer
with '\0'.  I use the following fix which modifies cook_keycode() in
input.c:

Index: input.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/input.c,v
retrieving revision 1.37
diff -u -C12 -r1.37 input.c
cvs server: conflicting specifications of output style
*** input.c     31 Aug 2003 06:51:32 -0000      1.37
--- input.c     30 Oct 2003 17:18:14 -0000
***************
*** 233,257 ****
--- 233,262 ----
  int
  cook_keycode (XKeyEvent *ev, KeySym *keysym, unsigned int *mod, char 
*keysym_name, int len, int ignore_bad_mods)
  {
    int nbytes;
   
    if (ignore_bad_mods)
      {
        ev->state &= ~(LockMask
                     | rp_modifier_info.num_lock_mask
                     | rp_modifier_info.scroll_lock_mask);
      }
  
+   if (len > 0)
+     --len;
    nbytes =  XLookupString (ev, keysym_name, len, keysym, NULL);
+   if (keysym_name) {
+     keysym_name[nbytes] = '\0';
+   }
  
    *mod = ev->state;
    *mod &= (rp_modifier_info.meta_mod_mask
           | rp_modifier_info.alt_mod_mask
           | rp_modifier_info.hyper_mod_mask
           | rp_modifier_info.super_mod_mask
           | ControlMask );
  
    return nbytes;
  }
  
  int


Alternatively, the input buffer could be terminated in
get_more_input() only:

char *
get_more_input (char *prompt, char *preinput, 
                completion_fn compl_fn)
{
  [...]
  for (;;)
    {
-->   nbytes = read_key (&ch, &modifier, keysym_buf, keysym_bufsize - 1);
-->   keysym_buf[nbytes] = '\0';
      modifier = x11_mask_to_rp_mask (modifier);
  [...]
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]