Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libcurses Fix for systems that don't have TCSASOFT as in...



details:   https://anonhg.NetBSD.org/src/rev/85f54d153d58
branches:  trunk
changeset: 768925:85f54d153d58
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Aug 29 11:07:38 2011 +0000

description:
Fix for systems that don't have TCSASOFT as intended originally. Simplify.

diffstat:

 lib/libcurses/tstp.c |  32 ++++++++--------
 lib/libcurses/tty.c  |  98 +++++++++++++++++++++++----------------------------
 2 files changed, 60 insertions(+), 70 deletions(-)

diffs (truncated from 350 to 300 lines):

diff -r 4d5e29fa73a9 -r 85f54d153d58 lib/libcurses/tstp.c
--- a/lib/libcurses/tstp.c      Mon Aug 29 10:48:57 2011 +0000
+++ b/lib/libcurses/tstp.c      Mon Aug 29 11:07:38 2011 +0000
@@ -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();
 }
diff -r 4d5e29fa73a9 -r 85f54d153d58 lib/libcurses/tty.c
--- a/lib/libcurses/tty.c       Mon Aug 29 10:48:57 2011 +0000
+++ b/lib/libcurses/tty.c       Mon Aug 29 11:07:38 2011 +0000
@@ -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 @@
        }



Home | Main Index | Thread Index | Old Index