Module Name: src Committed By: christos Date: Mon Aug 29 11:07:38 UTC 2011
Modified Files: src/lib/libcurses: tstp.c tty.c Log Message: Fix for systems that don't have TCSASOFT as intended originally. Simplify. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/lib/libcurses/tstp.c cvs rdiff -u -r1.42 -r1.43 src/lib/libcurses/tty.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libcurses/tstp.c diff -u src/lib/libcurses/tstp.c:1.38 src/lib/libcurses/tstp.c:1.39 --- src/lib/libcurses/tstp.c:1.38 Wed Feb 3 10:34:40 2010 +++ src/lib/libcurses/tstp.c Mon Aug 29 07:07:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tstp.c,v 1.38 2010/02/03 15:34:40 roy Exp $ */ +/* $NetBSD: tstp.c,v 1.39 2011/08/29 11:07:38 christos Exp $ */ /* * Copyright (c) 1981, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)tstp.c 8.3 (Berkeley) 5/4/94"; #else -__RCSID("$NetBSD: tstp.c,v 1.38 2010/02/03 15:34:40 roy Exp $"); +__RCSID("$NetBSD: tstp.c,v 1.39 2011/08/29 11:07:38 christos Exp $"); #endif #endif /* not lint */ @@ -55,6 +55,9 @@ __P((int)) = SIG_DFL; static struct sigaction owsa; +#ifndef TCSASOFT +#define TCSASOFT 0 +#endif /* * stop_signal_handler -- @@ -243,9 +246,8 @@ _cursesi_screen->endwin = 1; - return (tcsetattr(fileno(_cursesi_screen->infd), - __tcaction ? TCSASOFT | TCSADRAIN : TCSADRAIN, - &_cursesi_screen->orig_termios) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + &_cursesi_screen->orig_termios) ? ERR : OK; } @@ -299,9 +301,8 @@ &_cursesi_screen->orig_termios); /* Reset the terminal state to the mode just before we stopped. */ - (void) tcsetattr(fileno(_cursesi_screen->infd), - __tcaction ? TCSASOFT | TCSADRAIN : TCSADRAIN, - &_cursesi_screen->save_termios); + (void) tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + &_cursesi_screen->save_termios); /* Restore colours */ __restore_colors(); @@ -325,28 +326,27 @@ if (_cursesi_screen->endwin) return ERR; - return (tcgetattr(fileno(_cursesi_screen->infd), - &_cursesi_screen->save_termios) ? ERR : OK); + return tcgetattr(fileno(_cursesi_screen->infd), + &_cursesi_screen->save_termios) ? ERR : OK; } int reset_prog_mode(void) { - return tcsetattr(fileno(_cursesi_screen->infd), - __tcaction ? TCSASOFT | TCSADRAIN : TCSADRAIN, - &_cursesi_screen->save_termios) ? ERR : OK; + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + &_cursesi_screen->save_termios) ? ERR : OK; } int def_shell_mode(void) { - return (tcgetattr(fileno(_cursesi_screen->infd), - &_cursesi_screen->orig_termios) ? ERR : OK); + return tcgetattr(fileno(_cursesi_screen->infd), + &_cursesi_screen->orig_termios) ? ERR : OK; } int reset_shell_mode(void) { - return (__stopwin()); + return __stopwin(); } Index: src/lib/libcurses/tty.c diff -u src/lib/libcurses/tty.c:1.42 src/lib/libcurses/tty.c:1.43 --- src/lib/libcurses/tty.c:1.42 Wed Feb 3 10:34:40 2010 +++ src/lib/libcurses/tty.c Mon Aug 29 07:07:38 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: tty.c,v 1.42 2010/02/03 15:34:40 roy Exp $ */ +/* $NetBSD: tty.c,v 1.43 2011/08/29 11:07:38 christos Exp $ */ /*- * Copyright (c) 1992, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)tty.c 8.6 (Berkeley) 1/10/95"; #else -__RCSID("$NetBSD: tty.c,v 1.42 2010/02/03 15:34:40 roy Exp $"); +__RCSID("$NetBSD: tty.c,v 1.43 2011/08/29 11:07:38 christos Exp $"); #endif #endif /* not lint */ @@ -56,12 +56,12 @@ * those attributes at each change, or at least when stopped and restarted. * See also the comments in getterm(). */ -#ifdef TCSASOFT -int __tcaction = 1; /* Ignore hardware settings. */ -#else -int __tcaction = 0; +#ifndef TCSASOFT +#define TCSASOFT 0 #endif +int __tcaction = TCSASOFT != 0; /* Ignore hardware settings */ + #ifndef OXTABS #ifdef XTABS /* SMI uses XTABS. */ #define OXTABS XTABS @@ -115,7 +115,7 @@ screen->notty = TRUE; __GT = 0; __NONL = 0; - return (OK); + return OK; } } @@ -143,6 +143,7 @@ screen->rawt.c_oflag &= ~OPOST; screen->rawt.c_lflag &= ~(ISIG | IEXTEN); +#if TCSASOFT == 0 /* * In general, curses should leave hardware-related settings alone. * This includes parity and word size. Older versions set the tty @@ -151,15 +152,14 @@ * parity and word size, the TCSASOFT bit has to be removed from the * calls that switch to/from "raw" mode. */ - if (!__tcaction) { - screen->rawt.c_iflag &= ~ISTRIP; - screen->rawt.c_cflag &= ~(CSIZE | PARENB); - screen->rawt.c_cflag |= CS8; - } + screen->rawt.c_iflag &= ~ISTRIP; + screen->rawt.c_cflag &= ~(CSIZE | PARENB); + screen->rawt.c_cflag |= CS8; +#endif screen->curt = &screen->baset; - return (tcsetattr(fileno(screen->infd), __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, screen->curt) ? ERR : OK); + return tcsetattr(fileno(screen->infd), TCSASOFT | TCSADRAIN, + screen->curt) ? ERR : OK; } /* @@ -180,9 +180,8 @@ _cursesi_screen->curt = &_cursesi_screen->rawt; if (_cursesi_screen->notty == TRUE) return OK; - return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, - _cursesi_screen->curt) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + _cursesi_screen->curt) ? ERR : OK; } /* @@ -203,9 +202,8 @@ if (_cursesi_screen->notty == TRUE) return OK; _cursesi_screen->curt = &_cursesi_screen->baset; - return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, - _cursesi_screen->curt) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + _cursesi_screen->curt) ? ERR : OK; } /* @@ -227,9 +225,8 @@ return OK; _cursesi_screen->curt = _cursesi_screen->useraw ? &_cursesi_screen->rawt : &_cursesi_screen->cbreakt; - return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, - _cursesi_screen->curt) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + _cursesi_screen->curt) ? ERR : OK; } /* @@ -257,9 +254,8 @@ _cursesi_screen->half_delay = FALSE; _cursesi_screen->curt = _cursesi_screen->useraw ? &_cursesi_screen->rawt : &_cursesi_screen->baset; - return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, - _cursesi_screen->curt) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + _cursesi_screen->curt) ? ERR : OK; } /* @@ -302,8 +298,8 @@ _cursesi_screen->baset.c_cc[VMIN] = 1; _cursesi_screen->baset.c_cc[VTIME] = 0; - if (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT : TCSANOW, _cursesi_screen->curt)) { + if (tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSANOW, + _cursesi_screen->curt)) { __restore_termios(); return ERR; } @@ -330,8 +326,8 @@ _cursesi_screen->baset.c_cc[VMIN] = 0; _cursesi_screen->baset.c_cc[VTIME] = 0; - if (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT : TCSANOW, _cursesi_screen->curt)) { + if (tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSANOW, + _cursesi_screen->curt)) { __restore_termios(); return ERR; } @@ -390,9 +386,8 @@ _cursesi_screen->baset.c_cc[VMIN] = 0; _cursesi_screen->baset.c_cc[VTIME] = delay; - if (tcsetattr(fileno(_cursesi_screen->infd), - __tcaction ? TCSASOFT | TCSANOW : TCSANOW, - _cursesi_screen->curt)) { + if (tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSANOW, + _cursesi_screen->curt)) { __restore_termios(); return ERR; } @@ -419,9 +414,8 @@ _cursesi_screen->baset.c_cc[VMIN] = 1; _cursesi_screen->baset.c_cc[VTIME] = 0; - return (tcsetattr(fileno(_cursesi_screen->infd), - __tcaction ? TCSASOFT | TCSANOW : TCSANOW, - _cursesi_screen->curt) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSANOW, + _cursesi_screen->curt) ? ERR : OK; } int @@ -435,7 +429,7 @@ __restartwin(); __echoit = 1; - return (OK); + return OK; } int @@ -449,7 +443,7 @@ __restartwin(); __echoit = 0; - return (OK); + return OK; } int @@ -473,9 +467,8 @@ _cursesi_screen->nl = 1; _cursesi_screen->pfast = _cursesi_screen->rawmode; - return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, - _cursesi_screen->curt) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + _cursesi_screen->curt) ? ERR : OK; } int @@ -499,9 +492,8 @@ _cursesi_screen->nl = 0; __pfast = 1; - return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, - _cursesi_screen->curt) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + _cursesi_screen->curt) ? ERR : OK; } #ifndef _CURSES_USE_MACROS @@ -538,9 +530,8 @@ } __pfast = 1; - return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, - _cursesi_screen->curt) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + _cursesi_screen->curt) ? ERR : OK; } void @@ -587,14 +578,14 @@ bool isendwin(void) { - return (_cursesi_screen->endwin ? TRUE : FALSE); + return _cursesi_screen->endwin ? TRUE : FALSE; } int flushinp(void) { (void) fpurge(_cursesi_screen->infd); - return (OK); + return OK; } /* @@ -608,8 +599,8 @@ { if (_cursesi_screen->notty == TRUE) return OK; - return (tcgetattr(fileno(_cursesi_screen->infd), - &_cursesi_screen->savedtty) ? ERR : OK); + return tcgetattr(fileno(_cursesi_screen->infd), + &_cursesi_screen->savedtty) ? ERR : OK; } int @@ -617,9 +608,8 @@ { if (_cursesi_screen->notty == TRUE) return OK; - return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ? - TCSASOFT | TCSADRAIN : TCSADRAIN, - &_cursesi_screen->savedtty) ? ERR : OK); + return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN, + &_cursesi_screen->savedtty) ? ERR : OK; } /*