Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Nov 2000 14:08:45 -0800
From:      Jordan Hubbard <jkh@winston.osd.bsdi.com>
To:        arch@freebsd.org
Cc:        rps@merlin.mat.uc.pt
Subject:   Rui Pedro Mendes Salgueiro: erase2 patch (was: 4.2-RELEASE ISO image for x86 updated.)
Message-ID:  <52694.975362925@winston.osd.bsdi.com>

next in thread | raw e-mail | index | archive | help
I just received this today and am kind of scratching my head over it.
On one hand, creating an "alias" for a one specific piece of terminal
character mapping seems a hack; I can see the idea behind wanting to
use one of n characters for something like backspacing or line-killing
(^U or ^X for example) and would not frown (as much) on a more general
aliasing feature.  On the other hand, I can see that this specific
case (erase) is by far the most significant.  Which is why I'm
forwarding this to arch - this is one of those classic
architecture/feature trade-off decisions and I would like to hear more
opinions before deciding which way I'd like to respond to this.

- Jordan

------- Forwarded Message

Return-Path: rps@merlin.mat.uc.pt
Delivery-Date: Mon Nov 27 12:02:08 2000
Return-Path: <rps@merlin.mat.uc.pt>
Received: from merlin.mat.uc.pt (merlin-f.mat.uc.pt [193.137.206.2])
	by winston.osd.bsdi.com (8.11.1/8.11.1) with ESMTP id eARK25h52306
	for <jkh@winston.osd.bsdi.com>; Mon, 27 Nov 2000 12:02:05 -0800 (PST)
	(envelope-from rps@merlin.mat.uc.pt)
Received: (from rps@localhost)
	by merlin.mat.uc.pt (8.9.3/8.9.0) id UAA06153;
	Mon, 27 Nov 2000 20:01:52 GMT
Message-ID: <20001127200149.05857@merlin.mat.uc.pt>
Date: Mon, 27 Nov 2000 20:01:49 +0000
From: Rui Pedro Mendes Salgueiro <rps@mat.uc.pt>
To: Jordan Hubbard <jkh@winston.osd.bsdi.com>
Subject: erase2 patch (was: 4.2-RELEASE ISO image for x86 updated.)
References: <20001122191141.50422@merlin.mat.uc.pt> <80298.974921931@winston.osd.bsdi.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 0.89.1i
In-Reply-To: <80298.974921931@winston.osd.bsdi.com>; from Jordan Hubbard on Wed, Nov 22, 2000 at 11:38:51AM -0800

I am not sure if you are the proper person to send this:

One thing that has bothered me since a long time ago is the two confliting
standards for the erase character: ^H (backspace) and ^? (del).

Years ago I used a Convex (mini-super-)computer which solved the problem
in an elegant way. stty(1) had an extra option for a erase2 character.
So you could have both usual erase chars working simultaneously.  

Then, around 1993, I reimplemented that in an early version of BSDI (1.0?).
At that time, I also tried other tricks, like a flag to replace each ^H
with an ^? and the reverse, but those interfered with Emacs (which uses ^H).

The next BSDI version lacked the necessary kernel source file due to the ATT
lawsuit, so I could not reimplement it.

Much later I started to reimplement it on FreeBSD, but this is the first
time I managed to get a new release (4.2) before it is obsolete.

dingo# uname -a
FreeBSD dingo.mat.uc.pt 4.2-RELEASE FreeBSD 4.2-RELEASE #0: Mon Nov 27 13:35:57 WET 2000     rps@dingo.mat.uc.pt:/usr/src/sys/compile/GENERIC  i386

dingo# stty -a
[...]
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
[...]

The needed patches are simple:

1 - use a spare slot in the c_cc[] character array. This effects the header
    files "termios.h".

2 - define the default char for it in ttydefaults.h . Also, include it in
    the ttydefchars array.

(these files are in /usr/src/sys/sys and /usr/include/sys/ )

3 - the file tty.c in the kernel (/usr/src/sys/kern) is the one that does
    the real work. The modification there is just adding an OR to the
    relevant "if".

4 - modify stty(1) (/usr/src/bin/stty/cchar.c) so it knows about erase2.
    It is just needed to add the a line to the initialization of cchars1.

5 - document it in the man page (/usr/src/bin/stty/stty.1 ).

Patch follows (paths are realtive to /usr/src )

*** ./bin/stty/cchar.c.orig	Sat Aug 28 00:15:40 1999
- --- ./bin/stty/cchar.c	Mon Nov 27 13:11:33 2000
***************
*** 64,69 ****
- --- 64,70 ----
  	{ "eol",	VEOL,		CEOL },
  	{ "eol2",	VEOL2,		CEOL },
  	{ "erase",	VERASE,		CERASE },
+ 	{ "erase2",	VERASE2,	CERASE2 },
  	{ "intr",	VINTR,		CINTR },
  	{ "kill",	VKILL,		CKILL },
  	{ "lnext",	VLNEXT,		CLNEXT },
*** ./bin/stty/stty.1.orig	Wed Mar  1 10:43:07 2000
- --- ./bin/stty/stty.1	Mon Nov 27 13:20:29 2000
***************
*** 374,379 ****
- --- 374,380 ----
  .It eol Ta Tn VEOL	EOL No character
  .It eol2 Ta Tn VEOL2	EOL2 No character
  .It erase Ta Tn VERASE	ERASE No character
+ .It erase2 Ta Tn VERASE2	ERASE2 No character
  .It werase Ta Tn VWERASE	WERASE No character
  .It intr Ta Tn VINTR	INTR No character
  .It kill Ta Tn VKILL	KILL No character
***************
*** 420,426 ****
  -nl unsets inlcr and igncr.
  .It Cm ek
  Reset
! .Dv ERASE
  and
  .Dv KILL
  characters
- --- 421,428 ----
  -nl unsets inlcr and igncr.
  .It Cm ek
  Reset
! .Dv ERASE ,
! .Dv ERASE2 ,
  and
  .Dv KILL
  characters
*** ./sys/kern/tty.c.orig	Thu Aug  3 01:09:33 2000
- --- ./sys/kern/tty.c	Mon Nov 27 13:26:44 2000
***************
*** 452,460 ****
  		 * processing takes place.
  		 */
  		/*
! 		 * erase (^H / ^?)
  		 */
! 		if (CCEQ(cc[VERASE], c)) {
  			if (tp->t_rawq.c_cc)
  				ttyrub(unputc(&tp->t_rawq), tp);
  			goto endcase;
- --- 452,460 ----
  		 * processing takes place.
  		 */
  		/*
! 		 * erase or erase2 (^H / ^?)
  		 */
! 		if (CCEQ(cc[VERASE], c) || CCEQ(cc[VERASE2], c) ) {
  			if (tp->t_rawq.c_cc)
  				ttyrub(unputc(&tp->t_rawq), tp);
  			goto endcase;
***************
*** 2003,2010 ****
  			(void)ttyoutput('\\', tp);
  		}
  		ttyecho(c, tp);
! 	} else
  		ttyecho(tp->t_cc[VERASE], tp);
  	--tp->t_rocount;
  }
  
- --- 2003,2019 ----
  			(void)ttyoutput('\\', tp);
  		}
  		ttyecho(c, tp);
! 	} else {
  		ttyecho(tp->t_cc[VERASE], tp);
+ 		/*
+ 		 * This code may be executed not only when an ERASE key
+ 		 * is pressed, but also when ^U (KILL) or ^W (WERASE) are.
+ 		 * So, I didn't think it was worthwhile to pass the extra
+ 		 * information (which would need an extra parameter,
+ 		 * changing every call) needed to distinguish the ERASE2
+ 		 * case from the ERASE.
+ 		 */
+ 	}
  	--tp->t_rocount;
  }
  
*** ./sys/sys/termios.h.orig	Wed Dec 29 04:24:48 1999
- --- ./sys/sys/termios.h	Mon Nov 27 13:06:35 2000
***************
*** 56,63 ****
  #define VKILL		5	/* ICANON */
  #ifndef _POSIX_SOURCE
  #define	VREPRINT 	6	/* ICANON together with IEXTEN */
  #endif
! /*			7	   spare 1 */
  #define VINTR		8	/* ISIG */
  #define VQUIT		9	/* ISIG */
  #define VSUSP		10	/* ISIG */
- --- 56,64 ----
  #define VKILL		5	/* ICANON */
  #ifndef _POSIX_SOURCE
  #define	VREPRINT 	6	/* ICANON together with IEXTEN */
+ #define VERASE2 	7	/* ICANON */
  #endif
! /*			7	   ex-spare 1 */
  #define VINTR		8	/* ISIG */
  #define VQUIT		9	/* ISIG */
  #define VSUSP		10	/* ISIG */
*** ./sys/sys/ttydefaults.h.orig	Sat Aug 28 01:52:07 1999
- --- ./sys/sys/ttydefaults.h	Mon Nov 27 13:09:13 2000
***************
*** 61,66 ****
- --- 61,67 ----
  #define	CEOF		CTRL('d')
  #define	CEOL		0xff		/* XXX avoid _POSIX_VDISABLE */
  #define	CERASE		0177
+ #define	CERASE2		CTRL('h')
  #define	CINTR		CTRL('c')
  #define	CSTATUS		CTRL('t')
  #define	CKILL		CTRL('u')
***************
*** 90,96 ****
  #ifdef TTYDEFCHARS
  static cc_t	ttydefchars[NCCS] = {
  	CEOF,	CEOL,	CEOL,	CERASE, CWERASE, CKILL, CREPRINT,
! 	_POSIX_VDISABLE, CINTR,	CQUIT,	CSUSP,	CDSUSP,	CSTART,	CSTOP,	CLNEXT,
  	CDISCARD, CMIN,	CTIME,  CSTATUS, _POSIX_VDISABLE
  };
  #undef TTYDEFCHARS
- --- 91,97 ----
  #ifdef TTYDEFCHARS
  static cc_t	ttydefchars[NCCS] = {
  	CEOF,	CEOL,	CEOL,	CERASE, CWERASE, CKILL, CREPRINT,
! 	CERASE2, CINTR,	CQUIT,	CSUSP,	CDSUSP,	CSTART,	CSTOP,	CLNEXT,
  	CDISCARD, CMIN,	CTIME,  CSTATUS, _POSIX_VDISABLE
  };
  #undef TTYDEFCHARS

------- End of Forwarded Message



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?52694.975362925>