diff options
-rw-r--r-- | games/bcd/bcd.c | 10 | ||||
-rw-r--r-- | games/dm/dm.c | 5 | ||||
-rw-r--r-- | games/factor/factor.c | 12 | ||||
-rw-r--r-- | games/fish/fish.c | 40 | ||||
-rw-r--r-- | games/mille/comp.c | 8 | ||||
-rw-r--r-- | games/mille/extern.c | 33 | ||||
-rw-r--r-- | games/mille/mille.c | 7 | ||||
-rw-r--r-- | games/mille/mille.h | 29 | ||||
-rw-r--r-- | games/mille/misc.c | 9 | ||||
-rw-r--r-- | games/mille/move.c | 17 | ||||
-rw-r--r-- | games/mille/print.c | 6 | ||||
-rw-r--r-- | games/mille/save.c | 19 | ||||
-rw-r--r-- | games/mille/types.c | 5 | ||||
-rw-r--r-- | games/number/number.c | 30 | ||||
-rw-r--r-- | games/primes/pattern.c | 7 | ||||
-rw-r--r-- | games/primes/pr_tbl.c | 7 | ||||
-rw-r--r-- | games/primes/primes.c | 24 | ||||
-rw-r--r-- | games/primes/primes.h | 1 | ||||
-rw-r--r-- | games/wump/wump.c | 22 |
19 files changed, 135 insertions, 156 deletions
diff --git a/games/bcd/bcd.c b/games/bcd/bcd.c index f6e08871897..44bb47462fc 100644 --- a/games/bcd/bcd.c +++ b/games/bcd/bcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcd.c,v 1.5 1998/08/19 07:40:15 pjanzen Exp $ */ +/* $OpenBSD: bcd.c,v 1.6 1999/09/25 15:52:09 pjanzen Exp $ */ /* $NetBSD: bcd.c,v 1.6 1995/04/24 12:22:23 cgd Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94"; #else -static char rcsid[] = "$OpenBSD: bcd.c,v 1.5 1998/08/19 07:40:15 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: bcd.c,v 1.6 1999/09/25 15:52:09 pjanzen Exp $"; #endif #endif /* not lint */ @@ -160,9 +160,9 @@ void printcard(str) char *str; { - static char rowchars[] = " 123456789"; - register int i, row; - register char *p; + static const char rowchars[] = " 123456789"; + int i, row; + char *p; /* ruthlessly remove newlines and truncate at 48 characters. */ if ((p = strchr(str, '\n'))) diff --git a/games/dm/dm.c b/games/dm/dm.c index fa5362a454a..ef500d7cba2 100644 --- a/games/dm/dm.c +++ b/games/dm/dm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dm.c,v 1.12 1999/08/16 17:00:14 millert Exp $ */ +/* $OpenBSD: dm.c,v 1.13 1999/09/25 15:52:19 pjanzen Exp $ */ /* $NetBSD: dm.c,v 1.5 1996/02/06 22:47:20 jtc Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)dm.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: dm.c,v 1.12 1999/08/16 17:00:14 millert Exp $"; +static char rcsid[] = "$OpenBSD: dm.c,v 1.13 1999/09/25 15:52:19 pjanzen Exp $"; #endif #endif /* not lint */ @@ -56,7 +56,6 @@ static char rcsid[] = "$OpenBSD: dm.c,v 1.12 1999/08/16 17:00:14 millert Exp $"; #include <err.h> #include <errno.h> #include <fcntl.h> -#include <nlist.h> #include <pwd.h> #include <stdio.h> #include <stdlib.h> diff --git a/games/factor/factor.c b/games/factor/factor.c index d79e19e6efd..87bdb4a5cca 100644 --- a/games/factor/factor.c +++ b/games/factor/factor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: factor.c,v 1.5 1998/08/19 07:40:28 pjanzen Exp $ */ +/* $OpenBSD: factor.c,v 1.6 1999/09/25 15:52:19 pjanzen Exp $ */ /* $NetBSD: factor.c,v 1.5 1995/03/23 08:28:07 cgd Exp $ */ /* @@ -45,9 +45,9 @@ static char copyright[] = #ifndef lint #if 0 -static char sccsid[] = "@(#)factor.c 8.3 (Berkeley) 3/30/94"; +static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$OpenBSD: factor.c,v 1.5 1998/08/19 07:40:28 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: factor.c,v 1.6 1999/09/25 15:52:19 pjanzen Exp $"; #endif #endif /* not lint */ @@ -87,8 +87,8 @@ static char rcsid[] = "$OpenBSD: factor.c,v 1.5 1998/08/19 07:40:28 pjanzen Exp * We are able to sieve 2^32-1 because this byte table yields all primes * up to 65537 and 65537^2 > 2^32-1. */ -extern ubig prime[]; -extern ubig *pr_limit; /* largest prime in the prime array */ +extern const ubig prime[]; +extern const ubig *pr_limit; /* largest prime in the prime array */ void pr_fact __P((ubig)); /* print factors of a value */ void usage __P((void)); @@ -169,7 +169,7 @@ void pr_fact(val) ubig val; /* Factor this value. */ { - ubig *fact; /* The factor found. */ + const ubig *fact; /* The factor found. */ /* Firewall - catch 0 and 1. */ if (val == 0) /* Historical practice; 0 just exits. */ diff --git a/games/fish/fish.c b/games/fish/fish.c index dbd6245a2b3..5501e874579 100644 --- a/games/fish/fish.c +++ b/games/fish/fish.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fish.c,v 1.5 1999/06/10 22:58:24 pjanzen Exp $ */ +/* $OpenBSD: fish.c,v 1.6 1999/09/25 15:52:19 pjanzen Exp $ */ /* $NetBSD: fish.c,v 1.3 1995/03/23 08:28:18 cgd Exp $ */ /*- @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: fish.c,v 1.5 1999/06/10 22:58:24 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: fish.c,v 1.6 1999/09/25 15:52:19 pjanzen Exp $"; #endif #endif /* not lint */ @@ -71,7 +71,7 @@ static char rcsid[] = "$OpenBSD: fish.c,v 1.5 1999/06/10 22:58:24 pjanzen Exp $" #define COMPUTER 0 #define OTHER(a) (1 - (a)) -char *cards[] = { +const char *const cards[] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", NULL, }; @@ -81,10 +81,10 @@ int promode; int asked[RANKS], comphand[RANKS], deck[RANKS]; int userasked[RANKS], userhand[RANKS]; -void chkwinner __P((int, int *)); +void chkwinner __P((int, const int *)); int compmove __P((void)); -int countbooks __P((int *)); -int countcards __P((int *)); +int countbooks __P((const int *)); +int countcards __P((const int *)); int drawcard __P((int, int *)); int getans __P((const char *)); int gofish __P((int, int, int *)); @@ -92,7 +92,7 @@ void goodmove __P((int, int, int *, int *)); void init __P((void)); void instructions __P((void)); int nrandom __P((int)); -void printhand __P((int *)); +void printhand __P((const int *)); void printplayer __P((int)); int promove __P((void)); void usage __P((void)); @@ -117,8 +117,7 @@ main(argc, argv) case '?': case 'h': default: - (void)fprintf(stderr, "usage: fish [-p]\n"); - exit(1); + usage(); } srandom(time((time_t *)NULL)); @@ -158,8 +157,8 @@ istart: for (;;) { int usermove() { - register int n; - register char **p; + int n; + const char *const *p; char buf[256]; (void)printf("\nYour hand is:"); @@ -231,7 +230,7 @@ compmove() int promove() { - register int i, max; + int i, max; for (i = 0; i < RANKS; ++i) if (userasked[i] && @@ -333,9 +332,10 @@ goodmove(player, move, hand, opphand) void chkwinner(player, hand) - int player, *hand; + int player; + const int *hand; { - register int cb, i, ub; + int cb, i, ub; for (i = 0; i < RANKS; ++i) if (hand[i] > 0 && hand[i] < CARDS) @@ -376,9 +376,9 @@ printplayer(player) void printhand(hand) - int *hand; + const int *hand; { - register int book, i, j; + int book, i, j; for (book = i = 0; i < RANKS; i++) if (hand[i] < CARDS) @@ -397,9 +397,9 @@ printhand(hand) int countcards(hand) - int *hand; + const int *hand; { - register int i, count; + int i, count; for (count = i = 0; i < RANKS; i++) count += *hand++; @@ -408,7 +408,7 @@ countcards(hand) int countbooks(hand) - int *hand; + const int *hand; { int i, count; @@ -426,7 +426,7 @@ countbooks(hand) void init() { - register int i, rank; + int i, rank; for (i = 0; i < RANKS; ++i) deck[i] = CARDS; diff --git a/games/mille/comp.c b/games/mille/comp.c index 8763e0c92e3..e653418fdbf 100644 --- a/games/mille/comp.c +++ b/games/mille/comp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comp.c,v 1.2 1998/09/22 04:08:21 pjanzen Exp $ */ +/* $OpenBSD: comp.c,v 1.3 1999/09/25 15:52:19 pjanzen Exp $ */ /* $NetBSD: comp.c,v 1.4 1995/03/24 05:01:11 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)comp.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: comp.c,v 1.2 1998/09/22 04:08:21 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: comp.c,v 1.3 1999/09/25 15:52:19 pjanzen Exp $"; #endif #endif /* not lint */ @@ -408,7 +408,7 @@ play_it: */ int onecard(pp) - PLAY *pp; + const PLAY *pp; { CARD bat, spd, card; @@ -441,7 +441,7 @@ onecard(pp) int canplay(pp, op, card) - PLAY *pp, *op; + const PLAY *pp, *op; CARD card; { switch (card) { diff --git a/games/mille/extern.c b/games/mille/extern.c index 2c99d07f2d9..fddfd7632db 100644 --- a/games/mille/extern.c +++ b/games/mille/extern.c @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.c,v 1.2 1998/09/22 04:08:22 pjanzen Exp $ */ +/* $OpenBSD: extern.c,v 1.3 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: extern.c,v 1.4 1995/03/24 05:01:36 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: extern.c,v 1.2 1998/09/22 04:08:22 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: extern.c,v 1.3 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ @@ -55,10 +55,10 @@ bool Debug, /* set if debugging code on */ Order, /* set if hand should be sorted */ Saved; /* set if game just saved */ -char *C_fmt = "%-18.18s", /* format for printing cards */ - *Fromfile = NULL, /* startup file for game */ - Initstr[100], /* initial string for error field */ - *_cn[NUM_CARDS] = { /* Card name buffer */ +char Initstr[100], /* initial string for error field */ + *C_fmt = "%-18.18s"; /* format for printing cards */ +const char *Fromfile = NULL, /* startup file for game */ + *const _cn[NUM_CARDS] = { /* Card name buffer */ "", "25", "50", @@ -80,7 +80,7 @@ char *C_fmt = "%-18.18s", /* format for printing cards */ "Driving Ace", "Right of Way" }, - **C_name = &_cn[1]; /* Card names */ + *const *C_name = &_cn[1]; /* Card names */ int Card_no, /* Card number for current move */ End, /* End value for current hand */ @@ -89,8 +89,9 @@ int Card_no, /* Card number for current move */ Play, /* Current player */ Numgos, /* Number of Go cards used by computer */ Window = W_SMALL, /* Current window wanted */ - Numseen[NUM_CARDS], /* Number of cards seen in current hand */ - Value[NUM_MILES] = { /* Value of mileage cards */ + Numseen[NUM_CARDS]; /* Number of cards seen in current hand */ + +const int Value[NUM_MILES] = { /* Value of mileage cards */ 25, 50, 75, 100, 200 }, Numcards[NUM_CARDS] = { /* Number of cards in deck */ @@ -114,8 +115,8 @@ int Card_no, /* Card number for current move */ 1, /* C_DRIVE_SAFE */ 1, /* C_RIGHT_WAY */ 0 /* C_INIT */ - }, - Numneed[NUM_CARDS] = { /* number of cards needed per hand */ + }; +int Numneed[NUM_CARDS] = { /* number of cards needed per hand */ 0, /* C_25 */ 0, /* C_50 */ 0, /* C_75 */ @@ -138,14 +139,14 @@ int Card_no, /* Card number for current move */ 0 /* C_INIT */ }; -CARD Discard, /* Top of discard pile */ - Sh_discard, /* Last discard card shown */ - *Topcard, /* Pointer to next card to be picked */ - Opposite[NUM_CARDS] = { /* Opposites of each card */ +const CARD Opposite[NUM_CARDS] = { /* Opposites of each card */ C_25, C_50, C_75, C_100, C_200, C_GAS, C_SPARE, C_REPAIRS, C_GO, C_END_LIMIT, C_EMPTY, C_FLAT, C_CRASH, C_STOP, C_LIMIT, C_EMPTY, C_FLAT, C_CRASH, C_STOP, C_INIT - }, + }; +CARD Discard, /* Top of discard pile */ + Sh_discard, /* Last discard card shown */ + *Topcard, /* Pointer to next card to be picked */ Deck[DECK_SZ] = { /* Current deck */ C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_25, C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, C_50, diff --git a/games/mille/mille.c b/games/mille/mille.c index 62a73f38c99..b457035854e 100644 --- a/games/mille/mille.c +++ b/games/mille/mille.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mille.c,v 1.6 1998/09/22 04:08:23 pjanzen Exp $ */ +/* $OpenBSD: mille.c,v 1.7 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: mille.c,v 1.4 1995/03/24 05:01:48 cgd Exp $ */ /* @@ -44,15 +44,12 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mille.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: mille.c,v 1.6 1998/09/22 04:08:23 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: mille.c,v 1.7 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ # include "mille.h" # include <signal.h> -# ifdef attron -# include <term.h> -# endif attron /* * @(#)mille.c 1.3 (Berkeley) 5/10/83 diff --git a/games/mille/mille.h b/games/mille/mille.h index 697634b3041..cfb84c16042 100644 --- a/games/mille/mille.h +++ b/games/mille/mille.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mille.h,v 1.3 1998/09/22 04:08:23 pjanzen Exp $ */ +/* $OpenBSD: mille.h,v 1.4 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: mille.h,v 1.5 1995/03/24 05:01:51 cgd Exp $ */ /* @@ -161,11 +161,6 @@ # ifdef SYSV # define srandom(x) srand(x) # define random() rand() - -# ifndef attron -# define erasechar() _tty.c_cc[VERASE] -# define killchar() _tty.c_cc[VKILL] -# endif # endif /* SYSV */ typedef struct { @@ -213,13 +208,15 @@ typedef struct { extern bool Debug, Finished, Next, On_exit, Order, Saved; -extern char *C_fmt, **C_name, *Fromfile, Initstr[]; +extern char Initstr[], *C_fmt; +extern const char *const *C_name, *Fromfile; -extern int Card_no, End, Handstart, Movetype, Numcards[], Numgos, - Numneed[], Numseen[NUM_CARDS], Play, Value[], Window; +extern int Card_no, End, Handstart, Movetype, Numgos, + Numneed[], Numseen[NUM_CARDS], Play, Window; +extern const int Numcards[], Value[]; -extern CARD Deck[DECK_SZ], Discard, Opposite[NUM_CARDS], Sh_discard, - *Topcard; +extern CARD Deck[DECK_SZ], Discard, Sh_discard, *Topcard; +extern const CARD Opposite[NUM_CARDS]; extern FILE *outf; @@ -233,7 +230,7 @@ extern WINDOW *Board, *Miles, *Score; void account __P((CARD)); void calcmove __P((void)); -int canplay __P((PLAY *, PLAY *, CARD)); +int canplay __P((const PLAY *, const PLAY *, CARD)); int check_ext __P((bool)); void check_go __P((void)); void check_more __P((void)); @@ -244,19 +241,19 @@ void finalscore __P((PLAY *)); CARD getcard __P((void)); void getmove __P((void)); int getyn __P((int)); -int haspicked __P((PLAY *)); +int haspicked __P((const PLAY *)); void init __P((void)); int isrepair __P((CARD)); int main __P((int, char **)); void newboard __P((void)); void newscore __P((void)); -int onecard __P((PLAY *)); +int onecard __P((const PLAY *)); int playcard __P((PLAY *)); void prboard __P((void)); void prompt __P((int)); -void prscore __P((int)); +void prscore __P((bool)); int readch __P((void)); -bool rest_f __P((char *)); +bool rest_f __P((const char *)); int roll __P((int, int)); void rub __P((int)); int safety __P((CARD)); diff --git a/games/mille/misc.c b/games/mille/misc.c index 08f71780677..8a6f8f2e814 100644 --- a/games/mille/misc.c +++ b/games/mille/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.3 1998/09/22 04:08:23 pjanzen Exp $ */ +/* $OpenBSD: misc.c,v 1.4 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: misc.c,v 1.4 1995/03/24 05:01:54 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: misc.c,v 1.3 1998/09/22 04:08:23 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: misc.c,v 1.4 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ @@ -53,11 +53,6 @@ static char rcsid[] = "$OpenBSD: misc.c,v 1.3 1998/09/22 04:08:23 pjanzen Exp $" #include "mille.h" -# ifdef attron -# include <term.h> -# define _tty cur_term->Nttyb -# endif attron - /* * @(#)misc.c 1.2 (Berkeley) 3/28/83 */ diff --git a/games/mille/move.c b/games/mille/move.c index 0f4aa63a146..eb347b1e44c 100644 --- a/games/mille/move.c +++ b/games/mille/move.c @@ -1,4 +1,4 @@ -/* $OpenBSD: move.c,v 1.4 1998/09/22 04:08:24 pjanzen Exp $ */ +/* $OpenBSD: move.c,v 1.5 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: move.c,v 1.4 1995/03/24 05:01:57 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: move.c,v 1.4 1998/09/22 04:08:24 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: move.c,v 1.5 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ @@ -49,11 +49,6 @@ static char rcsid[] = "$OpenBSD: move.c,v 1.4 1998/09/22 04:08:24 pjanzen Exp $" #include <termios.h> #include "mille.h" -# ifdef attron -# include <term.h> -# define _tty cur_term->Nttyb -# endif attron - /* * @(#)move.c 1.2 (Berkeley) 3/28/83 */ @@ -61,10 +56,6 @@ static char rcsid[] = "$OpenBSD: move.c,v 1.4 1998/09/22 04:08:24 pjanzen Exp $" #undef CTRL #define CTRL(c) (c - 'A' + 1) -char *Movenames[] = { - "M_DISCARD", "M_DRAW", "M_PLAY", "M_ORDER" - }; - void domove() { @@ -488,7 +479,7 @@ ret: */ int haspicked(pp) - PLAY *pp; + const PLAY *pp; { int card; @@ -536,7 +527,7 @@ void prompt(promptno) int promptno; { - static char *names[] = { + static const char *const names[] = { ">>:Move:", "Really?", "Another hand?", diff --git a/games/mille/print.c b/games/mille/print.c index 2fb09670da0..9780ccce29f 100644 --- a/games/mille/print.c +++ b/games/mille/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $ */ +/* $OpenBSD: print.c,v 1.4 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: print.c,v 1.4 1995/03/24 05:02:02 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: print.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: print.c,v 1.4 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ @@ -70,7 +70,7 @@ prboard() show_card(14, temp, pp->battle, &pp->sh_battle); show_card(16, temp, pp->speed, &pp->sh_speed); for (i = C_25; i <= C_200; i++) { - char *name; + const char *name; int end; if (pp->nummiles[i] == pp->sh_nummiles[i]) diff --git a/games/mille/save.c b/games/mille/save.c index 5ad1ff7708e..3e8263ec1e2 100644 --- a/games/mille/save.c +++ b/games/mille/save.c @@ -1,4 +1,4 @@ -/* $OpenBSD: save.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $ */ +/* $OpenBSD: save.c,v 1.4 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: save.c,v 1.4 1995/03/24 05:02:13 cgd Exp $ */ /* @@ -38,17 +38,13 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: save.c,v 1.3 1998/09/22 04:08:24 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: save.c,v 1.4 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ +#include <time.h> #include "mille.h" -# ifdef attron -# include <term.h> -# define _tty cur_term->Nttyb -# endif attron - /* * @(#)save.c 1.2 (Berkeley) 3/28/83 */ @@ -72,10 +68,9 @@ save() sp = NULL; tp = &tme; - if (Fromfile && getyn(SAMEFILEPROMPT)) { - strncpy(buf, Fromfile, sizeof(buf)); - buf[sizeof(buf) - 1] = '\0'; - } else { + if (Fromfile && getyn(SAMEFILEPROMPT)) + strlcpy(buf, Fromfile, sizeof(buf)); + else { over: prompt(FILEPROMPT); leaveok(Board, FALSE); @@ -147,7 +142,7 @@ over: */ bool rest_f(file) - char *file; + const char *file; { char *sp; int inf; diff --git a/games/mille/types.c b/games/mille/types.c index fe296659ac5..e7bbe110c95 100644 --- a/games/mille/types.c +++ b/games/mille/types.c @@ -1,4 +1,4 @@ -/* $OpenBSD: types.c,v 1.3 1998/09/22 04:08:25 pjanzen Exp $ */ +/* $OpenBSD: types.c,v 1.4 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: types.c,v 1.4 1995/03/24 05:02:22 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)types.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: types.c,v 1.3 1998/09/22 04:08:25 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: types.c,v 1.4 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ @@ -80,5 +80,6 @@ safety(card) case C_END_LIMIT: return C_RIGHT_WAY; } + errx(1, "safety() failed; please submit bug report."); /* NOTREACHED */ } diff --git a/games/number/number.c b/games/number/number.c index 3e56679cbb4..a1264570812 100644 --- a/games/number/number.c +++ b/games/number/number.c @@ -1,4 +1,4 @@ -/* $OpenBSD: number.c,v 1.6 1998/03/25 08:45:25 pjanzen Exp $ */ +/* $OpenBSD: number.c,v 1.7 1999/09/25 15:52:20 pjanzen Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -41,9 +41,9 @@ static char copyright[] = #ifndef lint #if 0 -static char sccsid[] = "@(#)number.c 8.2 (Berkeley) 3/31/94"; +static char sccsid[] = "@(#)number.c 8.3 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$OpenBSD: number.c,v 1.6 1998/03/25 08:45:25 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: number.c,v 1.7 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ @@ -59,19 +59,19 @@ static char rcsid[] = "$OpenBSD: number.c,v 1.6 1998/03/25 08:45:25 pjanzen Exp #define MAXNUM 65 /* Biggest number we handle. */ #define LINELEN 256 -static char *name1[] = { +static const char *const name1[] = { "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", }, - *name2[] = { + *const name2[] = { "", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety", }, - *name3[] = { + *const name3[] = { "hundred", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion", "sextillion", "septillion", "octillion", "nonillion", "decillion", @@ -83,10 +83,10 @@ static char *name1[] = { void convert __P((char *)); void convertexp __P((char *)); -int number __P((char *, int)); +int number __P((const char *, int)); void pfract __P((int)); void toobig __P((void)); -int unit __P((int, char *)); +int unit __P((int, const char *)); void usage __P((void)); int lflag; @@ -225,7 +225,7 @@ convertexp(line) char tmp[2]; int i, j; - (void)strncpy(locline,line,LINELEN); + (void)strlcpy(locline,line,LINELEN); part3 = locline; part2 = strsep(&part3, "eE"); /* part3 is the exponent */ part4 = part3; @@ -262,10 +262,10 @@ convertexp(line) int unit(len, p) - register int len; - register char *p; + int len; + const char *p; { - register int off, rval; + int off, rval; rval = 0; if (len > 3) { @@ -298,10 +298,10 @@ unit(len, p) int number(p, len) - register char *p; + const char *p; int len; { - register int val, rval; + int val, rval; rval = 0; switch (len) { @@ -340,7 +340,7 @@ void pfract(len) int len; { - static char *pref[] = { "", "ten-", "hundred-" }; + static const char *const pref[] = { "", "ten-", "hundred-" }; switch(len) { case 1: diff --git a/games/primes/pattern.c b/games/primes/pattern.c index a3beb53fe8b..81fb01dede0 100644 --- a/games/primes/pattern.c +++ b/games/primes/pattern.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pattern.c,v 1.3 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: pattern.c,v 1.3 1995/03/23 08:35:47 cgd Exp $ */ /* @@ -40,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)pattern.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pattern.c,v 1.3 1995/03/23 08:35:47 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pattern.c,v 1.3 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ @@ -56,7 +57,7 @@ static char rcsid[] = "$NetBSD: pattern.c,v 1.3 1995/03/23 08:35:47 cgd Exp $"; * with 1. All non-zero elements are factors of 3, 5, 7, 11 and 13. */ -char pattern[] = { +const char pattern[] = { 1,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0, 1,0,1,0,0,1,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0,1,1,0,0, 1,0,0,1,0,1,0,0,1,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,0,1, @@ -443,4 +444,4 @@ char pattern[] = { 0,0,1,1,0,0,0,0,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1, 0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,1 }; -int pattern_size = (sizeof(pattern)/sizeof(pattern[0])); +const int pattern_size = (sizeof(pattern)/sizeof(pattern[0])); diff --git a/games/primes/pr_tbl.c b/games/primes/pr_tbl.c index f92f21f3ffe..51ee1033a9d 100644 --- a/games/primes/pr_tbl.c +++ b/games/primes/pr_tbl.c @@ -1,3 +1,4 @@ +/* $OpenBSD: pr_tbl.c,v 1.2 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: pr_tbl.c,v 1.3 1995/03/23 08:35:52 cgd Exp $ */ /* @@ -40,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)pr_tbl.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: pr_tbl.c,v 1.3 1995/03/23 08:35:52 cgd Exp $"; +static char rcsid[] = "$OpenBSD: pr_tbl.c,v 1.2 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ @@ -57,7 +58,7 @@ static char rcsid[] = "$NetBSD: pr_tbl.c,v 1.3 1995/03/23 08:35:52 cgd Exp $"; #include "primes.h" -ubig prime[] = { +const ubig prime[] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103, 107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199, 211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313, @@ -549,4 +550,4 @@ ubig prime[] = { }; /* pr_limit - largest prime in the prime table */ -unsigned long *pr_limit = &prime[(sizeof(prime)/sizeof(prime[0]))-1]; +const unsigned long *pr_limit = &prime[(sizeof(prime)/sizeof(prime[0]))-1]; diff --git a/games/primes/primes.c b/games/primes/primes.c index 179489da472..6b49386aa01 100644 --- a/games/primes/primes.c +++ b/games/primes/primes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: primes.c,v 1.5 1998/08/19 07:40:52 pjanzen Exp $ */ +/* $OpenBSD: primes.c,v 1.6 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: primes.c,v 1.5 1995/04/24 12:24:47 cgd Exp $ */ /* @@ -45,9 +45,9 @@ static char copyright[] = #ifndef lint #if 0 -static char sccsid[] = "@(#)primes.c 8.4 (Berkeley) 3/21/94"; +static char sccsid[] = "@(#)primes.c 8.5 (Berkeley) 5/10/95"; #else -static char rcsid[] = "$OpenBSD: primes.c,v 1.5 1998/08/19 07:40:52 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: primes.c,v 1.6 1999/09/25 15:52:20 pjanzen Exp $"; #endif #endif /* not lint */ @@ -98,16 +98,16 @@ char table[TABSIZE]; /* Eratosthenes sieve of odd numbers */ * We are able to sieve 2^32-1 because this byte table yields all primes * up to 65537 and 65537^2 > 2^32-1. */ -extern ubig prime[]; -extern ubig *pr_limit; /* largest prime in the prime array */ +extern const ubig prime[]; +extern const ubig *pr_limit; /* largest prime in the prime array */ /* * To avoid excessive sieves for small factors, we use the table below to * setup our sieve blocks. Each element represents a odd number starting * with 1. All non-zero elements are factors of 3, 5, 7, 11 and 13. */ -extern char pattern[]; -extern int pattern_size; /* length of pattern array */ +extern const char pattern[]; +extern const int pattern_size; /* length of pattern array */ void primes __P((ubig, ubig)); ubig read_num_buf __P((void)); @@ -229,11 +229,11 @@ primes(start, stop) ubig start; /* where to start generating */ ubig stop; /* don't generate at or above this value */ { - register char *q; /* sieve spot */ - register ubig factor; /* index and factor */ - register char *tab_lim; /* the limit to sieve on the table */ - register ubig *p; /* prime table pointer */ - register ubig fact_lim; /* highest prime for current block */ + char *q; /* sieve spot */ + ubig factor; /* index and factor */ + char *tab_lim; /* the limit to sieve on the table */ + const ubig *p; /* prime table pointer */ + ubig fact_lim; /* highest prime for current block */ /* * A number of systems can not convert double values into unsigned diff --git a/games/primes/primes.h b/games/primes/primes.h index 3197d271b78..ae993d6240d 100644 --- a/games/primes/primes.h +++ b/games/primes/primes.h @@ -1,3 +1,4 @@ +/* $OpenBSD: primes.h,v 1.2 1999/09/25 15:52:20 pjanzen Exp $ */ /* $NetBSD: primes.h,v 1.4 1995/03/23 08:35:58 cgd Exp $ */ /* diff --git a/games/wump/wump.c b/games/wump/wump.c index 928fbd9dae2..ec2df32bba7 100644 --- a/games/wump/wump.c +++ b/games/wump/wump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wump.c,v 1.11 1999/08/17 09:13:12 millert Exp $ */ +/* $OpenBSD: wump.c,v 1.12 1999/09/25 15:52:21 pjanzen Exp $ */ /* * Copyright (c) 1989, 1993 @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)wump.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: wump.c,v 1.11 1999/08/17 09:13:12 millert Exp $"; +static char rcsid[] = "$OpenBSD: wump.c,v 1.12 1999/09/25 15:52:21 pjanzen Exp $"; #endif #endif /* not lint */ @@ -65,6 +65,7 @@ static char rcsid[] = "$OpenBSD: wump.c,v 1.11 1999/08/17 09:13:12 millert Exp $ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <unistd.h> #include "pathnames.h" @@ -272,7 +273,7 @@ quiver holds %d custom super anti-evil Wumpus arrows. Good luck.\n", void display_room_stats() { - register int i; + int i; /* * Routine will explain what's going on with the current room, as well @@ -555,9 +556,8 @@ into room %d!\n", arrow_location, next, cave[arrow_location].tunnel[link]); void cave_init() { - register int i, j, k, link; - int delta, int_compare(); - time_t time(); + int i, j, k, link; + int delta; /* * This does most of the interesting work in this program actually! @@ -644,7 +644,7 @@ try_again: link = (random() % room_num) + 1; void clear_things_in_cave() { - register int i; + int i; /* * remove bats and pits from the current cave in preparation for us @@ -657,7 +657,7 @@ clear_things_in_cave() void initialize_things_in_cave() { - register int i, loc; + int i, loc; /* place some bats, pits, the wumpus, and the player. */ for (i = 0; i < bat_num; ++i) { @@ -730,7 +730,7 @@ getans(prompt) int bats_nearby() { - register int i; + int i; /* check for bats in the immediate vicinity */ for (i = 0; i < link_num; ++i) @@ -742,7 +742,7 @@ bats_nearby() int pit_nearby() { - register int i; + int i; /* check for pits in the immediate vicinity */ for (i = 0; i < link_num; ++i) @@ -754,7 +754,7 @@ pit_nearby() int wump_nearby() { - register int i, j; + int i, j; /* check for a wumpus within TWO caves of where we are */ for (i = 0; i < link_num; ++i) { |