summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-11-02 17:00:56 +0000
committered <ed@FreeBSD.org>2010-11-02 17:00:56 +0000
commit568dc19750ccec553ab3df463967352da528cd93 (patch)
treef242e644964b102fa1b89235f6f64b8ce56638ed /bin
parent3108c93ec3c2c606e4ec78a5f471565ab55e31a9 (diff)
downloadFreeBSD-src-568dc19750ccec553ab3df463967352da528cd93.zip
FreeBSD-src-568dc19750ccec553ab3df463967352da528cd93.tar.gz
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 <sys/ttydefaults.h> to provide TTYDEF_*.
Diffstat (limited to 'bin')
-rw-r--r--bin/stty/key.c11
1 files changed, 6 insertions, 5 deletions
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;
}
OpenPOWER on IntegriCloud