--- correct.c
+++ correct.c	2007-05-31 18:03:19.794187729 +0200
@@ -201,6 +201,7 @@ static char Rcs_Id[] =
  */
 
 #include <ctype.h>
+#include <unistd.h>
 #include "config.h"
 #include "ispell.h"
 #include "proto.h"
--- ispell.h
+++ ispell.h	2007-05-31 18:04:06.795177229 +0200
@@ -143,6 +143,7 @@
 
 #include "config.h"
 #include <stdio.h>
+#include <curses.h>
 
 #ifdef __STDC__
 #define P(x)	x
@@ -575,7 +576,11 @@ extern ichar_t	mytoupper P ((unsigned in
 # define EXTERN extern
 #endif
 
+#ifdef NCURSES_VERSION
+extern char *	BC;	/* backspace if not ^H */
+#else
 EXTERN char *	BC;	/* backspace if not ^H */
+#endif
 EXTERN char *	cd;	/* clear to end of display */
 EXTERN char *	cl;	/* clear display */
 EXTERN char *	cm;	/* cursor movement */
--- term.c
+++ term.c	2007-05-31 18:18:53.861317891 +0200
@@ -87,13 +87,20 @@ static char Rcs_Id[] =
 #include "proto.h"
 #include "msgs.h"
 #ifdef USG
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+#include <termios.h>
+#else
 #include <termio.h>
+#endif
 #else
 #ifndef __DJGPP__
 #include <sgtty.h>
 #endif
 #endif
 #include <signal.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 void		ierase P ((void));
 void		imove P ((int row, int col));
@@ -166,8 +173,13 @@ static int iputch (c)
     }
 
 #ifdef USG
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+static struct termios	sbuf;
+static struct termios	osbuf;
+#else
 static struct termio	sbuf;
 static struct termio	osbuf;
+#endif
 #else
 static struct sgttyb	sbuf;
 static struct sgttyb	osbuf;
@@ -190,9 +202,13 @@ void terminit ()
     int			tpgrp;
 #else
 #ifdef TIOCGPGRP
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+    pid_t		tpgrp;
+#else
     int			tpgrp;
 #endif
 #endif
+#endif
 #ifdef TIOCGWINSZ
     struct winsize	wsize;
 #endif /* TIOCGWINSZ */
@@ -276,7 +292,11 @@ retry:
 	(void) fprintf (stderr, TERM_C_NO_BATCH);
 	exit (1);
 	}
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+    (void) tcgetattr (0, &osbuf);
+#else
     (void) ioctl (0, TCGETA, (char *) &osbuf);
+#endif
     termchanged = 1;
 
     sbuf = osbuf;
@@ -285,7 +305,11 @@ retry:
     sbuf.c_iflag &= ~(INLCR | IGNCR | ICRNL);
     sbuf.c_cc[VMIN] = 1;
     sbuf.c_cc[VTIME] = 1;
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+    (void) tcsetattr (0, TCSADRAIN, &sbuf);
+#else
     (void) ioctl (0, TCSETAW, (char *) &sbuf);
+#endif
 
     uerasechar = osbuf.c_cc[VERASE];
     ukillchar = osbuf.c_cc[VKILL];
@@ -298,7 +322,11 @@ retry:
 #endif
 #endif
 #ifdef TIOCGPGRP
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+    if ((tpgrp = tcgetpgrp (0)) == -1)
+#else
     if (ioctl (0, TIOCGPGRP, (char *) &tpgrp) != 0)
+#endif
 	{
 	(void) fprintf (stderr, TERM_C_NO_BATCH);
 	exit (1);
@@ -373,7 +401,11 @@ SIGNAL_TYPE done (signo)
 	if (te)
 	    tputs (te, 1, iputch);
 #ifdef USG
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+	(void) tcsetattr (0, TCSADRAIN, &osbuf);
+#else
 	(void) ioctl (0, TCSETAW, (char *) &osbuf);
+#endif
 #else
 	(void) ioctl (0, TIOCSETP, (char *) &osbuf);
 #ifdef TIOCSLTC
@@ -394,7 +426,11 @@ static SIGNAL_TYPE onstop (signo)
 	if (te)
 	    tputs (te, 1, iputch);
 #ifdef USG
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+	(void) tcsetattr (0, TCSADRAIN, &osbuf);
+#else
 	(void) ioctl (0, TCSETAW, (char *) &osbuf);
+#endif
 #else
 	(void) ioctl (0, TIOCSETP, (char *) &osbuf);
 #ifdef TIOCSLTC
@@ -413,7 +449,11 @@ static SIGNAL_TYPE onstop (signo)
     if (termchanged)
 	{
 #ifdef USG
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+	(void) tcsetattr (0, TCSADRAIN, &sbuf);
+#else
 	(void) ioctl (0, TCSETAW, (char *) &sbuf);
+#endif
 #else
 	(void) ioctl (0, TIOCSETP, (char *) &sbuf);
 #ifdef TIOCSLTC
@@ -481,7 +521,11 @@ int shellescape	(buf)
     argv[i] = NULL;
 
 #ifdef USG
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+    (void) tcsetattr (0, TCSADRAIN, &osbuf);
+#else
     (void) ioctl (0, TCSETAW, (char *) &osbuf);
+#endif
 #else
     (void) ioctl (0, TIOCSETP, (char *) &osbuf);
 #ifdef TIOCSLTC
@@ -527,7 +571,11 @@ int shellescape	(buf)
 #endif
 
 #ifdef USG
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+    (void) tcsetattr (0, TCSADRAIN, &sbuf);
+#else
     (void) ioctl (0, TCSETAW, (char *) &sbuf);
+#endif
 #else
     (void) ioctl (0, TIOCSETP, (char *) &sbuf);
 #ifdef TIOCSLTC
@@ -563,7 +611,11 @@ void shescape (buf)
 #endif
 
 #ifdef USG
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+    (void) tcsetattr (0, TCSADRAIN, &osbuf);
+#else
     (void) ioctl (0, TCSETAW, (char *) &osbuf);
+#endif
 #else
     (void) ioctl (0, TIOCSETP, (char *) &osbuf);
 #ifdef TIOCSLTC
@@ -611,7 +663,11 @@ void shescape (buf)
 #endif
 
 #ifdef USG
+#if defined(__GLIBC__) && __GLIBC__ >= 2
+    (void) tcsetattr (0, TCSADRAIN, &sbuf);
+#else
     (void) ioctl (0, TCSETAW, (char *) &sbuf);
+#endif
 #else
     (void) ioctl (0, TIOCSETP, (char *) &sbuf);
 #ifdef TIOCSLTC
