File curses-bsd4.4-linux.patch of Package termcap

Index: ChangeLog
===================================================================
--- /dev/null
+++ ChangeLog
@@ -0,0 +1,19 @@
+Fri Nov 18 20:11:55 1994  J. Alan Eldridge (alane@wozzle.linet.org)
+ 
+	 * curses-bsd4.4/newwin.c (__set_subwin): fix
+	   "olp" and "lp->line". Please test it.
+
+Wed Aug 31 17:05:00 1994  H.J. Lu (hlu@fudan)
+
+	* curses.c: initialize all uninitialized variables to 0 or
+	  NULL.
+
+	* curses.h: include <features.h>.
+	  include <termcap.h>. remove termcap function declarations.
+	  remove <sys/cdefs.h>.
+	  remove <compat.h>.
+	  (__BEGIN_DECLS/__END_DECLS): added.
+
+	* printw.c (vwprintw): don't use funopen () for Linux.
+
+	* tty.c (__tcaction): set it to 1 only if TCSASOFT != 0.
Index: Makefile
===================================================================
--- Makefile.orig
+++ Makefile
@@ -1,33 +1,91 @@
-#	$OpenBSD: Makefile,v 1.7 1998/12/02 15:45:43 espie Exp $
+#
+# This is Makefile of curses for Linux
+#
+
+prefix	=	/usr
+lib	=	lib
+LIBNAME =	libcurses
+
+MAJOR	=	1
+MINOR	=	0
+RELEASE	=	0
+SHLIB	=	$(LIBNAME).so.$(MAJOR).$(MINOR).$(RELEASE)
+SONAME	=	$(LIBNAME).so.$(MAJOR)
+STLIB	=	$(LIBNAME).a
+
+TOPDIR	=	..
+TARGETS =	$(SHLIB) $(STLIB)
+TERMCAP	=	$(TOPDIR)/termcap-2.0.8/
+
+INC_CFLAGS	=-I. -I$(TERMCAP)
+BASE_CFLAGS	=-Wall $(RPM_OPT_FLAGS) -pipe -include nowarn.h
+CURSES_CFLAGS	=-DPOSIX -D__USE_BSD_SIGNAL -D_CURSES_PRIVATE -D_GNU_SOURCE
+CFLAGS		=$(BASE_CFLAGS) $(CURSES_CFLAGS) $(INC_CFLAGS)
+CC		=gcc
+AR		=ar
+ARFLAGS		=ucvr
+LN		=ln
+INSTALL		=install
 
-CFLAGS+=#-DTFILE=\"/dev/ttyp0\"
-CFLAGS+=-D_CURSES_PRIVATE -I${.CURDIR}
-CFLAGS+=-DCM_N -DCM_GT -DCM_B -DCM_D
-LIB=	ocurses
 SRCS=	addbytes.c addch.c addnstr.c box.c clear.c clrtobot.c clrtoeol.c \
 	cr_put.c ctrace.c cur_hash.c curses.c delch.c deleteln.c delwin.c \
 	erase.c fullname.c getch.c getstr.c id_subwins.c idlok.c initscr.c \
 	insch.c insertln.c longname.c move.c mvwin.c newwin.c overlay.c \
 	overwrite.c printw.c putchar.c refresh.c scanw.c scroll.c setterm.c \
 	standout.c toucholap.c touchwin.c tscroll.c tstp.c tty.c unctrl.c
-SRCS+=	termcap.c tgoto.c tputs.c
-MAN=	ocurses.3 otermcap.3
+#
+# We use an other termcap library
+#
+#SRCS+=	termcap.c tgoto.c tputs.c
+
+OBJS=	$(SRCS:.c=.o)
+SOBJS= 	$(SRCS:%.c=pic/%.o)
+
+#
+# The people should use ncurses
+#
+#MAN=	ocurses.3 otermcap.3
+MAN=
+
+.c.o:
+	$(CC) $(CFLAGS) -c $<
+
+pic/%.o: %.c
+	$(CC) $(CFLAGS) -fPIC -c $< -o $@
+
+all lib: pic .depend $(SHLIB) $(STLIB) $(TERMCAP)/libtermcap.so
+
+$(SHLIB):: pic
+$(SHLIB):: $(SOBJS)
+	$(CC) -shared -o $@ -Wl,-soname,$(SONAME) $^ -Wl,-rpath-link,$(TERMCAP) -L$(TERMCAP) -ltermcap
+
+$(STLIB): $(OBJS)
+	$(AR) $(ARFLAGS) $@ $(OBJS)
+
+pic:
+	-if [ ! -d pic ]; then mkdir pic; fi
+
+install:
+	$(INSTALL) -d $(prefix)/include/curses
+	$(INSTALL) -d $(prefix)/$(lib)/curses
+	$(INSTALL) $(SHLIB)	$(prefix)/$(lib)/
+	$(INSTALL) curses.h	$(prefix)/include/curses/
+	$(LN) -sf  $(SHLIB)	$(prefix)/$(lib)/$(SONAME)
+	$(LN) -sf  ../$(SHLIB)	$(prefix)/$(lib)/curses/$(LIBNAME).so
+	$(INSTALL) $(STLIB)	$(prefix)/$(lib)/curses/
+
+clean:
+	rm -rf *.o pic $(SHLIB) $(SOBJS)
+
+distclean: clean
+	-rm -f .depend
+
+depend:: .depend
 
-.if make(install)
-SUBDIR+= PSD.doc
-.endif
-
-includes:
-	-cd ${.CURDIR}; cmp -s curses.h ${DESTDIR}/usr/include/ocurses.h || \
-	    ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
-	    curses.h ${DESTDIR}/usr/include/ocurses.h
-
-# Link libotermcap to libocurses for programs that need full compatibility
-# with the old termcap behavior
-afterinstall:
-	-cd ${DESTDIR}/usr/lib; \
-	for i in ${_LIBS}; do \
-	    ln -f $$i `echo $$i | sed 's/ocurses/otermcap/'`; \
-	done
+.depend: $(SRCS)
+	$(CC) $(CFLAGS) -M $(SRCS) | \
+	sed -e 's,^[	 ]*\(.*\.o\)[	 ]*:,\1 pic/\1:,' > .depend
 
-.include <bsd.lib.mk>
+ifeq (.depend,$(wildcard .depend))
+include .depend
+endif
Index: Makefile.bsd-4.4
===================================================================
--- /dev/null
+++ Makefile.bsd-4.4
@@ -0,0 +1,33 @@
+#	$OpenBSD: Makefile,v 1.7 1998/12/02 15:45:43 espie Exp $
+
+CFLAGS+=#-DTFILE=\"/dev/ttyp0\"
+CFLAGS+=-D_CURSES_PRIVATE -I${.CURDIR}
+CFLAGS+=-DCM_N -DCM_GT -DCM_B -DCM_D
+LIB=	ocurses
+SRCS=	addbytes.c addch.c addnstr.c box.c clear.c clrtobot.c clrtoeol.c \
+	cr_put.c ctrace.c cur_hash.c curses.c delch.c deleteln.c delwin.c \
+	erase.c fullname.c getch.c getstr.c id_subwins.c idlok.c initscr.c \
+	insch.c insertln.c longname.c move.c mvwin.c newwin.c overlay.c \
+	overwrite.c printw.c putchar.c refresh.c scanw.c scroll.c setterm.c \
+	standout.c toucholap.c touchwin.c tscroll.c tstp.c tty.c unctrl.c
+SRCS+=	termcap.c tgoto.c tputs.c
+MAN=	ocurses.3 otermcap.3
+
+.if make(install)
+SUBDIR+= PSD.doc
+.endif
+
+includes:
+	-cd ${.CURDIR}; cmp -s curses.h ${DESTDIR}/usr/include/ocurses.h || \
+	    ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 444 \
+	    curses.h ${DESTDIR}/usr/include/ocurses.h
+
+# Link libotermcap to libocurses for programs that need full compatibility
+# with the old termcap behavior
+afterinstall:
+	-cd ${DESTDIR}/usr/lib; \
+	for i in ${_LIBS}; do \
+	    ln -f $$i `echo $$i | sed 's/ocurses/otermcap/'`; \
+	done
+
+.include <bsd.lib.mk>
Index: clrtobot.c
===================================================================
--- clrtobot.c.orig
+++ clrtobot.c
@@ -46,7 +46,7 @@ wclrtobot(win)
 	register WINDOW *win;
 {
 	register int minx, startx, starty, y;
-	register __LDATA *sp, *end, *maxx;
+	register __LDATA *sp, *end, *maxx = NULL;
 
 	if (win->lines[win->cury]->flags & __ISPASTEOL) {
 		starty = win->cury + 1;
@@ -66,7 +66,7 @@ wclrtobot(win)
 				sp->ch = ' ';
 				sp->attr = 0;
 			}
-		if (minx != -1)
+		if (maxx && minx != -1)
 			__touchline(win, y, minx, maxx - win->lines[y]->line,
 		            0);
 		startx = 0;
Index: cr_put.c
===================================================================
--- cr_put.c.orig
+++ cr_put.c
@@ -102,12 +102,12 @@ fgoto(in_refresh)
 			while (l > 0) {
 				if (__pfast) {
 					if (CR)
-						tputs(CR, 0, __cputchar);
+						tputs(CR, 0, (int (*)(int))__cputchar);
 					else
 						putchar('\r');
 				}
 				if (NL)
-					tputs(NL, 0, __cputchar);
+					tputs(NL, 0, (int (*)(int))__cputchar);
 				else
 					putchar('\n');
 				l--;
@@ -148,7 +148,7 @@ fgoto(in_refresh)
 			 * Eggert's Superbee description which wins better.
 			 */
 			if (NL /* && !XB */ && __pfast)
-				tputs(NL, 0, __cputchar);
+				tputs(NL, 0, (int (*)(int))__cputchar);
 			else
 				putchar('\n');
 			l--;
@@ -168,7 +168,7 @@ fgoto(in_refresh)
 		if (outcol != COLS - 1 && plod(strlen(cgp), in_refresh) > 0)
 			plod(0, in_refresh);
 		else 
-			tputs(cgp, 0, __cputchar);
+			tputs(cgp, 0, (int (*)(int))__cputchar);
 	} else
 		plod(0, in_refresh);
 	outline = destline;
@@ -245,7 +245,7 @@ plod(cnt, in_refresh)
 			 * Cheaper to home.  Do it now and pretend it's a
 			 * regular local motion.
 			 */
-			tputs(HO, 0, plodput);
+			tputs(HO, 0, (int (*)(int))plodput);
 			outcol = outline = 0;
 		} else if (LL) {
 			/*
@@ -254,7 +254,7 @@ plod(cnt, in_refresh)
 			 */
 			k = (LINES - 1) - destline;
 			if (i + k + 2 < j && (k <= 0 || UP)) {
-				tputs(LL, 0, plodput);
+				tputs(LL, 0, (int (*)(int))plodput);
 				outcol = 0;
 				outline = LINES - 1;
 			}
@@ -304,12 +304,12 @@ plod(cnt, in_refresh)
 		 * into account.
 		 */
 		if (CR)
-			tputs(CR, 0, plodput);
+			tputs(CR, 0, (int (*)(int))plodput);
 		else
 			plodput('\r');
 		if (NC) {
 			if (NL)
-				tputs(NL, 0, plodput);
+				tputs(NL, 0, (int (*)(int))plodput);
 			else
 				plodput('\n');
 			outline++;
@@ -320,7 +320,7 @@ plod(cnt, in_refresh)
 dontcr:	while (outline < destline) {
 		outline++;
 		if (NL)
-			tputs(NL, 0, plodput);
+			tputs(NL, 0, (int (*)(int))plodput);
 		else
 			plodput('\n');
 		if (plodcnt < 0)
@@ -335,7 +335,7 @@ dontcr:	while (outline < destline) {
 			goto out;
 #ifdef notdef
 		if (BT && outcol - destcol > k + 4) {
-			tputs(BT, 0, plodput);
+			tputs(BT, 0, (int (*)(int))plodput);
 			outcol--;
 			outcol &= ~7;
 			continue;
@@ -343,13 +343,13 @@ dontcr:	while (outline < destline) {
 #endif
 		outcol--;
 		if (BC)
-			tputs(BC, 0, plodput);
+			tputs(BC, 0, (int (*)(int))plodput);
 		else
 			plodput('\b');
 	}
 	while (outline > destline) {
 		outline--;
-		tputs(UP, 0, plodput);
+		tputs(UP, 0, (int (*)(int))plodput);
 		if (plodcnt < 0)
 			goto out;
 	}
@@ -359,21 +359,21 @@ dontcr:	while (outline < destline) {
 			if (i > destcol)
 				break;
 			if (TA)
-				tputs(TA, 0, plodput);
+				tputs(TA, 0, (int (*)(int))plodput);
 			else
 				plodput('\t');
 			outcol = i;
 		}
 		if (destcol - outcol > 4 && i < COLS && (BC || BS)) {
 			if (TA)
-				tputs(TA, 0, plodput);
+				tputs(TA, 0, (int (*)(int))plodput);
 			else
 				plodput('\t');
 			outcol = i;
 			while (outcol > destcol) {
 				outcol--;
 				if (BC)
-					tputs(BC, 0, plodput);
+					tputs(BC, 0, (int (*)(int))plodput);
 				else
 					plodput('\b');
 			}
@@ -398,7 +398,7 @@ dontcr:	while (outline < destline) {
 			}
 		} else
 nondes:			if (ND)
-				tputs(ND, 0, plodput);
+				tputs(ND, 0, (int (*)(int))plodput);
 			else
 				plodput(' ');
 		outcol++;
Index: curses.c
===================================================================
--- curses.c.orig
+++ curses.c
@@ -39,23 +39,29 @@ static char sccsid[] = "@(#)curses.c	8.3
 
 /* Private. */
 int	__echoit = 1;			/* If stty indicates ECHO. */
-int	__pfast;
+int	__pfast = 0;
 int	__rawmode = 0;			/* If stty indicates RAW mode. */
 int	__noqch = 0;			/* 
 					 * If terminal doesn't have 
 					 * insert/delete line capabilities 
 					 * for quick change on refresh.
 					 */
-char	AM, BS, CA, DA, EO, HC, IN, MI, MS, NC, NS, OS, PC,
-	UL, XB, XN, XT, XS, XX;
-char	*AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
-	*DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
-	*K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
-	*KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
-	*SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
-	*VE, *al, *dl, *sf, *sr,
-	*AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM, *LEFT_PARM,
-	*RIGHT_PARM;
+char	AM = 0, BS = 0, CA = 0, DA = 0, EO = 0, HC = 0, IN = 0,
+	MI = 0, MS = 0, NC = 0, NS = 0, OS = 0, PC = 0,
+	UL = 0, XB = 0, XN = 0, XT = 0, XS = 0, XX = 0;
+char	*AL = 0, *BC = 0, *BT = 0, *CD = 0, *CE = 0, *CL = 0,
+	*CM = 0, *CR = 0, *CS = 0, *DC = 0, *DL = 0,
+	*DM = 0, *DO = 0, *ED = 0, *EI = 0, *K0 = 0, *K1 = 0,
+	*K2 = 0, *K3 = 0, *K4 = 0, *K5 = 0, *K6 = 0,
+	*K7 = 0, *K8 = 0, *K9 = 0, *HO = 0, *IC = 0, *IM = 0,
+	*IP = 0, *KD = 0, *KE = 0, *KH = 0, *KL = 0,
+	*KR = 0, *KS = 0, *KU = 0, *LL = 0, *MA = 0, *ND = 0,
+	*NL = 0, *RC = 0, *SC = 0, *SE = 0, *SF = 0,
+	*SO = 0, *SR = 0, *TA = 0, *TE = 0, *TI = 0, *UC = 0,
+	*UE = 0, *UP = 0, *US = 0, *VB = 0, *VS = 0,
+	*VE = 0, *al = 0, *dl = 0, *sf = 0, *sr = 0,
+	*AL_PARM = 0, *DL_PARM = 0, *UP_PARM = 0, *DOWN_PARM = 0,
+	*LEFT_PARM = 0, *RIGHT_PARM = 0;
 /*
  * Public.
  *
Index: curses.h
===================================================================
--- curses.h.orig
+++ curses.h
@@ -36,18 +36,17 @@
 #ifndef _OCURSES_H_
 #define	_OCURSES_H_
 
+#include <features.h>
 #include <sys/types.h>
-#include <sys/cdefs.h>
-
 #include <stdio.h>
+#include <termcap/termcap.h>
 
-#define	bool	char
-
-#ifndef TRUE
-#define	TRUE	(1)
+#ifndef _BSD_VA_LIST_
+#define _BSD_VA_LIST_	_G_va_list
 #endif
-#ifndef FALSE
-#define	FALSE	(0)
+
+#ifndef TCSASOFT
+#define TCSASOFT	0
 #endif
 
 /*
@@ -57,8 +56,18 @@
  * START BACKWARD COMPATIBILITY ONLY.
  */
 #ifndef _CURSES_PRIVATE
-#define	_puts(s)	tputs(s, 0, __cputchar)
-#define	_putchar(c)	__cputchar(c)
+#define	bool	char
+#define	reg	register
+
+#ifndef TRUE
+#define	TRUE	(1)
+#endif
+#ifndef FALSE
+#define	FALSE	(0)
+#endif
+
+#define	_puts(s)	tputs(s, 0, (int (*)(int))__cputchar)
+#define	_putchar(c)	((int (*)(int))__cputchar(c))
 
 /* Old-style terminal modes access. */
 #define	baudrate()	(cfgetospeed(&__baset))
@@ -327,14 +336,4 @@ extern int	 __rawmode;
 extern int	 __noqch;
 #endif
 
-/* Termcap functions. */
-__BEGIN_DECLS
-int	 tgetent __P((char *, char *));
-int	 tgetnum __P((char *));
-int	 tgetflag __P((char *));
-char	*tgetstr __P((char *, char **));
-char	*tgoto __P((char *, int, int));
-void	 tputs __P((char *, int, void (*)(int)));
-__END_DECLS
-
 #endif /* !_OCURSES_H_ */
Index: erase.c
===================================================================
--- erase.c.orig
+++ erase.c
@@ -47,7 +47,7 @@ werase(win)
 {
 
 	register int minx, y;
-	register __LDATA *sp, *end, *start, *maxx;
+	register __LDATA *sp, *end, *start, *maxx = NULL;
 
 #ifdef DEBUG
 	__CTRACE("werase: (%0.2o)\n", win);
@@ -64,7 +64,7 @@ werase(win)
 				sp->ch = ' ';
 				sp->attr = 0;
 			}
-		if (minx != -1)
+		if (maxx && minx != -1)
 			__touchline(win, y, minx, maxx - win->lines[y]->line,
 			   0);
 	}
Index: insertln.c
===================================================================
--- insertln.c.orig
+++ insertln.c
@@ -49,7 +49,7 @@ winsertln(win)
 {
 
 	register int y, i;
-	register __LINE *temp;
+	register __LINE *temp = NULL;
 
 #ifdef DEBUG
 	__CTRACE("insertln: (%0.2o)\n", win);
@@ -67,7 +67,7 @@ winsertln(win)
 			    win->maxx * __LDATASIZE);
 		__touchline(win, y, 0, win->maxx - 1, 0);
 	}
-	if (win->orig == NULL)
+	if (temp && win->orig == NULL)
 		win->lines[y] = temp;
 	else
 		temp = win->lines[y];
Index: newwin.c
===================================================================
--- newwin.c.orig
+++ newwin.c
@@ -134,8 +134,8 @@ __set_subwin(orig, win)
 	/*  Point line pointers to line space. */
 	for (lp = win->lspace, i = 0; i < win->maxy; i++, lp++) {
 		win->lines[i] = lp;
-		olp = orig->lines[i + win->begy];
-		lp->line = &olp->line[win->begx];
+		olp = orig->lines[i + win->begy - orig->begy];
+		lp->line = &olp->line[win->ch_off];
 		lp->firstchp = &olp->firstch;
 		lp->lastchp = &olp->lastch;
 		lp->hash = __hash((char *) lp->line, win->maxx * __LDATASIZE);
Index: nowarn.h
===================================================================
--- /dev/null
+++ nowarn.h
@@ -0,0 +1 @@
+static char sccsid[] __attribute__ ((unused));
Index: printw.c
===================================================================
--- printw.c.orig
+++ printw.c
@@ -191,10 +191,18 @@ vwprintw(win, fmt, ap)
 	const char *fmt;
 	va_list ap;
 {
+#ifdef __linux__
+	char buf[1024];
+	int len;
+
+	len = vsprintf(buf, fmt, ap);
+	return __winwrite(win, buf, len) ? ERR : OK;
+#else
 	FILE *f;
 
 	if ((f = funopen(win, NULL, __winwrite, NULL, NULL)) == NULL)
 		return (ERR);
 	(void)vfprintf(f, fmt, ap);
 	return (fclose(f) ? ERR : OK);
+#endif
 }
Index: refresh.c
===================================================================
--- refresh.c.orig
+++ refresh.c
@@ -36,6 +36,7 @@ static char sccsid[] = "@(#)refresh.c	8.
 #endif /* not lint */
 
 #include <string.h>
+#include <stdlib.h>
 
 #include "curses.h"
 
@@ -77,7 +78,7 @@ wrefresh(win)
 
 	if (win->flags & __CLEAROK || curscr->flags & __CLEAROK || curwin) {
 		if ((win->flags & __FULLWIN) || curscr->flags & __CLEAROK) {
-			tputs(CL, 0, __cputchar);
+			tputs(CL, 0, (int (*)(int))__cputchar);
 			ly = 0;
 			lx = 0;
 			if (!curwin) {
@@ -220,7 +221,7 @@ makech(win, wy)
 	static __LDATA blank = {' ', 0};
 	__LDATA *nsp, *csp, *cp, *cep;
 	u_int force;
-	int clsp, nlsp;			/* Last space in lines. */
+	int clsp, nlsp = 0;			/* Last space in lines. */
 	int lch, wx, y;
 	char *ce;
 
@@ -264,9 +265,9 @@ makech(win, wy)
 
 	if (force) {
 		if (CM)
-			tputs(tgoto(CM, lx, ly), 0, __cputchar);
+			tputs(tgoto(CM, lx, ly), 0, (int (*)(int))__cputchar);
 		else {
-			tputs(HO, 0, __cputchar);
+			tputs(HO, 0, (int (*)(int))__cputchar);
 			__mvcur(0, 0, ly, lx, 1);
 		}
 	}
@@ -313,10 +314,10 @@ makech(win, wy)
 				    && clsp < win->maxx * __LDATASIZE) ||
 				    wy == win->maxy - 1) {
 					if (curscr->flags & __WSTANDOUT) {
-						tputs(SE, 0, __cputchar);
+						tputs(SE, 0, (int (*)(int))__cputchar);
 						curscr->flags &= ~__WSTANDOUT;
 					}
-					tputs(CE, 0, __cputchar);
+					tputs(CE, 0, (int (*)(int))__cputchar);
 					lx = wx + win->begx;
 					while (wx++ <= clsp) {
 						csp->ch = ' ';
@@ -336,13 +337,13 @@ makech(win, wy)
 			if (nsp->attr & __STANDOUT) {
 				if (!(curscr->flags & __WSTANDOUT) &&
 				    SO != NULL && SE != NULL) {
-					tputs(SO, 0, __cputchar);
+					tputs(SO, 0, (int (*)(int))__cputchar);
 					curscr->flags |= __WSTANDOUT;
 				}
 			} else
 				if (curscr->flags & __WSTANDOUT &&
 				    SE != NULL) {
-					tputs(SE, 0, __cputchar);
+					tputs(SE, 0, (int (*)(int))__cputchar);
 					curscr->flags &= ~__WSTANDOUT;
 				}
 
@@ -353,7 +354,7 @@ makech(win, wy)
 					    && win->flags & __ENDLINE)
 						if (!MS) {
 							tputs(SE, 0,
-							    __cputchar);
+							    (int (*)(int))__cputchar);
 							curscr->flags &=
 							    ~__WSTANDOUT;
 						}
@@ -387,7 +388,7 @@ makech(win, wy)
 #endif
 			if (UC && (nsp->attr & __STANDOUT)) {
 				putchar('\b');
-				tputs(UC, 0, __cputchar);
+				tputs(UC, 0, (int (*)(int))__cputchar);
 			}
 			nsp++;
 #ifdef DEBUG
@@ -411,7 +412,7 @@ makech(win, wy)
 
 	/* Don't leave the screen in standout mode. */
 	if (curscr->flags & __WSTANDOUT) {
-		tputs(SE, 0, __cputchar);
+		tputs(SE, 0, (int (*)(int))__cputchar);
 		curscr->flags &= ~__WSTANDOUT;
 	}
 	return (OK);
@@ -426,7 +427,7 @@ domvcur(oy, ox, ny, nx)
 	int oy, ox, ny, nx;
 {
 	if (curscr->flags & __WSTANDOUT && !MS) {
-		tputs(SE, 0, __cputchar);
+		tputs(SE, 0, (int (*)(int))__cputchar);
 		curscr->flags &= ~__WSTANDOUT;
 	}
 
@@ -446,7 +447,7 @@ quickch(win)
 #define THRESH		(int) win->maxy / 4
 
 	register __LINE *clp, *tmp1, *tmp2;
-	register int bsize, curs, curw, starts, startw, i, j;
+	register int bsize, curs = 0, curw = 0, starts = 0, startw = 0, i, j;
 	int n, target, cur_period, bot, top, sc_region;
 	__LDATA buf[1024];
 	u_int blank_hash;
@@ -679,8 +680,8 @@ quickch(win)
 		 * Need to repoint any subwindow lines to the rotated
 		 * line structured.
 		 */
-		for (wp = curscr->nextp; wp != curscr; wp = wp->nextp)
-			__set_subwin(wp->orig, wp);
+		for (wp = win->nextp; wp != win; wp = wp->nextp)
+			__set_subwin(win, wp);
 	}
 }
 
@@ -724,20 +725,20 @@ scrolln(win, starts, startw, curs, bot,
 	 */
 	if (n > 0) {
 		if (CS != NULL && HO != NULL && (SF != NULL ||
-		    (AL == NULL || DL == NULL ||
-		    top > 3 || bot + 3 < win->maxy) && sf != NULL)) {
-			tputs(__tscroll(CS, top, bot + 1), 0, __cputchar);
+		    ((AL == NULL || DL == NULL ||
+		    top > 3 || bot + 3 < win->maxy) && sf != NULL))) {
+			tputs(__tscroll(CS, top, bot + 1), 0, (int (*)(int))__cputchar);
 			__mvcur(oy, ox, 0, 0, 1);
-			tputs(HO, 0, __cputchar);
+			tputs(HO, 0, (int (*)(int))__cputchar);
 			__mvcur(0, 0, bot, 0, 1);
 			if (SF != NULL)
-				tputs(__tscroll(SF, n, 0), 0, __cputchar);
+				tputs(__tscroll(SF, n, 0), 0, (int (*)(int))__cputchar);
 			else
 				for (i = 0; i < n; i++)
-					tputs(sf, 0, __cputchar);
-			tputs(__tscroll(CS, 0, win->maxy), 0, __cputchar);
+					tputs(sf, 0, (int (*)(int))__cputchar);
+			tputs(__tscroll(CS, 0, win->maxy), 0, (int (*)(int))__cputchar);
 			__mvcur(bot, 0, 0, 0, 1);
-			tputs(HO, 0, __cputchar);
+			tputs(HO, 0, (int (*)(int))__cputchar);
 			__mvcur(0, 0, oy, ox, 1);
 			return;
 		}
@@ -745,28 +746,28 @@ scrolln(win, starts, startw, curs, bot,
 		/* Scroll up the block. */
 		if (SF != NULL && top == 0) {
 			__mvcur(oy, ox, bot, 0, 1);
-			tputs(__tscroll(SF, n, 0), 0, __cputchar);
+			tputs(__tscroll(SF, n, 0), 0, (int (*)(int))__cputchar);
 		} else if (DL != NULL) {
 			__mvcur(oy, ox, top, 0, 1);
-			tputs(__tscroll(DL, n, 0), 0, __cputchar);
+			tputs(__tscroll(DL, n, 0), 0, (int (*)(int))__cputchar);
 		} else if (dl != NULL) {
 			__mvcur(oy, ox, top, 0, 1);
 			for (i = 0; i < n; i++)
-				tputs(dl, 0, __cputchar);
+				tputs(dl, 0, (int (*)(int))__cputchar);
 		} else if (sf != NULL && top == 0) {
 			__mvcur(oy, ox, bot, 0, 1);
 			for (i = 0; i < n; i++)
-				tputs(sf, 0, __cputchar);
+				tputs(sf, 0, (int (*)(int))__cputchar);
 		} else
 			abort();
 
 		/* Push down the bottom region. */
 		__mvcur(top, 0, bot - n + 1, 0, 1);
 		if (AL != NULL)
-			tputs(__tscroll(AL, n, 0), 0, __cputchar);
+			tputs(__tscroll(AL, n, 0), 0, (int (*)(int))__cputchar);
 		else if (al != NULL)
 			for (i = 0; i < n; i++)
-				tputs(al, 0, __cputchar);
+				tputs(al, 0, (int (*)(int))__cputchar);
 		else
 			abort();
 		__mvcur(bot - n + 1, 0, oy, ox, 1);
@@ -779,21 +780,21 @@ scrolln(win, starts, startw, curs, bot,
 		 * See the above comments for details.
 		 */
 		if (CS != NULL && HO != NULL && (SR != NULL ||
-		    (AL == NULL || DL == NULL ||
-		    top > 3 || bot + 3 < win->maxy) && sr != NULL)) {
-			tputs(__tscroll(CS, top, bot + 1), 0, __cputchar);
+		    ((AL == NULL || DL == NULL ||
+		    top > 3 || bot + 3 < win->maxy) && sr != NULL))) {
+			tputs(__tscroll(CS, top, bot + 1), 0, (int (*)(int))__cputchar);
 			__mvcur(oy, ox, 0, 0, 1);
-			tputs(HO, 0, __cputchar);
+			tputs(HO, 0, (int (*)(int))__cputchar);
 			__mvcur(0, 0, top, 0, 1);
 
 			if (SR != NULL)
-				tputs(__tscroll(SR, -n, 0), 0, __cputchar);
+				tputs(__tscroll(SR, -n, 0), 0, (int (*)(int))__cputchar);
 			else
 				for (i = n; i < 0; i++)
-					tputs(sr, 0, __cputchar);
-			tputs(__tscroll(CS, 0, win->maxy), 0, __cputchar);
+					tputs(sr, 0, (int (*)(int))__cputchar);
+			tputs(__tscroll(CS, 0, win->maxy), 0, (int (*)(int))__cputchar);
 			__mvcur(top, 0, 0, 0, 1);
-			tputs(HO, 0, __cputchar);
+			tputs(HO, 0, (int (*)(int))__cputchar);
 			__mvcur(0, 0, oy, ox, 1);
 			return;
 		}
@@ -801,25 +802,25 @@ scrolln(win, starts, startw, curs, bot,
 		/* Preserve the bottom lines. */
 		__mvcur(oy, ox, bot + n + 1, 0, 1);
 		if (SR != NULL && bot == win->maxy)
-			tputs(__tscroll(SR, -n, 0), 0, __cputchar);
+			tputs(__tscroll(SR, -n, 0), 0, (int (*)(int))__cputchar);
 		else if (DL != NULL)
-			tputs(__tscroll(DL, -n, 0), 0, __cputchar);
+			tputs(__tscroll(DL, -n, 0), 0, (int (*)(int))__cputchar);
 		else if (dl != NULL)
 		       	for (i = n; i < 0; i++)
-				tputs(dl, 0, __cputchar);
+				tputs(dl, 0, (int (*)(int))__cputchar);
 		else if (sr != NULL && bot == win->maxy)
 		       	for (i = n; i < 0; i++)
-				tputs(sr, 0, __cputchar);
+				tputs(sr, 0, (int (*)(int))__cputchar);
 		else
 			abort();
 
 		/* Scroll the block down. */
 		__mvcur(bot + n + 1, 0, top, 0, 1);
 		if (AL != NULL)
-			tputs(__tscroll(AL, -n, 0), 0, __cputchar);
+			tputs(__tscroll(AL, -n, 0), 0, (int (*)(int))__cputchar);
 		else if (al != NULL)
 			for (i = n; i < 0; i++)
-				tputs(al, 0, __cputchar);
+				tputs(al, 0, (int (*)(int))__cputchar);
 		else
 			abort();
 		__mvcur(top, 0, oy, ox, 1);
Index: setterm.c
===================================================================
--- setterm.c.orig
+++ setterm.c
@@ -164,8 +164,8 @@ setterm(type)
 	/* If no scrolling commands, no quick change. */
 	__noqch =
 	    (CS == NULL || HO == NULL ||
-	    SF == NULL && sf == NULL || SR == NULL && sr == NULL) &&
-	    (AL == NULL && al == NULL || DL == NULL && dl == NULL);
+	     (SF == NULL && sf == NULL) || (SR == NULL && sr == NULL)) &&
+	    ((AL == NULL && al == NULL) || (DL == NULL && dl == NULL));
 
 	return (unknown ? ERR : OK);
 }
Index: standout.c
===================================================================
--- standout.c.orig
+++ standout.c
@@ -49,7 +49,7 @@ wstandout(win)
 	 * If standout/standend strings, or can underline, set the
 	 * screen standout bit.
 	 */
-	if (SO != NULL && SE != NULL || UC != NULL)
+	if ((SO != NULL && SE != NULL) || UC != NULL)
 		win->flags |= __WSTANDOUT;
 	return (1);
 }
Index: tty.c
===================================================================
--- tty.c.orig
+++ tty.c
@@ -48,7 +48,7 @@ static char sccsid[] = "@(#)tty.c	8.5 (B
  * those attributes at each change, or at least when stopped and restarted.
  * See also the comments in getterm().
  */
-#ifdef TCSASOFT
+#if TCSASOFT != 0
 int __tcaction = 1;			/* Ignore hardware settings. */
 #else
 int __tcaction = 0;
@@ -235,8 +235,8 @@ __startwin()
 	}
 	(void)setvbuf(stdout, stdbuf, _IOFBF, len);
 
-	tputs(TI, 0, __cputchar);
-	tputs(VS, 0, __cputchar);
+	tputs(TI, 0, (int (*)(int))__cputchar);
+	tputs(VS, 0, (int (*)(int))__cputchar);
 }
 
 int
@@ -246,14 +246,14 @@ endwin()
 
 	if (curscr != NULL) {
 		if (curscr->flags & __WSTANDOUT) {
-			tputs(SE, 0, __cputchar);
+			tputs(SE, 0, (int (*)(int))__cputchar);
 			curscr->flags &= ~__WSTANDOUT;
 		}
 		__mvcur(curscr->cury, curscr->cury, curscr->maxy - 1, 0, 0);
 	}
 
-	(void)tputs(VE, 0, __cputchar);
-	(void)tputs(TE, 0, __cputchar);
+	(void)tputs(VE, 0, (int (*)(int))__cputchar);
+	(void)tputs(TE, 0, (int (*)(int))__cputchar);
 	(void)fflush(stdout);
 	(void)setvbuf(stdout, NULL, _IOLBF, 0);
 
Index: PSD.doc/Makefile
===================================================================
--- PSD.doc/Makefile.orig
+++ PSD.doc/Makefile
@@ -3,10 +3,6 @@
 DIR=	psd/19.curses
 SRCS=	Master
 MACROS=	-me
-EXTRA=	appen.A appen.B appen.C c_macros doc.I doc.II doc.III \
-	doc.IV ex1.c ex2.c fns.doc intro.0 intro.1 intro.2 intro.3 \
-	intro.4 intro.5 intro.6 life.c macros twinkle1.c twinkle2.c \
-	win_st.c
 
 CLEANFILES+=win_st.gr twinkle1.gr twinkle2.gr life.gr intro.2.tbl appen.A.tbl \
 	ex1.gr ex2.gr