diff options
author | dholland <dholland@NetBSD.org> | 2009-08-12 06:19:17 +0000 |
---|---|---|
committer | dholland <dholland@NetBSD.org> | 2009-08-12 06:19:17 +0000 |
commit | 31f496067cd42ce5ff71163efa5921ab6522e4aa (patch) | |
tree | 91bcc67080a700414d760c85ef7a3cd21fb0319b /gomoku | |
parent | 9b4f22d74f6cba399615723bd7b666b854c15788 (diff) | |
download | bsdgames-darwin-31f496067cd42ce5ff71163efa5921ab6522e4aa.tar.gz bsdgames-darwin-31f496067cd42ce5ff71163efa5921ab6522e4aa.tar.zst bsdgames-darwin-31f496067cd42ce5ff71163efa5921ab6522e4aa.zip |
sprinkle static
Diffstat (limited to 'gomoku')
-rw-r--r-- | gomoku/bdinit.c | 8 | ||||
-rw-r--r-- | gomoku/gomoku.h | 21 | ||||
-rw-r--r-- | gomoku/main.c | 25 | ||||
-rw-r--r-- | gomoku/makemove.c | 10 | ||||
-rw-r--r-- | gomoku/pickmove.c | 74 | ||||
-rw-r--r-- | gomoku/stoc.c | 9 |
6 files changed, 80 insertions, 67 deletions
diff --git a/gomoku/bdinit.c b/gomoku/bdinit.c index 93a58f49..9592fe04 100644 --- a/gomoku/bdinit.c +++ b/gomoku/bdinit.c @@ -1,4 +1,4 @@ -/* $NetBSD: bdinit.c,v 1.7 2009/06/04 05:43:29 dholland Exp $ */ +/* $NetBSD: bdinit.c,v 1.8 2009/08/12 06:19:17 dholland Exp $ */ /* * Copyright (c) 1994 @@ -37,13 +37,15 @@ #if 0 static char sccsid[] = "from: @(#)bdinit.c 8.2 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: bdinit.c,v 1.7 2009/06/04 05:43:29 dholland Exp $"); +__RCSID("$NetBSD: bdinit.c,v 1.8 2009/08/12 06:19:17 dholland Exp $"); #endif #endif /* not lint */ #include <string.h> #include "gomoku.h" +static void init_overlap(void); + void bdinit(struct spotstr *bp) { @@ -170,7 +172,7 @@ bdinit(struct spotstr *bp) * As pieces are played, it can make frames not overlap if there are no * common open spaces shared between the two frames. */ -void +static void init_overlap(void) { struct spotstr *sp1, *sp2; diff --git a/gomoku/gomoku.h b/gomoku/gomoku.h index 16a437ae..bf83379a 100644 --- a/gomoku/gomoku.h +++ b/gomoku/gomoku.h @@ -1,4 +1,4 @@ -/* $NetBSD: gomoku.h,v 1.16 2009/07/13 19:05:40 roy Exp $ */ +/* $NetBSD: gomoku.h,v 1.17 2009/08/12 06:19:17 dholland Exp $ */ /* * Copyright (c) 1994 @@ -261,7 +261,6 @@ extern int debug; #define ASSERT(x) void bdinit(struct spotstr *); -void init_overlap(void); int get_line(char *, int); void ask(const char *); void dislog(const char *); @@ -272,30 +271,12 @@ void cursfini(void); void cursinit(void); void bdwho(int); void panic(const char *, ...) __printflike(1, 2) __dead; -void misclog(const char *, ...) __printflike(1, 2); void debuglog(const char *, ...) __printflike(1, 2); -void quit(void) __dead; -void quitsig(int) __dead; void whatsup(int); -int readinput(FILE *); const char *stoc(int); -int lton(int); int ctos(const char *); -void update_overlap(struct spotstr *); int makemove(int, int); int list_eq(struct combostr **, struct combostr **, int); void clearcombo(struct combostr *, int); -void makeempty(struct combostr *); -void appendcombo(struct combostr *, int); -void updatecombo(struct combostr *, int); void markcombo(struct combostr *); -void printcombo(struct combostr *, char *, size_t); -void makecombo(struct combostr *, struct spotstr *, int, int); -void makecombo2(struct combostr *, struct spotstr *, int, int); -int sortcombo(struct combostr **, struct combostr **, struct combostr *); -int checkframes(struct combostr *, struct combostr *, struct spotstr *, - int, struct overlap_info *); -void addframes(int); -void scanframes(int); -int better(const struct spotstr *, const struct spotstr *, int); int pickmove(int); diff --git a/gomoku/main.c b/gomoku/main.c index 79c3f18a..74fd9d76 100644 --- a/gomoku/main.c +++ b/gomoku/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.19 2009/07/13 19:05:40 roy Exp $ */ +/* $NetBSD: main.c,v 1.20 2009/08/12 06:19:17 dholland Exp $ */ /* * Copyright (c) 1994 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1994\ #if 0 static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: main.c,v 1.19 2009/07/13 19:05:40 roy Exp $"); +__RCSID("$NetBSD: main.c,v 1.20 2009/08/12 06:19:17 dholland Exp $"); #endif #endif /* not lint */ @@ -63,10 +63,10 @@ __RCSID("$NetBSD: main.c,v 1.19 2009/07/13 19:05:40 roy Exp $"); int interactive = 1; /* true if interactive */ int debug; /* true if debugging */ -int test; /* both moves come from 1: input, 2: computer */ -char *prog; /* name of program */ -FILE *debugfp; /* file for debug output */ -FILE *inputfp; /* file for debug input */ +static int test; /* both moves come from 1: input, 2: computer */ +static char *prog; /* name of program */ +static FILE *debugfp; /* file for debug output */ +static FILE *inputfp; /* file for debug input */ const char pdir[4] = "-\\|/"; @@ -79,7 +79,10 @@ int movelog[BSZ * BSZ]; /* log of all the moves */ int movenum; /* current move number */ const char *plyr[2]; /* who's who */ -int main(int, char *[]); +static int readinput(FILE *); +static void misclog(const char *, ...) __printflike(1, 2); +static void quit(void) __dead; +static void quitsig(int) __dead; int main(int argc, char **argv) @@ -329,7 +332,7 @@ again: return(0); } -int +static int readinput(FILE *fp) { int c; @@ -502,7 +505,7 @@ debuglog(const char *fmt, ...) fprintf(stderr, "%s\n", buf); } -void +static void misclog(const char *fmt, ...) { va_list ap; @@ -520,7 +523,7 @@ misclog(const char *fmt, ...) printf("%s\n", buf); } -void +static void quit(void) { if (interactive) { @@ -530,7 +533,7 @@ quit(void) exit(0); } -void +static void quitsig(int dummy __unused) { quit(); diff --git a/gomoku/makemove.c b/gomoku/makemove.c index c483aa9d..28ad355a 100644 --- a/gomoku/makemove.c +++ b/gomoku/makemove.c @@ -1,4 +1,4 @@ -/* $NetBSD: makemove.c,v 1.10 2009/06/04 05:43:29 dholland Exp $ */ +/* $NetBSD: makemove.c,v 1.11 2009/08/12 06:19:17 dholland Exp $ */ /* * Copyright (c) 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)makemove.c 8.2 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: makemove.c,v 1.10 2009/06/04 05:43:29 dholland Exp $"); +__RCSID("$NetBSD: makemove.c,v 1.11 2009/08/12 06:19:17 dholland Exp $"); #endif #endif /* not lint */ @@ -48,7 +48,9 @@ const int dd[4] = { MRIGHT, MRIGHT+MDOWN, MDOWN, MDOWN+MLEFT }; -const int weight[5] = { 0, 1, 7, 22, 100 }; +static const int weight[5] = { 0, 1, 7, 22, 100 }; + +static void update_overlap(struct spotstr *); /* * Return values: @@ -215,7 +217,7 @@ makemove(int us, int mv) /* * fix up the overlap array due to updating spot osp. */ -void +static void update_overlap(struct spotstr *osp) { struct spotstr *sp, *sp1, *sp2; diff --git a/gomoku/pickmove.c b/gomoku/pickmove.c index b7755358..4bdf82ba 100644 --- a/gomoku/pickmove.c +++ b/gomoku/pickmove.c @@ -1,4 +1,4 @@ -/* $NetBSD: pickmove.c,v 1.18 2009/06/04 07:01:16 dholland Exp $ */ +/* $NetBSD: pickmove.c,v 1.19 2009/08/12 06:19:17 dholland Exp $ */ /* * Copyright (c) 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)pickmove.c 8.2 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: pickmove.c,v 1.18 2009/06/04 07:01:16 dholland Exp $"); +__RCSID("$NetBSD: pickmove.c,v 1.19 2009/08/12 06:19:17 dholland Exp $"); #endif #endif /* not lint */ @@ -55,15 +55,28 @@ __RCSID("$NetBSD: pickmove.c,v 1.18 2009/06/04 07:01:16 dholland Exp $"); #define BIT_CLR(a, b) ((a)[(b)/BITS_PER_INT] &= ~(1 << ((b) % BITS_PER_INT))) #define BIT_TEST(a, b) ((a)[(b)/BITS_PER_INT] & (1 << ((b) % BITS_PER_INT))) -struct combostr *hashcombos[FAREA]; /* hash list for finding duplicates */ -struct combostr *sortcombos; /* combos at higher levels */ -int combolen; /* number of combos in sortcombos */ -int nextcolor; /* color of next move */ -int elistcnt; /* count of struct elist allocated */ -int combocnt; /* count of struct combostr allocated */ -int forcemap[MAPSZ]; /* map for blocking <1,x> combos */ -int tmpmap[MAPSZ]; /* map for blocking <1,x> combos */ -int nforce; /* count of opponent <1,x> combos */ +static struct combostr *hashcombos[FAREA];/* hash list for finding duplicates */ +static struct combostr *sortcombos; /* combos at higher levels */ +static int combolen; /* number of combos in sortcombos */ +static int nextcolor; /* color of next move */ +static int elistcnt; /* count of struct elist allocated */ +static int combocnt; /* count of struct combostr allocated */ +static int forcemap[MAPSZ]; /* map for blocking <1,x> combos */ +static int tmpmap[MAPSZ]; /* map for blocking <1,x> combos */ +static int nforce; /* count of opponent <1,x> combos */ + +static int better(const struct spotstr *, const struct spotstr *, int); +static void scanframes(int); +static void makecombo2(struct combostr *, struct spotstr *, int, int); +static void addframes(int); +static void makecombo(struct combostr *, struct spotstr *, int, int); +static void appendcombo(struct combostr *, int); +static void updatecombo(struct combostr *, int); +static void makeempty(struct combostr *); +static int checkframes(struct combostr *, struct combostr *, struct spotstr *, + int, struct overlap_info *); +static int sortcombo(struct combostr **, struct combostr **, struct combostr *); +static void printcombo(struct combostr *, char *, size_t); int pickmove(int us) @@ -161,7 +174,7 @@ pickmove(int us) /* * Return true if spot 'sp' is better than spot 'sp1' for color 'us'. */ -int +static int better(const struct spotstr *sp, const struct spotstr *sp1, int us) { int them, s, s1; @@ -211,15 +224,15 @@ better(const struct spotstr *sp, const struct spotstr *sp1, int us) #endif } -int curcolor; /* implicit parameter to makecombo() */ -int curlevel; /* implicit parameter to makecombo() */ +static int curcolor; /* implicit parameter to makecombo() */ +static int curlevel; /* implicit parameter to makecombo() */ /* * Scan the sorted list of non-empty frames and * update the minimum combo values for each empty spot. * Also, try to combine frames to find more complex (chained) moves. */ -void +static void scanframes(int color) { struct combostr *cbp, *ecbp; @@ -400,7 +413,7 @@ scanframes(int color) * Compute all level 2 combos of frames intersecting spot 'osp' * within the frame 'ocbp' and combo value 's'. */ -void +static void makecombo2(struct combostr *ocbp, struct spotstr *osp, int off, int s) { struct spotstr *fsp; @@ -530,7 +543,7 @@ makecombo2(struct combostr *ocbp, struct spotstr *osp, int off, int s) * Scan the sorted list of frames and try to add a frame to * combinations of 'level' number of frames. */ -void +static void addframes(int level) { struct combostr *cbp, *ecbp; @@ -630,7 +643,7 @@ addframes(int level) * Compute all level N combos of frames intersecting spot 'osp' * within the frame 'ocbp' and combo value 's'. */ -void +static void makecombo(struct combostr *ocbp, struct spotstr *osp, int off, int s) { struct combostr *cbp, *ncbp; @@ -644,6 +657,15 @@ makecombo(struct combostr *ocbp, struct spotstr *osp, int off, int s) struct overlap_info vertices[1]; char tmp[128]; + /* + * XXX: when I made functions static gcc started warning about + * some members of vertices[0] maybe being used uninitialized. + * For now I'm just going to clear it rather than wade through + * the logic to find out whether gcc or the code is wrong. I + * wouldn't be surprised if it were the code though. - dholland + */ + memset(vertices, 0, sizeof(vertices)); + ocb.s = s; baseB = ocb.c.a + ocb.c.b - 1; fcnt = ocb.c.a - 2; @@ -769,14 +791,14 @@ makecombo(struct combostr *ocbp, struct spotstr *osp, int off, int s) } #define MAXDEPTH 100 -struct elist einfo[MAXDEPTH]; -struct combostr *ecombo[MAXDEPTH]; /* separate from elist to save space */ +static struct elist einfo[MAXDEPTH]; +static struct combostr *ecombo[MAXDEPTH]; /* separate from elist to save space */ /* * Add the combostr 'ocbp' to the empty spots list for each empty spot * in 'ocbp' that will complete the combo. */ -void +static void makeempty(struct combostr *ocbp) { struct combostr *cbp, *tcbp, **cbpp; @@ -933,7 +955,7 @@ makeempty(struct combostr *ocbp) * We handle things differently depending on whether the next move * would be trying to "complete" the combo or trying to block it. */ -void +static void updatecombo(struct combostr *cbp, int color) { struct spotstr *sp; @@ -1022,7 +1044,7 @@ updatecombo(struct combostr *cbp, int color) /* * Add combo to the end of the list. */ -void +static void appendcombo(struct combostr *cbp, int color __unused) { struct combostr *pcbp, *ncbp; @@ -1051,7 +1073,7 @@ appendcombo(struct combostr *cbp, int color __unused) * Return -1 if 'fcbp' should not be combined with 'cbp'. * 's' is the combo value for frame 'fcpb'. */ -int +static int checkframes(struct combostr *cbp, struct combostr *fcbp, struct spotstr *osp, int s, struct overlap_info *vertices) { @@ -1189,7 +1211,7 @@ checkframes(struct combostr *cbp, struct combostr *fcbp, struct spotstr *osp, * Return true if this list of frames is already in the hash list. * Otherwise, add the new combo to the hash list. */ -int +static int sortcombo(struct combostr **scbpp, struct combostr **cbpp, struct combostr *fcbp) { @@ -1303,7 +1325,7 @@ inserted: /* * Print the combo into string buffer 'buf'. */ -void +static void printcombo(struct combostr *cbp, char *buf, size_t max) { struct combostr *tcbp; diff --git a/gomoku/stoc.c b/gomoku/stoc.c index 58e8fc90..c7b1eff8 100644 --- a/gomoku/stoc.c +++ b/gomoku/stoc.c @@ -1,4 +1,4 @@ -/* $NetBSD: stoc.c,v 1.11 2009/06/04 05:51:12 dholland Exp $ */ +/* $NetBSD: stoc.c,v 1.12 2009/08/12 06:19:17 dholland Exp $ */ /* * Copyright (c) 1994 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)stoc.c 8.1 (Berkeley) 7/24/94"; #else -__RCSID("$NetBSD: stoc.c,v 1.11 2009/06/04 05:51:12 dholland Exp $"); +__RCSID("$NetBSD: stoc.c,v 1.12 2009/08/12 06:19:17 dholland Exp $"); #endif #endif /* not lint */ @@ -59,6 +59,9 @@ static const struct mvstr mv[] = { { -1, 0 } }; +static int lton(int); + + /* * Turn the spot number form of a move into the character form. */ @@ -97,7 +100,7 @@ ctos(const char *mp) /* * Turn a letter into a number. */ -int +static int lton(int c) { int i; |