$NetBSD: patch-ak,v 1.5 2005/07/07 12:42:20 markd Exp $ --- term.c.orig 2005-04-15 11:11:36.000000000 +1200 +++ term.c @@ -86,7 +86,10 @@ static char Rcs_Id[] = #include "ispell.h" #include "proto.h" #include "msgs.h" -#ifdef USG +#if defined(__NetBSD__) || defined(linux) || defined(__sgi) || defined(__INTERIX) +#define USE_TERMIOS +#include +#elif defined(USG) #include #else #ifndef __DJGPP__ @@ -165,7 +168,10 @@ static int iputch (c) return putchar (c); } -#ifdef USG +#ifdef USE_TERMIOS +static struct termios sbuf; +static struct termios osbuf; +#elif defined(USG) static struct termio sbuf; static struct termio osbuf; #else @@ -292,8 +298,31 @@ retry: #endif +#ifdef USE_TERMIOS + if (!isatty (0)) + { + (void) fprintf (stderr, TERM_C_NO_BATCH); + exit (1); + } + tcgetattr(0, &osbuf); + termchanged = 1; + + sbuf = osbuf; + sbuf.c_lflag &= ~(ECHO | ECHOK | ECHONL | ICANON); + sbuf.c_oflag &= ~(OPOST); + sbuf.c_iflag &= ~(INLCR | IGNCR | ICRNL); + sbuf.c_lflag |= ISIG; + sbuf.c_cc[VMIN] = 1; + sbuf.c_cc[VTIME] = 0; + tcsetattr(0, TCSANOW, &sbuf); + + uerasechar = osbuf.c_cc[VERASE]; + ukillchar = osbuf.c_cc[VKILL]; + +#endif + #ifdef SIGTSTP -#ifndef USG +#if !(defined(USG) || defined(USE_TERMIOS)) (void) sigsetmask (1<<(SIGTSTP-1) | 1<<(SIGTTIN-1) | 1<<(SIGTTOU-1)); #endif #endif @@ -319,7 +348,7 @@ retry: #endif #endif -#ifndef USG +#if !(defined(USG) || defined(USE_TERMIOS)) (void) ioctl (0, TIOCGETP, (char *) &osbuf); #ifdef TIOCGLTC (void) ioctl (0, TIOCGLTC, (char *) &oltc); @@ -372,7 +401,9 @@ SIGNAL_TYPE done (signo) { if (te) tputs (te, 1, iputch); -#ifdef USG +#ifdef USE_TERMIOS + tcsetattr(0, TCSANOW, &osbuf); +#elif defined(USG) (void) ioctl (0, TCSETAW, (char *) &osbuf); #else (void) ioctl (0, TIOCSETP, (char *) &osbuf); @@ -393,7 +424,9 @@ static SIGNAL_TYPE onstop (signo) imove (li - 1, 0); if (te) tputs (te, 1, iputch); -#ifdef USG +#ifdef USE_TERMIOS + tcsetattr(0, TCSANOW, &osbuf); +#elif defined(USG) (void) ioctl (0, TCSETAW, (char *) &osbuf); #else (void) ioctl (0, TIOCSETP, (char *) &osbuf); @@ -412,7 +445,9 @@ static SIGNAL_TYPE onstop (signo) (void) signal (signo, onstop); if (termchanged) { -#ifdef USG +#ifdef USE_TERMIOS + tcsetattr(0, TCSANOW, &sbuf); +#elif defined(USG) (void) ioctl (0, TCSETAW, (char *) &sbuf); #else (void) ioctl (0, TIOCSETP, (char *) &sbuf); @@ -480,7 +515,9 @@ int shellescape (buf) } argv[i] = NULL; -#ifdef USG +#ifdef USE_TERMIOS + tcsetattr(0, TCSANOW, &osbuf); +#elif defined(USG) (void) ioctl (0, TCSETAW, (char *) &osbuf); #else (void) ioctl (0, TIOCSETP, (char *) &osbuf); @@ -526,7 +563,9 @@ int shellescape (buf) (void) signal (SIGTSTP, onstop); #endif -#ifdef USG +#ifdef USE_TERMIOS + tcsetattr(0, TCSANOW, &sbuf); +#elif defined(USG) (void) ioctl (0, TCSETAW, (char *) &sbuf); #else (void) ioctl (0, TIOCSETP, (char *) &sbuf); @@ -562,7 +601,9 @@ void shescape (buf) char curdir[MAXPATHLEN]; #endif -#ifdef USG +#ifdef USE_TERMIOS + tcsetattr(0, TCSANOW, &osbuf); +#elif defined(USG) (void) ioctl (0, TCSETAW, (char *) &osbuf); #else (void) ioctl (0, TIOCSETP, (char *) &osbuf); @@ -610,7 +651,9 @@ void shescape (buf) chdir (curdir); #endif -#ifdef USG +#ifdef USE_TERMIOS + tcsetattr(0, TCSANOW, &sbuf); +#elif defined(USG) (void) ioctl (0, TCSETAW, (char *) &sbuf); #else (void) ioctl (0, TIOCSETP, (char *) &sbuf);