diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 1999-09-25 15:52:22 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 1999-09-25 15:52:22 +0000 |
commit | 1f392a4b5afa2c9b7442b8574263220a9400956f (patch) | |
tree | 86df7545a070242cc88b1c37212ee0954992be45 /games/mille | |
parent | 14e587faa87cde5eab2f480ee4d6f8e56f18a4a1 (diff) |
Tidying and minor changes from or based on jsm28@cam.ac.uk's work for the
Linux bsd-games package and NetBSD. Mainly using 'const'.
Diffstat (limited to 'games/mille')
-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 |
9 files changed, 55 insertions, 78 deletions
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 */ } |