Date: Fri, 6 Aug 1999 21:10:04 -0700 (PDT) From: "Stephen J. Roznowski" <sjr@home.net> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/12727: Game patches from NetBSD Message-ID: <199908070410.VAA56173@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/12727; it has been noted by GNATS.
From: "Stephen J. Roznowski" <sjr@home.net>
To: freebsd-gnats-submit@freebsd.org
Cc:
Subject: Re: bin/12727: Game patches from NetBSD
Date: Fri, 6 Aug 1999 23:59:47 -0400 (EDT)
Joseph Myers (jsm28@cam.ac.uk) has submitted a series of
patches for games to NetBSD. This update incorporates the
following NetBSD patches:
bin/8056 - Atc memory allocation checks
bin/8057 - More backgammon(6) const fixes
bin/8062 - Atc: use getopt
bin/8080 - Backgammon malloc checks
bin/8081 - Backgammon bug fix
bin/8085 - Battlestar save file handling 2
bin/8091 - Atc getAChar() cleanup
bin/8092 - Backgammon executable save files relic
bin/8093 - Bcd const/unsigned fixes
bin/8104 - Backgammon trivial fix
bin/8102 - Bcd(6) references
bin/8103 - Worm display fix
bin/8105 - Adventure extern/common fixes
Additionally, I've patched the following files to use
symbolic values for the lseek() settings:
hack/hack.save.c
larn/io.c
robots/score.c
snake/snake/snake.c
fortune/fortune/fortune.c
Also, for the files that were patched, I deleted
all of the "register" declarations.
diff -ur games-990720+patches/adventure/hdr.h games-990720+patches2/adventure/hdr.h
--- games-990720+patches/adventure/hdr.h Tue Jul 20 20:54:53 1999
+++ games-990720+patches2/adventure/hdr.h Fri Aug 6 22:40:18 1999
@@ -58,9 +58,9 @@
#include <sys/types.h>
#include <signal.h>
-int datfd; /* message file descriptor */
-volatile sig_atomic_t delhit;
-int yea;
+extern int datfd; /* message file descriptor */
+extern volatile sig_atomic_t delhit;
+extern int yea;
extern char data_file[]; /* Virtual data file */
#define TAB 011
@@ -68,18 +68,18 @@
#define FLUSHLINE do { int flushline_ch; while ((flushline_ch = getchar()) != EOF && flushline_ch != '\n'); } while (0)
#define FLUSHLF while (next()!=LF)
-int loc,newloc,oldloc,oldlc2,wzdark,gaveup,kq,k,k2;
-char *wd1,*wd2; /* the complete words */
-int verb,obj,spk;
+extern int loc,newloc,oldloc,oldlc2,wzdark,gaveup,kq,k,k2;
+extern char *wd1,*wd2; /* the complete words */
+extern int verb,obj,spk;
extern int blklin;
-int saveday,savet,mxscor,latncy;
+extern int saveday,savet,mxscor,latncy;
#define SHORT 50 /* How short is a demo game? */
#define MAXSTR 20 /* max length of user's words */
#define HTSIZE 512 /* max number of vocab words */
-struct hashtab /* hash table for vocabulary */
+extern struct hashtab /* hash table for vocabulary */
{ int val; /* word type &index (ktab) */
char *atab; /* pointer to actual string */
} voc[HTSIZE];
@@ -87,61 +87,58 @@
#define SEED 1815622 /* "Encryption" seed */
struct text
-#ifdef OLDSTUFF
-{ int seekadr; /* DATFILE must be < 2**16 */
-#endif OLDSTUFF
{ char *seekadr; /* Msg start in virtual disk */
int txtlen; /* length of msg starting here */
};
#define RTXSIZ 205
-struct text rtext[RTXSIZ]; /* random text messages */
+extern struct text rtext[RTXSIZ]; /* random text messages */
#define MAGSIZ 35
-struct text mtext[MAGSIZ]; /* magic messages */
+extern struct text mtext[MAGSIZ]; /* magic messages */
-int clsses;
+extern int clsses;
#define CLSMAX 12
-struct text ctext[CLSMAX]; /* classes of adventurer */
-int cval[CLSMAX];
+extern struct text ctext[CLSMAX]; /* classes of adventurer */
+extern int cval[CLSMAX];
-struct text ptext[101]; /* object descriptions */
+extern struct text ptext[101]; /* object descriptions */
#define LOCSIZ 141 /* number of locations */
-struct text ltext[LOCSIZ]; /* long loc description */
-struct text stext[LOCSIZ]; /* short loc descriptions */
+extern struct text ltext[LOCSIZ]; /* long loc description */
+extern struct text stext[LOCSIZ]; /* short loc descriptions */
-struct travlist /* direcs & conditions of travel*/
+extern struct travlist /* direcs & conditions of travel*/
{ struct travlist *next; /* ptr to next list entry */
int conditions; /* m in writeup (newloc / 1000) */
int tloc; /* n in writeup (newloc % 1000) */
int tverb; /* the verb that takes you there*/
} *travel[LOCSIZ],*tkk; /* travel is closer to keys(...)*/
-int atloc[LOCSIZ];
+extern int atloc[LOCSIZ];
-int plac[101]; /* initial object placement */
-int fixd[101],fixed[101]; /* location fixed? */
+extern int plac[101]; /* initial object placement */
+extern int fixd[101],fixed[101]; /* location fixed? */
-int actspk[35]; /* rtext msg for verb <n> */
+extern int actspk[35]; /* rtext msg for verb <n> */
-int cond[LOCSIZ]; /* various condition bits */
+extern int cond[LOCSIZ]; /* various condition bits */
extern int setbit[16]; /* bit defn masks 1,2,4,... */
-int hntmax;
-int hints[20][5]; /* info on hints */
-int hinted[20],hintlc[20];
+extern int hntmax;
+extern int hints[20][5]; /* info on hints */
+extern int hinted[20],hintlc[20];
-int place[101], prop[101],linkx[201];
-int abb[LOCSIZ];
+extern int place[101], prop[101],linkx[201];
+extern int abb[LOCSIZ];
-int maxtrs,tally,tally2; /* treasure values */
+extern int maxtrs,tally,tally2; /* treasure values */
#define FALSE 0
#define TRUE 1
-int keys,lamp,grate,cage,rod,rod2,steps,/* mnemonics */
+extern int keys,lamp,grate,cage,rod,rod2,steps,/* mnemonics */
bird,door,pillow,snake,fissur,tablet,clam,oyster,magzin,
dwarf,knife,food,bottle,water,oil,plant,plant2,axe,mirror,dragon,
chasm,troll,troll2,bear,messag,vend,batter,
@@ -151,15 +148,15 @@
enter, stream, pour,
say,lock,throw,find,invent;
-int chloc,chloc2,dseen[7],dloc[7], /* dwarf stuff */
+extern int chloc,chloc2,dseen[7],dloc[7], /* dwarf stuff */
odloc[7],dflag,daltlc;
-int tk[21],stick,dtotal,attack;
-int turns,lmwarn,iwest,knfloc,detail, /* various flags & counters */
+extern int tk[21],stick,dtotal,attack;
+extern int turns,lmwarn,iwest,knfloc,detail, /* various flags & counters*/
abbnum,maxdie,numdie,holdng,dkill,foobar,bonus,clock1,clock2,
saved,closng,panic,closed,scorng;
-int demo,newloc,limit;
+extern int demo,newloc,limit;
char *decr();
unsigned long crc();
@@ -167,4 +164,4 @@
/* We need to get a little tricky to avoid strings */
#define DECR(a,b,c,d,e) decr('a'+'+','b'+'-','c'+'#','d'+'&','e'+'%')
-gid_t egid;
+extern gid_t egid;
diff -ur games-990720+patches/adventure/init.c games-990720+patches2/adventure/init.c
--- games-990720+patches/adventure/init.c Sun Apr 18 23:58:42 1999
+++ games-990720+patches2/adventure/init.c Fri Aug 6 22:40:58 1999
@@ -53,6 +53,72 @@
int setbit[16] = {1,2,4,010,020,040,0100,0200,0400,01000,02000,04000,
010000,020000,040000,0100000};
+int datfd; /* message file descriptor */
+volatile sig_atomic_t delhit;
+int yea;
+
+int loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2;
+char *wd1, *wd2; /* the complete words */
+int verb, obj, spk;
+int saveday, savet, mxscor, latncy;
+
+struct hashtab voc[HTSIZE];
+
+struct text rtext[RTXSIZ]; /* random text messages */
+
+struct text mtext[MAGSIZ]; /* magic messages */
+
+int clsses;
+
+struct text ctext[CLSMAX]; /* classes of adventurer */
+int cval[CLSMAX];
+
+struct text ptext[101]; /* object descriptions */
+
+struct text ltext[LOCSIZ]; /* long loc description */
+struct text stext[LOCSIZ]; /* short loc descriptions */
+
+struct travlist *travel[LOCSIZ], *tkk; /* travel is closer to keys(...) */
+
+int atloc[LOCSIZ];
+
+int plac[101]; /* initial object placement */
+int fixd[101], fixed[101]; /* location fixed? */
+
+int actspk[35]; /* rtext msg for verb <n> */
+
+int cond[LOCSIZ]; /* various condition bits */
+
+int hntmax;
+int hints[20][5]; /* info on hints */
+int hinted[20], hintlc[20];
+
+int place[101], prop[101], linkx[201];
+int abb[LOCSIZ];
+
+int maxtrs, tally, tally2; /* treasure values */
+
+int keys, lamp, grate, cage, rod, rod2, steps, /* mnemonics */
+ bird, door, pillow, snake, fissur, tablet, clam, oyster,
+ magzin, dwarf, knife, food, bottle, water, oil, plant, plant2,
+ axe, mirror, dragon, chasm, troll, troll2, bear, messag,
+ vend, batter, nugget, coins, chest, eggs, tridnt, vase,
+ emrald, pyram, pearl, rug, chain, spices, back, look, cave,
+ null, entrnc, dprssn, enter, stream, pour, say, lock, throw,
+ find, invent;
+
+int chloc, chloc2, dseen[7], dloc[7], /* dwarf stuff */
+ odloc[7], dflag, daltlc;
+
+int tk[21], stick, dtotal, attack;
+int turns, lmwarn, iwest, knfloc, detail, /* various flags and
+ * counters */
+ abbnum, maxdie, numdie, holdng, dkill, foobar, bonus, clock1,
+ clock2, saved, closng, panic, closed, scorng;
+
+int demo, newloc, limit;
+
+gid_t egid;
init() /* everything for 1st time run */
{
diff -ur games-990720+patches/atc/graphics.c games-990720+patches2/atc/graphics.c
--- games-990720+patches/atc/graphics.c Sun Apr 18 23:58:50 1999
+++ games-990720+patches2/atc/graphics.c Fri Aug 6 22:17:53 1999
@@ -49,9 +49,7 @@
#include <string.h>
#include "include.h"
-#ifdef SYSV
#include <errno.h>
-#endif
#define C_TOPBOTTOM '-'
#define C_LEFTRIGHT '|'
@@ -65,15 +63,14 @@
getAChar()
{
-#ifdef BSD
- return (getchar());
-#endif
-#ifdef SYSV
int c;
- while ((c = getchar()) == -1 && errno == EINTR) ;
+ errno = 0;
+ while ((c = getchar()) == -1 && errno == EINTR) {
+ errno = 0;
+ clearerr(stdin);
+ }
return(c);
-#endif
}
erase_all()
@@ -124,7 +121,7 @@
setup_screen(scp)
const C_SCREEN *scp;
{
- register int i, j;
+ int i, j;
char str[3];
const char *airstr;
@@ -381,7 +378,11 @@
wmove(input, 0, 0);
wclrtobot(input);
- wprintw(input, "Plane '%c' %s\n\nHit space for top players list...",
+ /* p may be NULL if we ran out of memory */
+ if (p == NULL)
+ wprintw(input, "%s\n\nHit space for top players list...", s);
+ else
+ wprintw(input, "Plane '%c' %s\n\nHit space for top players list...",
name(p), s);
wrefresh(input);
fflush(stdout);
diff -ur games-990720+patches/atc/main.c games-990720+patches2/atc/main.c
--- games-990720+patches/atc/main.c Sun May 2 22:08:18 1999
+++ games-990720+patches2/atc/main.c Fri Aug 6 22:18:34 1999
@@ -54,6 +54,7 @@
#endif /* not lint */
#include <string.h>
+#include <unistd.h>
#include "include.h"
#include "pathnames.h"
@@ -65,7 +66,7 @@
int f_usage = 0, f_list = 0, f_showscore = 0;
int f_printpath = 0;
const char *file = NULL;
- char *name, *ptr;
+ int ch;
#ifdef BSD
struct itimerval itv;
#endif
@@ -77,57 +78,41 @@
setregid(getgid(), getgid());
start_time = time(0);
-
- name = *av++;
- while (*av) {
-#ifndef SAVEDASH
- if (**av == '-')
- *++*av;
- else
+ while ((ch = getopt(ac, av, "ulstpg:f:r:")) != -1) {
+ switch (ch) {
+ case '?':
+ case 'u':
+ default:
+ f_usage++;
+ break;
+ case 'l':
+ f_list++;
+ break;
+ case 's':
+ case 't':
+ f_showscore++;
+ break;
+ case 'p':
+ f_printpath++;
+ break;
+ case 'r':
+ seed = atoi(optarg);
+ break;
+ case 'f':
+ case 'g':
+ file = optarg;
break;
-#endif
- ptr = *av++;
- while (*ptr) {
- switch (*ptr) {
- case '?':
- case 'u':
- f_usage++;
- break;
- case 'l':
- f_list++;
- break;
- case 's':
- case 't':
- f_showscore++;
- break;
- case 'p':
- f_printpath++;
- break;
- case 'r':
- srandom(atoi(*av));
- seed = 1;
- av++;
- break;
- case 'f':
- case 'g':
- file = *av;
- av++;
- break;
- default:
- fprintf(stderr, "Unknown option '%c'\n", *ptr);
- f_usage++;
- break;
- }
- ptr++;
}
}
+ if (optind < ac)
+ f_usage++;
if (!seed)
srandomdev();
if (f_usage)
fprintf(stderr,
"Usage: %s -[u?lstp] [-[gf] game_name] [-r random seed]\n",
- name);
+ av[0]);
if (f_showscore)
log_score(1);
if (f_list)
diff -ur games-990720+patches/atc/update.c games-990720+patches2/atc/update.c
--- games-990720+patches/atc/update.c Sun Apr 18 23:58:51 1999
+++ games-990720+patches2/atc/update.c Fri Aug 6 21:42:42 1999
@@ -363,6 +363,8 @@
p.plane_no = pnum;
pp = newplane();
+ if (pp == NULL)
+ loser(pp, "Out of memory!");
bcopy(&p, pp, sizeof (p));
if (pp->orig_type == T_AIRPORT)
diff -ur games-990720+patches/backgammon/backgammon/main.c games-990720+patches2/backgammon/backgammon/main.c
--- games-990720+patches/backgammon/backgammon/main.c Tue Jul 20 20:50:01 1999
+++ games-990720+patches2/backgammon/backgammon/main.c Fri Aug 6 22:07:01 1999
@@ -69,7 +69,7 @@
};
static const char rules[] = "\nDo you want the rules of the game?";
-static const char noteach[] = "Teachgammon not available!\n\007";
+static const char noteach[] = "Teachgammon not available!\n\a";
static const char need[] = "Do you need instructions for this program?";
static const char askcol[] =
"Enter 'r' to play red, 'w' to play white, 'b' to play both:";
diff -ur games-990720+patches/backgammon/common_source/fancy.c games-990720+patches2/backgammon/common_source/fancy.c
--- games-990720+patches/backgammon/common_source/fancy.c Sun Apr 18 23:58:52 1999
+++ games-990720+patches2/backgammon/common_source/fancy.c Fri Aug 6 22:05:59 1999
@@ -84,7 +84,7 @@
int addbuf __P((int));
fboard () {
- register int i, j, l;
+ int i, j, l;
curmove (0,0); /* do top line */
for (i = 0; i < 53; i++)
@@ -198,11 +198,11 @@
int cnext; /* direction of position */
{
- register int j; /* index */
- register int n; /* number of men on position */
- register int bct; /* counter */
- int k; /* index */
- char pc; /* color of men on position */
+ int j; /* index */
+ int n; /* number of men on position */
+ int bct; /* counter */
+ int k; /* index */
+ char pc; /* color of men on position */
n = abs(b); /* initialize n and pc */
pc = (b > 0? 'r': 'w');
@@ -252,7 +252,7 @@
}
refresh() {
- register int i, r, c;
+ int i, r, c;
r = curr; /* save current position */
c = curc;
@@ -312,7 +312,7 @@
int old, new, r, c, inc;
{
- register int o, n, nv;
+ int o, n, nv;
int ov, nc;
char col;
@@ -379,11 +379,11 @@
}
fixcol (r,c,l,ch,inc)
-register int l, ch;
-int r, c, inc;
+int l, ch;
+int r, c, inc;
{
- register int i;
+ int i;
curmove (r,c);
fancyc (ch);
@@ -394,7 +394,7 @@
}
curmove (r,c)
-register int r, c;
+int r, c;
{
if (curr == r && curc == c)
@@ -408,9 +408,9 @@
}
newpos () {
- register int r; /* destination row */
- register int c; /* destination column */
- register int mode = -1; /* mode of movement */
+ int r; /* destination row */
+ int c; /* destination column */
+ int mode = -1; /* mode of movement */
int count = 1000; /* character count */
int i; /* index */
@@ -575,7 +575,7 @@
}
clear () {
- register int i;
+ int i;
/* double space if can't clear */
if (CL == 0) {
@@ -593,9 +593,9 @@
fancyc (c)
-register char c; /* character to output */
+char c; /* character to output */
{
- register int sp; /* counts spaces in a tab */
+ int sp; /* counts spaces in a tab */
if (c == '\007') { /* bells go in blindly */
addbuf (c);
@@ -649,8 +649,8 @@
}
clend() {
- register int i;
- register char *s;
+ int i;
+ char *s;
if (CD) {
@@ -671,9 +671,9 @@
}
cline () {
- register int i;
- register int c;
- register char *s;
+ int i;
+ int c;
+ char *s;
if (curc > linect[curr])
return;
@@ -705,10 +705,10 @@
const char *s;
{
- register char *code; /* two letter code */
- register char ***cap; /* pointer to cap string */
- char *bufp; /* pointer to cap buffer */
- char tentry[1024]; /* temporary uncoded caps buffer */
+ char *code; /* two letter code */
+ char ***cap; /* pointer to cap string */
+ char *bufp; /* pointer to cap buffer */
+ char tentry[1024]; /* temporary uncoded caps buffer */
tgetent (tentry, (char *)s); /* get uncoded termcap entry */
@@ -745,5 +745,9 @@
if (LI < 24 || CO < 72 || !(CL && UP && ND))
return (0);
linect = (int *)calloc (LI+1,sizeof(int));
+ if (linect == NULL) {
+ write(2, "\r\nOut of memory!\r\n", 18);
+ getout(0);
+ }
return (1);
}
diff -ur games-990720+patches/backgammon/common_source/save.c games-990720+patches2/backgammon/common_source/save.c
--- games-990720+patches/backgammon/common_source/save.c Sun Apr 18 23:58:52 1999
+++ games-990720+patches2/backgammon/common_source/save.c Fri Aug 6 22:04:46 1999
@@ -51,12 +51,12 @@
static const char cantrec[] = "Can't recover file: ";
save (n)
-register int n;
+int n;
{
- register int fdesc;
- register char *fs;
- char fname[50];
+ int fdesc;
+ char *fs;
+ char fname[50];
if (n) {
if (tflag) {
@@ -104,7 +104,7 @@
close (fdesc);
if (yorn (0)) {
unlink (fname);
- fdesc = creat (fname,0700);
+ fdesc = creat (fname,0600);
break;
} else {
cflag = 1;
@@ -146,7 +146,7 @@
const char *s;
{
- register int i;
+ int i;
int fdesc;
if ((fdesc = open (s,O_RDONLY)) == -1)
diff -ur games-990720+patches/backgammon/common_source/subs.c games-990720+patches2/backgammon/common_source/subs.c
--- games-990720+patches/backgammon/common_source/subs.c Sun Apr 18 23:58:52 1999
+++ games-990720+patches2/backgammon/common_source/subs.c Fri Aug 6 22:05:10 1999
@@ -61,7 +61,7 @@
};
errexit (s)
-register char *s;
+char *s;
{
write (2,"\n",1);
perror (s);
@@ -69,7 +69,7 @@
}
int addbuf (c)
-register int c;
+int c;
{
buffnum++;
@@ -167,7 +167,7 @@
wrint (n)
int n;
{
- register int i, j, t;
+ int i, j, t;
for (i = 4; i > 0; i--) {
t = 1;
@@ -180,7 +180,7 @@
}
gwrite() {
- register int r, c;
+ int r, c;
if (tflag) {
r = curr;
@@ -222,7 +222,7 @@
}
quit () {
- register int i;
+ int i;
if (tflag) {
curmove (20,0);
@@ -243,10 +243,10 @@
}
yorn (special)
-register char special; /* special response */
+char special; /* special response */
{
- register char c;
- register int i;
+ char c;
+ int i;
i = 1;
while ( (c = readc()) != 'Y' && c != 'N') {
@@ -273,7 +273,7 @@
}
wrhit (i)
-register int i;
+int i;
{
writel ("Blot hit on ");
wrint (i);
@@ -282,7 +282,7 @@
}
nexturn () {
- register int c;
+ int c;
cturn = -cturn;
c = cturn/abs(cturn);
@@ -297,11 +297,11 @@
}
getarg (argc, argv)
-register int argc;
-register char **argv;
+int argc;
+char **argv;
{
- register char ch;
+ char ch;
extern int optind;
extern char *optarg;
int i;
@@ -367,7 +367,11 @@
case 's':
/* recover file */
- recover (optarg);
+ if (optarg == NULL) {
+ writel("No save file named\n");
+ getout(0);
+ } else
+ recover (optarg);
break;
case 'h':
for (i = 0; descr[i] != 0; i++)
@@ -382,7 +386,7 @@
}
init () {
- register int i;
+ int i;
for (i = 0; i < 26;)
board[i++] = 0;
board[1] = 2;
@@ -433,9 +437,9 @@
exit(0);
}
roll () {
- register char c;
- register int row;
- register int col;
+ char c;
+ int row;
+ int col;
if (iroll) {
if (tflag) {
diff -ur games-990720+patches/backgammon/teachgammon/ttext1.c games-990720+patches2/backgammon/teachgammon/ttext1.c
--- games-990720+patches/backgammon/teachgammon/ttext1.c Sun Apr 18 23:58:52 1999
+++ games-990720+patches2/backgammon/teachgammon/ttext1.c Fri Aug 6 21:46:05 1999
@@ -37,8 +37,8 @@
#include "back.h"
-const char *opts = " QIMRHEDSPT";
-const char *prompt = "-->";
+const char *const opts = " QIMRHEDSPT";
+const char *const prompt = "-->";
const char *const list[] = {
"\n\n\tI\tIntroduction to Backgammon",
diff -ur games-990720+patches/battlestar/battlestar.6 games-990720+patches2/battlestar/battlestar.6
--- games-990720+patches/battlestar/battlestar.6 Mon Jul 12 16:30:17 1999
+++ games-990720+patches2/battlestar/battlestar.6 Fri Aug 6 23:09:11 1999
@@ -39,7 +39,10 @@
.SH SYNOPSIS
.B battlestar
[
-.B -r (recover a saved game)
+.B -r
+]
+[
+.B saved-file
]
.br
.fi
@@ -129,10 +132,12 @@
in
the game.
.SH "SAVING A GAME"
-The command "save" will save your game in a file called "Bstar." You
-can
-recover a saved game by using the "-r" option when you start up the
-game.
+The command "save" will save your game in a file, by default called
+".Bstar" in your home directory. You
+can recover a saved game by using the
+.B -r
+option when you start up the
+game, or by giving the name of the saved file as an argument.
.SH DIRECTIONS
The compass directions N, S, E, and W can be used if you have a compass.
If you don't have a compass, you'll have to say R, L, A, or B, which
diff -ur games-990720+patches/battlestar/battlestar.c games-990720+patches2/battlestar/battlestar.c
--- games-990720+patches/battlestar/battlestar.c Sun Apr 18 23:58:53 1999
+++ games-990720+patches2/battlestar/battlestar.c Fri Aug 6 23:10:30 1999
@@ -62,7 +62,9 @@
/* revoke privs. */
setgid(getgid());
- initialize(argc < 2 || strcmp(argv[1], "-r"));
+ initialize((argc < 2) ? NULL : (strcmp(argv[1], "-r") ? argv[1]
+ : (argv[2] ? argv[2]
+ : DEFAULT_SAVE_FILE)));
start:
news();
beenthere[position]++;
diff -ur games-990720+patches/battlestar/cypher.c games-990720+patches2/battlestar/cypher.c
--- games-990720+patches/battlestar/cypher.c Sun Apr 18 23:58:53 1999
+++ games-990720+patches2/battlestar/cypher.c Fri Aug 6 23:16:54 1999
@@ -39,10 +39,12 @@
cypher()
{
- register int n;
+ int n;
int junk;
int lflag = -1;
char buffer[10];
+ char *filename, *rfilename;
+ size_t filename_len;
while (wordtype[wordnumber] == ADJS)
wordnumber++;
@@ -339,7 +341,21 @@
break;
case SAVE:
- save();
+ printf("\nSave file name (default %s) ",
+ DEFAULT_SAVE_FILE);
+ filename = fgetln(stdin, &filename_len);
+ if (filename_len == 0
+ || (filename_len == 1 && filename[0] == '\n'))
+ rfilename = save_file_name(DEFAULT_SAVE_FILE,
+ strlen(DEFAULT_SAVE_FILE));
+ else {
+ if (filename[filename_len - 1] == '\n')
+ filename_len--;
+ rfilename = save_file_name(filename,
+ filename_len);
+ }
+ save(rfilename);
+ free(rfilename);
break;
case FOLLOW:
diff -ur games-990720+patches/battlestar/externs.h games-990720+patches2/battlestar/externs.h
--- games-990720+patches/battlestar/externs.h Sun Apr 18 23:58:53 1999
+++ games-990720+patches2/battlestar/externs.h Fri Aug 6 23:19:31 1999
@@ -38,6 +38,7 @@
#include <sys/signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#define BITS (8)
@@ -302,3 +303,5 @@
extern const struct objs nightobjs[];
gid_t egid;
+
+#define DEFAULT_SAVE_FILE ".Bstar"
diff -ur games-990720+patches/battlestar/init.c games-990720+patches2/battlestar/init.c
--- games-990720+patches/battlestar/init.c Sun Apr 18 23:58:53 1999
+++ games-990720+patches2/battlestar/init.c Fri Aug 6 23:31:34 1999
@@ -41,10 +41,12 @@
#include <string.h>
initialize(startup)
- char startup;
+ const char *startup;
{
const struct objs *p;
+ char *savefile;
void die();
+ char *save_file_name();
puts("Version 4.2, fall 1984.");
puts("First Adventure game written by His Lordship, the honorable");
@@ -55,7 +57,7 @@
location = dayfile;
wiz = wizard(uname);
wordinit();
- if (startup) {
+ if (startup == NULL) {
direction = NORTH;
gtime = 0;
snooze = CYCLE * 1.5;
@@ -65,8 +67,11 @@
torps = TORPEDOES;
for (p = dayobjs; p->room != 0; p++)
setbit(location[p->room].objects, p->obj);
- } else
- restore();
+ } else {
+ savefile = save_file_name(startup, strlen(startup));
+ restore(savefile);
+ free(savefile);
+ }
signal(SIGINT, die);
}
diff -ur games-990720+patches/battlestar/save.c games-990720+patches2/battlestar/save.c
--- games-990720+patches/battlestar/save.c Sun Apr 18 23:58:54 1999
+++ games-990720+patches2/battlestar/save.c Fri Aug 6 23:30:32 1999
@@ -44,21 +44,17 @@
#include "externs.h"
void
-restore()
+restore(filename)
+const char *filename;
{
- char *home;
- char home1[MAXPATHLEN];
- register int n;
+ int n;
int tmp;
- register FILE *fp;
-
- if ( (home = getenv("HOME")) != NULL)
- sprintf(home1, "%.*s/Bstar", MAXPATHLEN - 7, home);
- else return;
+ FILE *fp;
- if ((fp = fopen(home1, "r")) == 0) {
- perror(home1);
- return;
+ if (filename == NULL)
+ exit(1); /* Error determining save file name. */
+ if ((fp = fopen(filename, "r")) == 0) {
+ err(1, "fopen %s", filename);
}
fread(&WEIGHT, sizeof WEIGHT, 1, fp);
fread(&CUMBER, sizeof CUMBER, 1, fp);
@@ -96,30 +92,27 @@
fread(&power, sizeof power, 1, fp);
/* We must check the last read, to catch truncated save files. */
if (fread(&ego, sizeof ego, 1, fp) < 1)
- errx(1, "save file %s too short", home1);
+ errx(1, "save file %s too short", filename);
fclose(fp);
}
void
-save()
+save(filename)
+const char *filename;
{
struct stat sbuf;
- char *home;
- char home1[MAXPATHLEN];
- register int n;
+ int n;
int tmp, fd;
FILE *fp;
- home = getenv("HOME");
- if (home == 0)
- return;
- sprintf(home1, "%.*s/Bstar", MAXPATHLEN - 7, home);
+ if (filename == NULL)
+ return; /* Error determining save file name. */
/* Try to open the file safely. */
- if (stat(home1, &sbuf) < 0) {
- fd = open(home1, O_WRONLY|O_CREAT|O_EXCL, 0600);
+ if (stat(filename, &sbuf) < 0) {
+ fd = open(filename, O_WRONLY|O_CREAT|O_EXCL, 0600);
if (fd < 0) {
- fprintf(stderr, "Can't create %s\n", home1);
+ fprintf(stderr, "Can't create %s\n", filename);
return;
}
} else {
@@ -128,19 +121,19 @@
return;
}
- fd = open(home1, O_WRONLY|O_EXCL);
+ fd = open(filename, O_WRONLY|O_EXCL);
if (fd < 0) {
- fprintf(stderr, "Can't open %s for writing\n", home1);
+ fprintf(stderr, "Can't open %s for writing\n", filename);
return;
}
}
if ((fp = fdopen(fd, "w")) == 0) {
- perror(home1);
+ perror(filename);
return;
}
- printf("Saved in %s.\n", home1);
+ printf("Saved in %s.\n", filename);
fwrite(&WEIGHT, sizeof WEIGHT, 1, fp);
fwrite(&CUMBER, sizeof CUMBER, 1, fp);
fwrite(&gclock, sizeof gclock, 1, fp);
@@ -176,4 +169,53 @@
fwrite(&pleasure, sizeof pleasure, 1, fp);
fwrite(&power, sizeof power, 1, fp);
fwrite(&ego, sizeof ego, 1, fp);
+}
+
+/*
+ * Given a save file name (possibly from fgetln, so without terminating NUL),
+ * determine the name of the file to be saved to by adding the HOME
+ * directory if the name does not contain a slash. Name will be allocated
+ * with malloc(3).
+ */
+char *
+save_file_name(filename, len)
+ const char *filename;
+ size_t len;
+{
+ char *home;
+ char *newname;
+ size_t tmpl;
+
+ if (memchr(filename, '/', len)) {
+ newname = malloc(len + 1);
+ if (newname == NULL) {
+ warnx("out of memory");
+ return NULL;
+ }
+ memcpy(newname, filename, len);
+ newname[len] = 0;
+ } else {
+ home = getenv("HOME");
+ if (home != NULL) {
+ tmpl = strlen(home);
+ newname = malloc(tmpl + len + 2);
+ if (newname == NULL) {
+ warnx("out of memory");
+ return NULL;
+ }
+ memcpy(newname, home, tmpl);
+ newname[tmpl] = '/';
+ memcpy(newname + tmpl + 1, filename, len);
+ newname[tmpl + len + 1] = 0;
+ } else {
+ newname = malloc(len + 1);
+ if (newname == NULL) {
+ warnx("out of memory");
+ return NULL;
+ }
+ memcpy(newname, filename, len);
+ newname[len] = 0;
+ }
+ }
+ return newname;
}
diff -ur games-990720+patches/bcd/bcd.6 games-990720+patches2/bcd/bcd.6
--- games-990720+patches/bcd/bcd.6 Mon Jul 12 16:30:18 1999
+++ games-990720+patches2/bcd/bcd.6 Fri Aug 6 22:09:14 1999
@@ -141,3 +141,17 @@
.Pp
Sends a bit slower than it should due to system overhead. Some people
would call this a feature.
+.Sh SEE ALSO
+.Rs
+.%B "ISO 1681:1973: Information processing--Unpunched paper cards--Specification"
+.Re
+.Rs
+.%B "ISO 1682:1973: Information processing--80 columns punched paper cards--Dimensions and location of rectangular punched holes"
+.Re
+.Rs
+.%B "ECMA-10: ECMA Standard for Data Interchange on Punched Tape"
+.Re
+.Rs
+.%B "ITU-T Recommendation F.1: Operational provisions for the international public telegram service"
+.%O "Division B, I. Morse code"
+.Re
diff -ur games-990720+patches/bcd/bcd.c games-990720+patches2/bcd/bcd.c
--- games-990720+patches/bcd/bcd.c Sun Apr 18 23:58:54 1999
+++ games-990720+patches2/bcd/bcd.c Fri Aug 6 22:03:19 1999
@@ -80,7 +80,7 @@
#include <string.h>
#include <ctype.h>
-u_short holes[256] = {
+const u_short holes[256] = {
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
@@ -147,11 +147,11 @@
#define COLUMNS 48
printcard(str)
- register char *str;
+ char *str;
{
- static char rowchars[] = " 123456789";
- register int i, row;
- register char *p;
+ static const char rowchars[] = " 123456789";
+ int i, row;
+ unsigned char *p;
char *index();
/* ruthlessly remove newlines and truncate at 48 characters. */
diff -ur games-990720+patches/fortune/fortune/fortune.c games-990720+patches2/fortune/fortune/fortune.c
--- games-990720+patches/fortune/fortune/fortune.c Fri Jun 11 00:36:16 1999
+++ games-990720+patches2/fortune/fortune/fortune.c Fri Aug 6 22:55:42 1999
@@ -240,8 +240,8 @@
display(fp)
FILEDESC *fp;
{
- register char *p;
- register unsigned char ch;
+ char *p;
+ unsigned char ch;
char line[BUFSIZ];
open_fp(fp);
@@ -269,7 +269,7 @@
int
fortlen()
{
- register int nchar;
+ int nchar;
char line[BUFSIZ];
if (!(Fortfile->tbl.str_flags & (STR_RANDOM | STR_ORDERED)))
@@ -291,12 +291,12 @@
*/
void
getargs(argc, argv)
-register int argc;
-register char **argv;
+int argc;
+char **argv;
{
- register int ignore_case;
+ int ignore_case;
# ifndef NO_REGEX
- register char *pat;
+ char *pat;
# endif /* NO_REGEX */
extern char *optarg;
extern int optind;
@@ -395,11 +395,11 @@
*/
int
form_file_list(files, file_cnt)
-register char **files;
-register int file_cnt;
+char **files;
+int file_cnt;
{
- register int i, percent;
- register char *sp;
+ int i, percent;
+ char *sp;
if (file_cnt == 0)
if (Find_files) {
@@ -459,16 +459,16 @@
int
add_file(percent, file, dir, head, tail, parent)
int percent;
-register char *file;
+char *file;
char *dir;
FILEDESC **head, **tail;
FILEDESC *parent;
{
- register FILEDESC *fp;
- register int fd;
- register char *path, *offensive;
- register bool was_malloc;
- register bool isdir;
+ FILEDESC *fp;
+ int fd;
+ char *path, *offensive;
+ bool was_malloc;
+ bool isdir;
if (dir == NULL) {
path = file;
@@ -589,7 +589,7 @@
FILEDESC *
new_fp()
{
- register FILEDESC *fp;
+ FILEDESC *fp;
fp = (FILEDESC *) do_malloc(sizeof *fp);
fp->datfd = -1;
@@ -642,13 +642,13 @@
*/
void
all_forts(fp, offensive)
-register FILEDESC *fp;
-char *offensive;
+FILEDESC *fp;
+char *offensive;
{
- register char *sp;
- register FILEDESC *scene, *obscene;
- register int fd;
- auto char *datfile, *posfile;
+ char *sp;
+ FILEDESC *scene, *obscene;
+ int fd;
+ auto char *datfile, *posfile;
if (fp->child != NULL) /* this is a directory, not a file */
return;
@@ -692,10 +692,10 @@
*/
int
add_dir(fp)
-register FILEDESC *fp;
+FILEDESC *fp;
{
- register DIR *dir;
- register struct dirent *dirent;
+ DIR *dir;
+ struct dirent *dirent;
auto FILEDESC *tailp;
auto char *name;
@@ -753,9 +753,9 @@
char *file, **datp, **posp;
int check_for_offend;
{
- register int i;
- register char *sp;
- register char *datfile;
+ int i;
+ char *sp;
+ char *datfile;
static char *suflist[] = { /* list of "illegal" suffixes" */
"dat", "pos", "c", "h", "p", "i", "f",
"pas", "ftn", "ins.c", "ins,pas",
@@ -880,8 +880,8 @@
void
init_prob()
{
- register FILEDESC *fp, *last = NULL;
- register int percent, num_noprob, frac;
+ FILEDESC *fp, *last = NULL;
+ int percent, num_noprob, frac;
/*
* Distribute the residual probability (if any) across all
@@ -952,8 +952,8 @@
void
get_fort()
{
- register FILEDESC *fp;
- register int choice;
+ FILEDESC *fp;
+ int choice;
if (File_list->next == NULL || File_list->percent == NO_PROB)
fp = File_list;
@@ -1002,7 +1002,8 @@
get_pos(fp);
open_dat(fp);
(void) lseek(fp->datfd,
- (off_t) (sizeof fp->tbl + fp->pos * sizeof Seekpts[0]), 0);
+ (off_t) (sizeof fp->tbl + fp->pos * sizeof Seekpts[0]),
+ SEEK_SET);
read(fp->datfd, Seekpts, sizeof Seekpts);
Seekpts[0] = ntohl(Seekpts[0]);
Seekpts[1] = ntohl(Seekpts[1]);
@@ -1016,8 +1017,8 @@
pick_child(parent)
FILEDESC *parent;
{
- register FILEDESC *fp;
- register int choice;
+ FILEDESC *fp;
+ int choice;
if (Equal_probs) {
choice = random() % parent->num_children;
@@ -1051,7 +1052,7 @@
*/
void
sum_noprobs(fp)
-register FILEDESC *fp;
+FILEDESC *fp;
{
static bool did_noprobs = FALSE;
@@ -1068,7 +1069,7 @@
int
max(i, j)
-register int i, j;
+int i, j;
{
return (i >= j ? i : j);
}
@@ -1141,8 +1142,8 @@
get_tbl(fp)
FILEDESC *fp;
{
- auto int fd;
- register FILEDESC *child;
+ auto int fd;
+ FILEDESC *child;
if (fp->read_tbl)
return;
@@ -1179,7 +1180,7 @@
*/
void
zero_tbl(tp)
-register STRFILE *tp;
+STRFILE *tp;
{
tp->str_numstr = 0;
tp->str_longlen = 0;
@@ -1192,7 +1193,7 @@
*/
void
sum_tbl(t1, t2)
-register STRFILE *t1, *t2;
+STRFILE *t1, *t2;
{
t1->str_numstr += t2->str_numstr;
if (t1->str_longlen < t2->str_longlen)
@@ -1219,8 +1220,8 @@
*/
void
print_list(list, lev)
-register FILEDESC *list;
-int lev;
+FILEDESC *list;
+int lev;
{
while (list != NULL) {
fprintf(stderr, "%*s", lev * 4, "");
@@ -1245,11 +1246,11 @@
*/
char *
conv_pat(orig)
-register char *orig;
+char *orig;
{
- register char *sp;
- register unsigned int cnt;
- register char *new;
+ char *sp;
+ unsigned int cnt;
+ char *new;
cnt = 1; /* allow for '\0' */
for (sp = orig; *sp != '\0'; sp++)
@@ -1308,8 +1309,8 @@
maxlen_in_list(list)
FILEDESC *list;
{
- register FILEDESC *fp;
- register int len, maxlen;
+ FILEDESC *fp;
+ int len, maxlen;
maxlen = 0;
for (fp = list; fp != NULL; fp = fp->next) {
@@ -1334,8 +1335,8 @@
matches_in_list(list)
FILEDESC *list;
{
- register char *sp, *p;
- register FILEDESC *fp;
+ char *sp, *p;
+ FILEDESC *fp;
int in_file;
unsigned char ch;
diff -ur games-990720+patches/hack/hack.save.c games-990720+patches2/hack/hack.save.c
--- games-990720+patches/hack/hack.save.c Sun Sep 4 00:02:53 1994
+++ games-990720+patches2/hack/hack.save.c Fri Aug 6 22:52:14 1999
@@ -31,7 +31,7 @@
/* returns 1 if save successful */
dosave0(hu) int hu; {
- register fd, ofd;
+ int fd, ofd;
int tmp; /* not register ! */
(void) signal(SIGHUP, SIG_IGN);
@@ -88,9 +88,9 @@
}
dorecover(fd)
-register fd;
+int fd;
{
- register nfd;
+ int nfd;
int tmp; /* not a register ! */
unsigned mid; /* idem */
struct obj *otmp;
@@ -133,7 +133,7 @@
savelev(nfd,tmp);
(void) close(nfd);
}
- (void) lseek(fd, (off_t)0, 0);
+ (void) lseek(fd, (off_t)0, SEEK_SET);
getlev(fd, 0, 0);
(void) close(fd);
(void) unlink(SAVEF);
@@ -153,7 +153,7 @@
}
}
if(u.ustuck) {
- register struct monst *mtmp;
+ struct monst *mtmp;
for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if(mtmp->m_id == mid) goto monfnd;
@@ -171,10 +171,10 @@
struct obj *
restobjchn(fd)
-register fd;
+int fd;
{
- register struct obj *otmp, *otmp2;
- register struct obj *first = 0;
+ struct obj *otmp, *otmp2;
+ struct obj *first = 0;
int xl;
#ifdef lint
/* suppress "used before set" warning from lint */
@@ -199,10 +199,10 @@
struct monst *
restmonchn(fd)
-register fd;
+int fd;
{
- register struct monst *mtmp, *mtmp2;
- register struct monst *first = 0;
+ struct monst *mtmp, *mtmp2;
+ struct monst *first = 0;
int xl;
struct permonst *monbegin;
diff -ur games-990720+patches/larn/io.c games-990720+patches2/larn/io.c
--- games-990720+patches/larn/io.c Wed Sep 24 16:17:31 1997
+++ games-990720+patches2/larn/io.c Fri Aug 6 22:51:19 1999
@@ -155,7 +155,7 @@
*/
newgame()
{
- register long *p,*pe;
+ long *p,*pe;
for (p=c,pe=c+100; p<pe; *p++ =0);
time(&initialtime); srandomdev();
lcreat((char*)0); /* open buffering for output to terminal */
@@ -197,9 +197,9 @@
va_dcl
{
va_list ap; /* pointer for variable argument list */
- register char *fmt;
- register char *outb,*tmpb;
- register long wide,left,cont,n; /* data for lprintf */
+ 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 */
@@ -279,7 +279,7 @@
* Returns nothing of value.
*/
lprint(x)
- register long x;
+ long x;
{
if (lpnt >= lpend) lflush();
*lpnt++ = 255 & x; *lpnt++ = 255 & (x>>8);
@@ -295,11 +295,11 @@
* Returns nothing of value
*/
lwrite(buf,len)
- register char *buf;
+ char *buf;
int len;
{
- register char *str;
- register int num2;
+ char *str;
+ int num2;
if (len > 399) /* don't copy data if can just write it */
{
#ifdef EXTRA
@@ -332,7 +332,7 @@
*/
long lgetc()
{
- register int i;
+ int i;
if (ipoint != iepoint) return(inbuffer[ipoint++]);
if (iepoint!=MAXIBUF) return(0);
if ((i=read(fd,inbuffer,MAXIBUF))<=0)
@@ -358,7 +358,7 @@
*/
long lrint()
{
- register unsigned long i;
+ unsigned long i;
i = 255 & lgetc(); i |= (255 & lgetc()) << 8;
i |= (255 & lgetc()) << 16; i |= (255 & lgetc()) << 24;
return(i);
@@ -373,11 +373,11 @@
* Returns nothing of value
*/
lrfill(adr,num)
- register char *adr;
+ char *adr;
int num;
{
- register char *pnt;
- register int num2;
+ char *pnt;
+ int num2;
while (num)
{
if (iepoint == ipoint)
@@ -407,8 +407,8 @@
*/
char *lgetw()
{
- register char *lgp,cc;
- register int n=LINBUFSIZE,quote=0;
+ char *lgp,cc;
+ int n=LINBUFSIZE,quote=0;
lgp = lgetwbuf;
do cc=lgetc(); while ((cc <= 32) && (cc > NULL)); /* eat whitespace */
for ( ; ; --n,cc=lgetc())
@@ -426,8 +426,8 @@
*/
char *lgetl()
{
- register int i=LINBUFSIZE,ch;
- register char *str=lgetwbuf;
+ int i=LINBUFSIZE,ch;
+ char *str=lgetwbuf;
for ( ; ; --i)
{
if ((*str++ = ch = lgetc()) == NULL)
@@ -493,7 +493,7 @@
{
lfd=1; return(-1);
}
- lseek(lfd,0,2); /* seek to end of file */
+ lseek(lfd,0,SEEK_END); /* seek to end of file */
return(lfd);
}
@@ -522,9 +522,9 @@
* avoids calls to lprintf (time consuming)
*/
lprcat(str)
- register char *str;
+ char *str;
{
- register char *str2;
+ char *str2;
if (lpnt >= lpend) lflush();
str2 = lpnt;
while (*str2++ = *str++);
@@ -556,7 +556,7 @@
cursor(x,y)
int x,y;
{
- register char *p;
+ char *p;
if (lpnt >= lpend) lflush();
p = y_num[y]; /* get the string to print */
@@ -679,12 +679,12 @@
* cl_up(x,y) Clear screen from [x,1] to current position. Leave cursor at [x,y]
*/
cl_up(x,y)
- register int x,y;
+ int x,y;
{
#ifdef VT100
cursor(x,y); lprcat("\33[1J\33[2K");
#else VT100
- register int i;
+ int i;
cursor(1,1);
for (i=1; i<=y; i++) { *lpnt++ = CL_LINE; *lpnt++ = '\n'; }
cursor(x,y);
@@ -695,12 +695,12 @@
* cl_dn(x,y) Clear screen from [1,y] to end of display. Leave cursor at [x,y]
*/
cl_dn(x,y)
- register int x,y;
+ int x,y;
{
#ifdef VT100
cursor(x,y); lprcat("\33[J\33[2K");
#else VT100
- register int i;
+ int i;
cursor(1,y);
if (!CD)
{
@@ -718,7 +718,7 @@
* standout(str) Print the argument string in inverse video (standout mode).
*/
standout(str)
- register char *str;
+ char *str;
{
#ifdef VT100
setbold();
@@ -752,8 +752,8 @@
static int scrline=18; /* line # for wraparound instead of scrolling if no DL */
lflush ()
{
- register int lpoint;
- register char *str;
+ int lpoint;
+ char *str;
static int curx = 0;
static int cury = 0;
@@ -838,7 +838,7 @@
*/
lflush()
{
- register int lpoint;
+ int lpoint;
if ((lpoint = lpnt - lpbuf) > 0)
{
#ifdef EXTRA
@@ -878,9 +878,9 @@
* Processes only the \33[#m sequence (converts . files for termcap use
*/
char *tmcapcnv(sd,ss)
- register char *sd,*ss;
+ char *sd,*ss;
{
- register int tmstate=0; /* 0=normal, 1=\33 2=[ 3=# */
+ int tmstate=0; /* 0=normal, 1=\33 2=[ 3=# */
char tmdigit=0; /* the # in \33[#m */
while (*ss)
{
diff -ur games-990720+patches/robots/score.c games-990720+patches2/robots/score.c
--- games-990720+patches/robots/score.c Tue Jun 30 15:10:47 1998
+++ games-990720+patches2/robots/score.c Fri Aug 6 22:52:56 1999
@@ -61,10 +61,10 @@
*/
score()
{
- register int inf;
- register SCORE *scp;
- register int uid;
- register bool done_show = FALSE;
+ int inf;
+ SCORE *scp;
+ int uid;
+ bool done_show = FALSE;
static int numscores, max_uid;
Newscore = FALSE;
@@ -129,7 +129,7 @@
refresh();
if (Newscore) {
- lseek(inf, 0L, 0);
+ lseek(inf, 0L, SEEK_SET);
write(inf, &max_uid, sizeof max_uid);
write(inf, Top, sizeof Top);
}
@@ -137,9 +137,9 @@
}
set_name(scp)
-register SCORE *scp;
+SCORE *scp;
{
- register PASSWD *pp;
+ PASSWD *pp;
if ((pp = getpwuid(scp->s_uid)) == NULL)
pp->pw_name = "???";
@@ -151,7 +151,7 @@
* Compare two scores.
*/
cmp_sc(s1, s2)
-register SCORE *s1, *s2;
+SCORE *s1, *s2;
{
return s2->s_score - s1->s_score;
}
@@ -162,8 +162,8 @@
*/
show_score()
{
- register SCORE *scp;
- register int inf;
+ SCORE *scp;
+ int inf;
static int max_score;
if ((inf = open(Scorefile, 0)) < 0) {
diff -ur games-990720+patches/snake/snake/snake.c games-990720+patches2/snake/snake/snake.c
--- games-990720+patches/snake/snake/snake.c Sun May 23 19:17:28 1999
+++ games-990720+patches2/snake/snake/snake.c Fri Aug 6 22:53:48 1999
@@ -415,7 +415,7 @@
drawbox()
{
- register int i;
+ int i;
struct point p;
p.line = -1;
@@ -444,7 +444,7 @@
struct point *sp;
{
struct point p;
- register int i;
+ int i;
for (;;) {
p.col = random() % ccnt;
@@ -493,14 +493,14 @@
/* Figure out what happened in the past */
read(rawscores, &allbscore, sizeof(short));
read(rawscores, &allbwho, sizeof(short));
- lseek(rawscores, ((off_t)uid)*sizeof(short), 0);
+ lseek(rawscores, ((off_t)uid)*sizeof(short), SEEK_SET);
read(rawscores, &oldbest, sizeof(short));
if (!flag)
return (score > oldbest ? 1 : 0);
/* Update this jokers best */
if (score > oldbest) {
- lseek(rawscores, ((off_t)uid)*sizeof(short), 0);
+ lseek(rawscores, ((off_t)uid)*sizeof(short), SEEK_SET);
write(rawscores, &score, sizeof(short));
pr("You bettered your previous best of $%d\n", oldbest);
} else
@@ -509,7 +509,7 @@
/* See if we have a new champ */
p = getpwuid(allbwho);
if (p == NULL || score > allbscore) {
- lseek(rawscores, (off_t)0, 0);
+ lseek(rawscores, (off_t)0, SEEK_SET);
write(rawscores, &score, sizeof(short));
write(rawscores, &uid, sizeof(short));
if (allbwho)
diff -ur games-990720+patches/worm/worm.c games-990720+patches2/worm/worm.c
--- games-990720+patches/worm/worm.c Wed Sep 24 18:29:08 1997
+++ games-990720+patches2/worm/worm.c Fri Aug 6 22:11:33 1999
@@ -135,8 +135,8 @@
life()
{
- register struct body *bp, *np;
- register int i;
+ struct body *bp, *np;
+ int i;
head = newlink();
head->x = start_len+2;
@@ -206,7 +206,7 @@
process(ch)
char ch;
{
- register int x,y;
+ int x,y;
struct body *nh;
alarm(0);
@@ -261,7 +261,10 @@
display(nh, HEAD);
head = nh;
if (!(slow && running))
+ {
+ wmove(tv, head->y, head->x);
wrefresh(tv);
+ }
if (!running)
alarm(1);
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908070410.VAA56173>
