Module Name:    src
Committed By:   dholland
Date:           Wed Aug 12 06:19:17 UTC 2009

Modified Files:
        src/games/gomoku: bdinit.c gomoku.h main.c makemove.c pickmove.c stoc.c

Log Message:
sprinkle static


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/games/gomoku/bdinit.c
cvs rdiff -u -r1.16 -r1.17 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.19 -r1.20 src/games/gomoku/main.c
cvs rdiff -u -r1.10 -r1.11 src/games/gomoku/makemove.c
cvs rdiff -u -r1.18 -r1.19 src/games/gomoku/pickmove.c
cvs rdiff -u -r1.11 -r1.12 src/games/gomoku/stoc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/gomoku/bdinit.c
diff -u src/games/gomoku/bdinit.c:1.7 src/games/gomoku/bdinit.c:1.8
--- src/games/gomoku/bdinit.c:1.7	Thu Jun  4 05:43:29 2009
+++ src/games/gomoku/bdinit.c	Wed Aug 12 06:19:17 2009
@@ -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 @@
  * 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;

Index: src/games/gomoku/gomoku.h
diff -u src/games/gomoku/gomoku.h:1.16 src/games/gomoku/gomoku.h:1.17
--- src/games/gomoku/gomoku.h:1.16	Mon Jul 13 19:05:40 2009
+++ src/games/gomoku/gomoku.h	Wed Aug 12 06:19:17 2009
@@ -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 @@
 #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	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);

Index: src/games/gomoku/main.c
diff -u src/games/gomoku/main.c:1.19 src/games/gomoku/main.c:1.20
--- src/games/gomoku/main.c:1.19	Mon Jul 13 19:05:40 2009
+++ src/games/gomoku/main.c	Wed Aug 12 06:19:17 2009
@@ -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 @@
 #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 @@
 
 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	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 @@
 	return(0);
 }
 
-int
+static int
 readinput(FILE *fp)
 {
 	int c;
@@ -502,7 +505,7 @@
 		fprintf(stderr, "%s\n", buf);
 }
 
-void
+static void
 misclog(const char *fmt, ...)
 {
 	va_list ap;
@@ -520,7 +523,7 @@
 		printf("%s\n", buf);
 }
 
-void
+static void
 quit(void)
 {
 	if (interactive) {
@@ -530,7 +533,7 @@
 	exit(0);
 }
 
-void
+static void
 quitsig(int dummy __unused)
 {
 	quit();

Index: src/games/gomoku/makemove.c
diff -u src/games/gomoku/makemove.c:1.10 src/games/gomoku/makemove.c:1.11
--- src/games/gomoku/makemove.c:1.10	Thu Jun  4 05:43:29 2009
+++ src/games/gomoku/makemove.c	Wed Aug 12 06:19:17 2009
@@ -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 @@
 	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 @@
 /*
  * fix up the overlap array due to updating spot osp.
  */
-void
+static void
 update_overlap(struct spotstr *osp)
 {
 	struct spotstr *sp, *sp1, *sp2;

Index: src/games/gomoku/pickmove.c
diff -u src/games/gomoku/pickmove.c:1.18 src/games/gomoku/pickmove.c:1.19
--- src/games/gomoku/pickmove.c:1.18	Thu Jun  4 07:01:16 2009
+++ src/games/gomoku/pickmove.c	Wed Aug 12 06:19:17 2009
@@ -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 @@
 #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 @@
 /*
  * 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 @@
 #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 @@
  * 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 @@
  * 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 @@
  * 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 @@
 	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 @@
 }
 
 #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 @@
  * 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 @@
 /*
  * 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 @@
  * 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 @@
  * 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 @@
 /*
  * Print the combo into string buffer 'buf'.
  */
-void
+static void
 printcombo(struct combostr *cbp, char *buf, size_t max)
 {
 	struct combostr *tcbp;

Index: src/games/gomoku/stoc.c
diff -u src/games/gomoku/stoc.c:1.11 src/games/gomoku/stoc.c:1.12
--- src/games/gomoku/stoc.c:1.11	Thu Jun  4 05:51:12 2009
+++ src/games/gomoku/stoc.c	Wed Aug 12 06:19:17 2009
@@ -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 @@
 	{ -1,		0 }
 };
 
+static int lton(int);
+
+
 /*
  * Turn the spot number form of a move into the character form.
  */
@@ -97,7 +100,7 @@
 /*
  * Turn a letter into a number.
  */
-int
+static int
 lton(int c)
 {
 	int i;

Reply via email to