$NetBSD: patch-al,v 1.1.1.1 2001/04/27 15:27:32 agc Exp $ --- io.c.orig Wed Jan 18 11:48:27 1995 +++ io.c Sun Jan 14 07:56:12 2001 @@ -47,6 +47,12 @@ * * Note: ** entries are available only in termcap mode. */ + +#include +#include +#include +#include +#include #include "header.h" #include "extern.h" @@ -61,13 +67,13 @@ /* * 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 @@ * newgame() * Subroutine to save the initial time and seed rnd() */ -newgame () +void newgame (void) { long *p,*pe; @@ -101,7 +107,7 @@ */ /*VARARGS*/ -lprintf(va_alist) +void lprintf(va_alist) va_dcl { va_list ap; /* pointer for variable argument list */ @@ -164,7 +170,7 @@ break; } if (wide==0) { - while (*outb++ = *tmpb++); + while ((*outb++ = *tmpb++)); --outb; } else { @@ -172,7 +178,7 @@ if (left) while (n-- > 0) *outb++ = ' '; - while (*outb++ = *tmpb++) + while ((*outb++ = *tmpb++)) ; --outb; if (left==0) @@ -230,7 +236,7 @@ * 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 +257,7 @@ * 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 +292,7 @@ * * Returns 0 if EOF, otherwise the character */ -long lgetc1() +long lgetc1(void) { int i; @@ -320,7 +326,7 @@ * 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 +345,7 @@ * 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 +385,7 @@ * * 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 +418,7 @@ * *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 +443,7 @@ * 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 +467,7 @@ * 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 +490,7 @@ * 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 +513,7 @@ * * Returns nothing of value. */ -lrclose() +void lrclose(void) { if (fd > 0) close(fd); @@ -518,7 +524,7 @@ * * Returns nothing of value. */ -lwclose () +void lwclose (void) { lflush(); if (lfd > 2) @@ -529,7 +535,7 @@ * 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 +543,7 @@ if (lpnt >= lpend) lflush(); str2 = lpnt; - while (*str2++ = *str++) - ; + while ((*str2++ = *str++)); lpnt = str2 - 1; } @@ -553,15 +558,16 @@ 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 +590,11 @@ 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 +637,7 @@ /* * 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 +653,7 @@ /* * 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 +676,7 @@ /* * standout(str) Print the argument string in inverse video (standout mode). */ -standout (str) +void standout (str) char *str; { if (boldon == 0) { @@ -687,7 +692,7 @@ /* * set_score_output() Called when output should be literally printed. */ -set_score_output() { +void set_score_output() { enable_scroll = -1; } @@ -700,7 +705,7 @@ */ static int scrline=18; /* line # for wraparound instead of scrolling if no DL */ -lflush () +void lflush () { int lpoint; char *str; @@ -796,18 +801,19 @@ /* * 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 +831,7 @@ * * */ -tmcapcnv(sd,ss) +void tmcapcnv(sd,ss) char *sd, *ss; { int tmstate=0; /* 0=normal, 1=ESC 2=[ 3=# */