From 568dc19750ccec553ab3df463967352da528cd93 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 2 Nov 2010 17:00:56 +0000 Subject: Add a new libc function: cfmakesane(3). I've noticed various terminal emulators that need to obtain a sane default termios structure use very complex `hacks'. Even though POSIX doesn't provide any functionality for this, extend our termios API with cfmakesane(3), which is similar to the commonly supported cfmakeraw(3), except that it fills the termios structure with sane defaults. Change all code in our base system to use this function, instead of depending on to provide TTYDEF_*. --- bin/stty/key.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'bin/stty') diff --git a/bin/stty/key.c b/bin/stty/key.c index 413f4d5..1241301 100644 --- a/bin/stty/key.c +++ b/bin/stty/key.c @@ -257,14 +257,15 @@ f_rows(struct info *ip) void f_sane(struct info *ip) { + struct termios def; - ip->t.c_cflag = TTYDEF_CFLAG | (ip->t.c_cflag & CLOCAL); - ip->t.c_iflag = TTYDEF_IFLAG; - ip->t.c_iflag |= ICRNL; + cfmakesane(&def); + ip->t.c_cflag = def.c_cflag | (ip->t.c_cflag & CLOCAL); + ip->t.c_iflag = def.c_iflag; /* preserve user-preference flags in lflag */ #define LKEEP (ECHOKE|ECHOE|ECHOK|ECHOPRT|ECHOCTL|ALTWERASE|TOSTOP|NOFLSH) - ip->t.c_lflag = TTYDEF_LFLAG | (ip->t.c_lflag & LKEEP); - ip->t.c_oflag = TTYDEF_OFLAG; + ip->t.c_lflag = def.c_lflag | (ip->t.c_lflag & LKEEP); + ip->t.c_oflag = def.c_oflag; ip->set = 1; } -- cgit v1.1