From 679426dc52b7c5ef9223f9ec7065855f81102c78 Mon Sep 17 00:00:00 2001 From: kamil Date: Tue, 10 Nov 2020 08:49:08 +0000 Subject: Integrate Warp Kit into the NetBSD build Fix the build and make it install and run with minimal required changes. --- Makefile | 6 +-- warp/Makefile | 116 +++++++++++++++++++++++++++++++++------------------------ warp/config.h | 3 +- warp/intrp.c | 17 ++++++++- warp/score.c | 6 ++- warp/sig.c | 6 +-- warp/sig.h | 6 +-- warp/sm.c | 2 + warp/term.c | 4 +- warp/term.h | 23 +++++++++--- warp/util.c | 1 - warp/util.h | 2 +- warp/version.c | 2 + warp/warp.c | 1 + warp/warp.h | 17 ++++++--- warp/warp.news | 3 +- 16 files changed, 135 insertions(+), 80 deletions(-) diff --git a/Makefile b/Makefile index 338af66d..4cef4709 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.29 2013/11/12 17:46:20 mbalmer Exp $ +# $NetBSD: Makefile,v 1.30 2020/11/10 08:49:08 kamil Exp $ # @(#)Makefile 8.3 (Berkeley) 7/24/94 -# Missing: dungeon warp +# Missing: dungeon # Moved: chess # Don't belong: xneko xroach @@ -14,7 +14,7 @@ SUBDIR= adventure arithmetic atc \ hack hals_end hangman hunt larn mille monop morse number \ phantasia pig pom ppt primes quiz \ rain random robots rogue sail snake tetris trek \ - wargames worm worms wtf wump + wargames warp worm worms wtf wump .if ${MKCXX} != "no" SUBDIR+= dab diff --git a/warp/Makefile b/warp/Makefile index 0ae4411d..e48fbf3e 100644 --- a/warp/Makefile +++ b/warp/Makefile @@ -1,61 +1,79 @@ -CFLAGS+=-O +# $NetBSD: Makefile,v 1.2 2020/11/10 08:49:08 kamil Exp $ + +.include + +PROG= warp + SRCS= bang.c init.c intrp.c move.c object.c play.c score.c sig.c term.c \ them.c us.c util.c version.c warp.c weapon.c -OBJS= bang.o init.o intrp.o move.o object.o play.o score.o sig.o term.o \ - them.o us.o util.o version.o warp.o weapon.o - -warp: ${OBJS} - ${CC} ${OBJS} -o $@ -ltermlib -lm - -install: warp - export PATH || exit 1 - - mv $(bin)/warp $(bin)/warp.old - - if test `pwd` != $(bin); then cp $(public) $(bin); fi - - cd $(bin); chmod 755 $(public); chown '$(CHOWNER)' $(public) - - chmod 4711 $(bin)/warp - - chmod 755 makedir - - ./makedir `./filexp $(privlib)` - - \ -if test `pwd` != `./filexp $(privlib)`; then \ -cp $(private) `./filexp $(privlib)`; \ -fi - - \ -cd `./filexp $(privlib)`; \ -chmod 755 $(private); \ -chown '$(CHOWNER)' . $(private); \ -cp /dev/null save.blurfl - - \ -if test ! -f `./filexp $(privlib)/warp.news`; then \ -cp warp.news `./filexp $(privlib)`; \ -fi - - \ -if test `pwd` != $(mansrc); then \ -for page in $(manpages); do \ -cp $$page $(mansrc)/`basename $$page .man`.$(manext); \ -done; \ -fi - -clean: - rm -f warp core ${OBJS} + +DPADD= ${LIBTERMLIB} ${LIBM} ${LIBCOMPAT} +LDADD= -ltermlib -lm -lcompat + +CPPFLAGS+=-DHAVETERMLIB + +CLEANFILES+=sm sm.lo smap.0 smap.1 smap.2 smap.3 smap.4 smap.5 smap.6 smap.7 +CLEANFILES+=warp.6 +HIDEGAME=hidegame +SETGIDGAME=yes +MAN= warp.6 + +warp.6: + ${_MKTARGET_CREATE} + cat ${.CURDIR}/warp.man > ${.TARGET} + +DPSRCS+=smap.0 smap.1 smap.2 smap.3 smap.4 smap.5 smap.6 smap.7 smap.0: smp.0 sm - sm smap.0 + ${_MKTARGET_CREATE} + ./sm < ${.CURDIR}/smp.0 > ${.TARGET} + smap.1: smp.1 sm - sm smap.1 + ${_MKTARGET_CREATE} + ./sm < ${.CURDIR}/smp.1 > ${.TARGET} + smap.2: smp.2 sm - sm smap.2 + ${_MKTARGET_CREATE} + ./sm < ${.CURDIR}/smp.2 > ${.TARGET} + smap.3: smp.3 sm - sm smap.3 + ${_MKTARGET_CREATE} + ./sm < ${.CURDIR}/smp.3 > ${.TARGET} + smap.4: smp.4 sm - sm smap.4 + ${_MKTARGET_CREATE} + ./sm < ${.CURDIR}/smp.4 > ${.TARGET} + smap.5: smp.5 sm - sm smap.5 + ${_MKTARGET_CREATE} + ./sm < ${.CURDIR}/smp.5 > ${.TARGET} + smap.6: smp.6 sm - sm smap.6 + ${_MKTARGET_CREATE} + ./sm < ${.CURDIR}/smp.6 > ${.TARGET} + smap.7: smp.7 sm - sm smap.7 -sm: sm.c - ${CC} sm.c -o $@ + ${_MKTARGET_CREATE} + ./sm < ${.CURDIR}/smp.7 > ${.TARGET} + +sm: sm.lo + ${_MKTARGET_LINK} + ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC} + +.if ${MKSHARE} != "no" +FILES=smap.0 smap.1 smap.2 smap.3 smap.4 smap.5 smap.6 smap.7 +FILES+=warp.doc warp.news README +FILESDIR=/usr/share/games/warp +.endif + +CFLAGS+= -Wno-error=old-style-definition -Wno-error=strict-prototypes +CFLAGS+= -Wno-error=comment -Wno-error=maybe-uninitialized +CFLAGS+= -Wno-error=discarded-qualifiers -Wno-error=dangling-else +CFLAGS+= -Wno-error=char-subscripts -Wno-error=parentheses +CFLAGS+= -Wno-error=unused-value -Wno-error=format-extra-args +CFLAGS+= -Wno-error=format-overflow= -Wno-error=builtin-declaration-mismatch +CFLAGS+= -Wno-error=format= -Wno-error=sign-compare -Wno-error=return-type +CFLAGS+= -Wno-error=unused-label -Wno-error=unused-variable +CFLAGS+= -Wno-error=format-nonliteral -Wno-error=implicit-fallthrough= -depend: ${SRCS} - mkdep ${SRCS} +.include diff --git a/warp/config.h b/warp/config.h index 3d3aad41..b2c1b68a 100644 --- a/warp/config.h +++ b/warp/config.h @@ -145,5 +145,4 @@ #endif /* warp private library, may use ~ expansion, %x and %l */ -#define PRIVLIB "/usr/games/lib/warp" /**/ - +#define PRIVLIB "/usr/share/games/warp" /**/ diff --git a/warp/intrp.c b/warp/intrp.c index d2aa729c..0379d1be 100644 --- a/warp/intrp.c +++ b/warp/intrp.c @@ -257,6 +257,21 @@ getout: } #endif +static char *mygets(char *str, size_t n) +{ + char *ret; + size_t last; + + if ((ret = fgets(str, n, stdin)) != NULL) { + last = strlen(str) - 1; + + if (str[last] == '\n') + str[last] = '\0'; + } + + return ret; +} + /* interpret interpolations */ char * @@ -367,7 +382,7 @@ char *stoppers; pattern = dointerp(scrbuf,(sizeof scrbuf),pattern+1,"\""); fputs(scrbuf,stdout); resetty(); - gets(scrbuf); + mygets(scrbuf, sizeof(scrbuf)); crmode(); raw(); noecho(); diff --git a/warp/score.c b/warp/score.c index 8695f4f9..f36e6595 100644 --- a/warp/score.c +++ b/warp/score.c @@ -35,6 +35,7 @@ score_init() Reg2 int i; FILE *savfil; +#if 0 if (stat(SAVEDIR,&filestat)) { printf("Cannot access %s\r\n",SAVEDIR); finalize(1); @@ -47,6 +48,7 @@ score_init() printf("%s is not protected correctly (must be u+rw o+rx).\r\n",SAVEDIR); finalize(1); } +#endif #ifdef SCOREFULL interp(longlognam, sizeof longlognam, "%N"); @@ -535,12 +537,12 @@ score() Reg1 FILE *logfd; Reg2 FILE *outfd; Reg3 int i; - long nowtime, time(); + time_t nowtime; char *scoreboard; for (i=0; link(LOGFILE, LOCKFILE) == -1 && i<10; i++) sleep(1); - nowtime = time((long *)0); + nowtime = time(NULL); strcpy(cdate,ctime(&nowtime)); if ((logfd = fopen(LOGFILE,"a")) != NULL) { fprintf(logfd, diff --git a/warp/sig.c b/warp/sig.c index 3be78777..18e64564 100644 --- a/warp/sig.c +++ b/warp/sig.c @@ -58,7 +58,7 @@ sig_init() #ifdef SIGTSTP void -cont_catcher() +cont_catcher(int x) { #ifndef lint sigset(SIGCONT,cont_catcher); @@ -110,7 +110,7 @@ int status; /* come here on signal other than interrupt, stop, or cont */ void -sig_catcher(signo) +sig_catcher(int signo) { #ifdef VERBOSE static char *signame[] = { @@ -204,7 +204,7 @@ sig_catcher(signo) /* come here on stop signal */ void -stop_catcher() +stop_catcher(int sig) { if (!waiting) { resetty(); /* this is the point of all this */ diff --git a/warp/sig.h b/warp/sig.h index 46fe7d80..d8537059 100644 --- a/warp/sig.h +++ b/warp/sig.h @@ -6,10 +6,10 @@ * */ -void sig_catcher(); +void sig_catcher(int); #ifdef SIGTSTP -void cont_catcher(); -void stop_catcher(); +void cont_catcher(int); +void stop_catcher(int); #endif void mytstp(); void sig_init(); diff --git a/warp/sm.c b/warp/sm.c index 8fb657c3..4bbe328f 100644 --- a/warp/sm.c +++ b/warp/sm.c @@ -8,8 +8,10 @@ #include #include +#include #include "config.h" +int main() { char screen[23][90], buf[10]; diff --git a/warp/term.c b/warp/term.c index 27c36b01..76723df4 100644 --- a/warp/term.c +++ b/warp/term.c @@ -556,9 +556,9 @@ rewrite() display_status(); } -char +int cmstore(ch) -Reg1 char ch; +Reg1 int ch; { *maxcmstring++ = ch; } diff --git a/warp/term.h b/warp/term.h index 0c13d324..1ae6f164 100644 --- a/warp/term.h +++ b/warp/term.h @@ -12,6 +12,16 @@ * */ +#ifndef TERM_H +#define TERM_H + +#include "util.h" + +/* Compat with old termios. */ +#ifndef ECHO +#define ECHO 8 +#endif + /* warp will still work without the following, but may get ahead at low speed */ #ifdef TIOCOUTQ /* chars left in output queue */ #define output_pending() (ioctl(1, TIOCOUTQ, &iocount),iocount) @@ -110,7 +120,7 @@ EXT char INTRCH INIT('\03'); # endif /* lint */ # else /* RDCHK */ # ifndef O_NDELAY /* assert O_NDELAY */ - ??? PENDING isn't defined correctly in warp.h + ??? PENDING is not defined correctly in warp.h # endif EXT int devtty INIT(0); # ifndef lint @@ -121,7 +131,7 @@ EXT char INTRCH INIT('\03'); # endif /* RDCHK */ # endif /* FIONREAD */ # else /* PENDING */ - ??? warp won't work without PENDING + ??? warp will not work without PENDING # ifndef lint # define input_pending() (nextin!=nextout) # else @@ -149,7 +159,7 @@ EXT char INTRCH INIT('\03'); # endif /* lint */ # else /* RDCHK */ # ifndef O_NDELAY /* assert O_NDELAY */ - ??? PENDING isn't defined correctly in warp.h + ??? PENDING is not defined correctly in warp.h # endif EXT int devtty INIT(0); EXT bool is_input INIT(FALSE); @@ -163,7 +173,7 @@ EXT char INTRCH INIT('\03'); # endif /* RDCHK */ # endif /* FIONREAD */ # else /* PENDING */ - ??? warp won't work without PENDING + ??? warp will not work without PENDING # define read_tty(addr,size) read(0,addr,size) # define input_pending() (FALSE) # endif /* PENDING */ @@ -278,7 +288,6 @@ EXT char KILLCH; /* line delete character */ #define standout() do_tc(SO,1) #define un_standout() do_tc(SE,1) #define up_line() do_tc(UP,1) -#define carriage_return() do_tc(CR,1) #define dingaling() do_tc(VB,1) #else ???????? /* up to you */ @@ -305,4 +314,6 @@ void do_tc(); int comp_tc(); void helper(); void rewrite(); -char cmstore(); +int cmstore(int); + +#endif diff --git a/warp/util.c b/warp/util.c index 246f0de9..4f5d2960 100644 --- a/warp/util.c +++ b/warp/util.c @@ -97,7 +97,6 @@ safemalloc(size) MEM_SIZE size; { char *ptr; - char *malloc(); ptr = malloc(size?size:1); /* malloc(0) is NASTY on our system */ if (ptr != Nullch) diff --git a/warp/util.h b/warp/util.h index 9ae4332c..65381869 100644 --- a/warp/util.h +++ b/warp/util.h @@ -54,7 +54,7 @@ void movc3(); void no_can_do(); int exdis(); -EXT bool waiting INIT(FALSE); /* are we waiting for subprocess (in doshell)? */ +#define waiting 0 #ifdef NOTDEF EXT int len_last_line_got INIT(0); diff --git a/warp/version.c b/warp/version.c index 03dcd449..50c29cb6 100644 --- a/warp/version.c +++ b/warp/version.c @@ -10,6 +10,8 @@ #include "INTERN.h" #include "version.h" +#include + /* Print out the version number. */ void diff --git a/warp/warp.c b/warp/warp.c index 2c1c0948..e2571775 100644 --- a/warp/warp.c +++ b/warp/warp.c @@ -132,6 +132,7 @@ char rcsid[] = "@(#)Header: warp.c,v 7.0.1.3 86/12/12 17:07:44 lwall Exp"; #include "version.h" #include "weapon.h" +int main(argc,argv) int argc; char *argv[]; diff --git a/warp/warp.h b/warp/warp.h index 984c407f..77035fdd 100644 --- a/warp/warp.h +++ b/warp/warp.h @@ -12,16 +12,23 @@ * */ +#ifndef WARP_H +#define WARP_H + extern int errno; #include "config.h" /* generated by Configure script */ +#include #include #include #include #include #include #include +#include +#include +#include /* WARPLIB must be readable and writeable by warp, but not by anyone who you * don't trust. In other words, to set up warp so everyone can play and @@ -32,7 +39,7 @@ extern int errno; * access.) */ -#define SAVEDIR "./" +#define SAVEDIR "/var/games" #define NEWSFILE "warp.news" #define HELPFILE "warp.doc" #define LOCKFILE ".warp.lock" @@ -100,6 +107,8 @@ EXT char amb[YSIZE][XSIZE]; #ifdef TERMIO # include +#elif defined TERMIOS +# include #else # include #endif @@ -429,10 +438,6 @@ EXT int ambsize; EXT char spbuf[512]; -char *index(), *ttyname(), *malloc(), *ctime(), *strcpy(); -char *getenv(), cmstore(), *tgoto(); -long atol(); - #define Fclose (void)fclose #define Fflush (void)fflush #define Fgets (void)fgets @@ -443,3 +448,5 @@ long atol(); #define Tract (void)tract #define Make_object (void)make_object #define Read_tty (void)read_tty + +#endif diff --git a/warp/warp.news b/warp/warp.news index eef59cdf..2fedc67c 100644 --- a/warp/warp.news +++ b/warp/warp.news @@ -1,4 +1,3 @@ *** WARP NEWS *** -Welcome to warp! Please send any gripes, comments, fantastic ideas, etc. -to lwall@sdcrdcf.uucp (Larry Wall). +Welcome to warp! -- cgit v1.2.3-56-ge451