[gnu.bash.bug] Bash 1.04 patch: termio support

chip@ateng.ateng.com (Chip Salzenberg) (01/23/90)

As distributed, Bash 1.04 picks up the current erase and kill characters from
the tty mode structure -- but only for BSD, not SysV.  This patch adds this
feature for SysV, and also cleans up the ttymode code a little.

Index: readline/readline.c
***************
*** 1035,1060 ****
  readline_default_bindings ()
  {
! #ifdef TIOCGETP
!   struct sgttyb ttybuff;
    int tty = fileno (rl_instream);
  
!   if (ioctl (tty, TIOCGETP, &ttybuff) != -1)
!     {
!       int erase = ttybuff.sg_erase, kill = ttybuff.sg_kill;
  
!       if (erase != -1 && keymap[erase].type == ISFUNC)
! 	keymap[erase].function = rl_rubout;
  
!       if (kill != -1 && keymap[kill].type == ISFUNC)
! 	keymap[kill].function = rl_unix_line_discard;
      }
  
  #ifdef TIOCGLTC
    {
      struct ltchars lt;
  
!     if (ioctl (tty, TIOCGLTC, &lt) != -1)
        {
! 	int erase = lt.t_werasc, nextc = lt.t_lnextc;
  
  	if (erase != -1 && keymap[erase].type == ISFUNC)
--- 1037,1063 ----
  readline_default_bindings ()
  {
!   int erase = -1, kill = -1;
    int tty = fileno (rl_instream);
  
! #ifdef NEW_TTY_DRIVER
  
!   struct sgttyb ttybuff;
  
!   if (ioctl (tty, TIOCGETP, &ttybuff) == 0)
!     {
!       erase = ttybuff.sg_erase;
!       kill = ttybuff.sg_kill;
      }
  
  #ifdef TIOCGLTC
+ 
    {
      struct ltchars lt;
+     int erase, nextc;
  
!     if (ioctl (tty, TIOCGLTC, &lt) == 0)
        {
! 	int erase = lt.t_werasc;
! 	int nextc = lt.t_lnextc;
  
  	if (erase != -1 && keymap[erase].type == ISFUNC)
***************
*** 1065,1070 ****
        }
    }
  #endif /* TIOCGLTC */
! #endif /*  TIOCGETP */
  }
  
--- 1068,1091 ----
        }
    }
+ 
  #endif /* TIOCGLTC */
! 
! #else /* not new driver */
! 
!   struct termio ttyio;
! 
!   if (ioctl (tty, TCGETA, &ttyio) == 0)
!     {
!       erase = ttyio.c_cc[VERASE];
!       kill = ttyio.c_cc[VKILL];
!     }
! 
! #endif  /* not new driver */
! 
!   if (erase != -1 && keymap[erase].type == ISFUNC)
!     keymap[erase].function = rl_rubout;
! 
!   if (kill != -1 && keymap[kill].type == ISFUNC)
!     keymap[kill].function = rl_unix_line_discard;
  }