$NetBSD: patch-al,v 1.2 2003/12/06 19:28:22 ben Exp $

--- io.c.orig	1995-01-18 11:48:27.000000000 -0800
+++ io.c
@@ -47,6 +47,12 @@
  *
  * Note: ** entries are available only in termcap mode.
  */
+
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <stdlib.h>
+#include <termcap.h>
+#include <unistd.h>
 #include "header.h"
 #include "extern.h"
 
@@ -61,13 +67,13 @@ static char lgetwbuf[LINBUFSIZE];	/* get
 /*
  *	getcharacter() 	Routine to read in one character from the terminal
  */
-getcharacter ()
+int getcharacter (void)
 {
 	char byt;
 
 	lflush();		/* be sure output buffer is flushed */
 	read(0, &byt,1); 	/* get byte from terminal */
-	return(byt);
+	return((int)byt);
 }
 
 
@@ -75,7 +81,7 @@ getcharacter ()
  *	newgame() 
  *		Subroutine to save the initial time and seed rnd()
  */
-newgame ()
+void newgame (void)
 {
 	long *p,*pe;
 
@@ -101,18 +107,14 @@ newgame ()
  */
 /*VARARGS*/
 
-lprintf(va_alist)
-va_dcl
+void lprintf(char *fmt, ...)
 {
 	va_list ap;	/* pointer for variable argument list */
-	char *fmt;
 	char *outb,*tmpb;
 	long wide,left,cont,n;		/* data for lprintf	*/
 	char db[12];			/* %d buffer in lprintf	*/
 
-	va_start(ap);	/* initialize the var args pointer */
-
-	fmt = (char *)va_arg(ap, char *);	/* pointer to format string */
+	va_start(ap, fmt);	/* initialize the var args pointer */
 
 	if (lpnt >= lpend) lflush();
 	outb = lpnt;
@@ -164,7 +166,7 @@ va_dcl
 					break;
 				}
 				if (wide==0)  {
-					while (*outb++ = *tmpb++);
+					while ((*outb++ = *tmpb++));
 					--outb;
 				}
 				else {
@@ -172,7 +174,7 @@ va_dcl
 					if (left)
 						while (n-- > 0)
 							*outb++ = ' ';
-					while (*outb++ = *tmpb++)
+					while ((*outb++ = *tmpb++))
 						;
 					--outb;
 					if (left==0)
@@ -230,7 +232,7 @@ va_dcl
  *	No checking for output buffer overflow is done, but flushes if needed!
  *	Returns nothing of value.
  */
-lprint (x)
+void lprint (x)
 long x;
 {
 	if (lpnt >= lpend)
@@ -251,7 +253,7 @@ long x;
  *	Enter with the address and number of bytes to write out
  *	Returns nothing of value
  */
-lwrite (buf, len)
+void lwrite (buf, len)
 char *buf;
 int len;
 {
@@ -286,7 +288,7 @@ int len;
  *
  *  Returns 0 if EOF, otherwise the character
  */
-long lgetc1()
+long lgetc1(void)
 {
 	int i;
 
@@ -320,7 +322,7 @@ long lgetc1()
  *	The save order is low order first, to high order (4 bytes total)
  *	Returns the int read
  */
-long lrint()
+long lrint(void)
 {
 	long i;
 
@@ -339,7 +341,7 @@ long lrint()
  *	Reads "number" bytes into the buffer pointed to by "address".
  *	Returns nothing of value
  */
-lrfill (adr, num)
+void lrfill (adr, num)
 char *adr;
 int num;
 {
@@ -379,7 +381,7 @@ int num;
  *
  *	Returns pointer to a buffer that contains word.  If EOF, returns a 0
  */
-char *lgetw()
+char *lgetw(void)
 {
 	char *lgp;
 	int cc, n=LINBUFSIZE, quote=0;
@@ -412,7 +414,7 @@ char *lgetw()
  *
  *Returns pointer to a buffer that contains the line.  If EOF, returns 0
  */
-char *lgetl()
+char *lgetl(void)
 {
 	int i=LINBUFSIZE,ch;
 	char *str=lgetwbuf;
@@ -437,7 +439,7 @@ char *lgetl()
  *	lcreat((char*)0); means to the terminal
  *	Returns -1 if error, otherwise the file descriptor opened.
  */
-lcreat(str)
+int lcreat(str)
 char *str;
 {
 	lpnt = lpbuf;
@@ -461,7 +463,7 @@ char *str;
  *	lopen(0) means from the terminal
  *	Returns -1 if error, otherwise the file descriptor opened.
  */
-lopen (str)
+int lopen (str)
 char *str;
 {
 	ipoint = iepoint = BUFSIZ;
@@ -484,7 +486,7 @@ char *str;
  *	lappend(0) means to the terminal
  *	Returns -1 if error, otherwise the file descriptor opened.
  */
-lappend (str)
+int lappend (str)
 char *str;
 {
 	lpnt = lpbuf;
@@ -507,7 +509,7 @@ char *str;
  *
  *	Returns nothing of value.
  */
-lrclose()
+void lrclose(void)
 {
 	if (fd > 0)
 		close(fd);
@@ -518,7 +520,7 @@ lrclose()
  *
  *	Returns nothing of value.
  */
-lwclose ()
+void lwclose (void)
 {
 	lflush();
 	if (lfd > 2)
@@ -529,7 +531,7 @@ lwclose ()
  *	lprcat(string)			append a string to the output buffer
  *					avoids calls to lprintf (time consuming)
  */
-lprcat (str)
+void lprcat (str)
 char *str;
 {
 	char *str2;
@@ -537,8 +539,7 @@ char *str;
 	if (lpnt >= lpend)
 		lflush();
 	str2 = lpnt;
-	while (*str2++ = *str++)
-		;
+	while ((*str2++ = *str++));
 	lpnt = str2 - 1;
 }
 
@@ -553,15 +554,16 @@ static char cap[256];
 static char *outbuf=0;	/* translated output buffer */
 char *CM, *CE, *CD, *CL, *SO, *SE, *AL, *DL;/* Termcap capabilities */
 char *HO, *BC, *UP;
-extern char *PC;
+/* extern char *PC; */ /* termcap.h declares extern char PC, not a pointer */
 
 /*
  * init_term()		Terminal initialization -- setup termcap info
  */
-init_term ()
+void init_term (void)
 {
 	char termbuf[1024];
-	char *pc, *capptr = cap+10;
+	char *pc;
+	char *capptr = cap+10;
 	char *malloc(), *tgetstr(), *term, *getenv();
 
 	switch (tgetent(termbuf, term = getenv("TERM"))) {
@@ -584,12 +586,11 @@ init_term ()
 	UP = tgetstr("up", &capptr);	/* cursor up */
 	HO = tgetstr("ho", &capptr);	/* home cursor */
 
-	if (pc = tgetstr("pc", &capptr)) /* padding character */
-		PC = pc;
-/*
+	pc = tgetstr("pc", &capptr);	/* padding character */
+	if (pc)
+		PC = *pc;
 	else
-		*PC = '\0';
-*/
+		PC = '\0';
 
 	if (!(BC = tgetstr("bc", &capptr))) {	/* backspace */
 		if (!(BC=tgetstr("le", &capptr))) {
@@ -632,7 +633,7 @@ init_term ()
 /*
  * cl_up(x,y) Clear screen from [x,1] to current position. Leave cursor at [x,y]
  */
-cl_up (x,y)
+void cl_up (x,y)
 int x, y;
 {
 	int i;
@@ -648,7 +649,7 @@ int x, y;
 /*
  * cl_dn(x,y) 	Clear screen from [1,y] to end of display. Leave cursor at [x,y]
  */
-cl_dn (x,y)
+void cl_dn (x,y)
 int x, y;
 {
 	int i;
@@ -671,7 +672,7 @@ int x, y;
 /*
  * standout(str)  Print the argument string in inverse video (standout mode).
  */
-standout (str)
+void standout (str)
 char *str;
 {
 	if (boldon == 0) {
@@ -687,7 +688,7 @@ char *str;
 /*
  * set_score_output() 	Called when output should be literally printed.
  */
-set_score_output() {
+void set_score_output() {
 	enable_scroll = -1;
 }
 
@@ -700,7 +701,7 @@ set_score_output() {
  */
 static int scrline=18; /* line # for wraparound instead of scrolling if no DL */
 
-lflush ()
+void lflush ()
 {
 	int lpoint;
 	char *str;
@@ -796,18 +797,19 @@ static int ind=0;
 /*
  * putcharacter(c)		Print one character in decoded output buffer.
  */
-putcharacter(c)
+int putcharacter(c)
 int c;
 {
 	outbuf[ind++]=c;
 	if(ind>=BUFSIZ)
 		flush_buf();
+	return c;
 }
 
 /*
  * flush_buf()			Flush buffer with decoded output.
  */
-flush_buf()
+void flush_buf(void)
 {
 	if (ind)
 		write(lfd, outbuf, ind);
@@ -825,7 +827,7 @@ flush_buf()
  *
  *
  */
-tmcapcnv(sd,ss)
+void tmcapcnv(sd,ss)
 char *sd, *ss;
 {
 	int tmstate=0;	/* 0=normal, 1=ESC 2=[ 3=# */
