Module Name:    src
Committed By:   rillig
Date:           Sat May 21 14:55:26 UTC 2022

Modified Files:
        src/games/gomoku: Makefile gomoku.h main.c

Log Message:
gomoku: convert input source constants to an enum

I also tried converting other macros, but s_occ would use more memory
and the return values for makemove are special values, besides the usual
coordinates in the form PT(x, y), so turning the special values into an
enum would be confusing.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/games/gomoku/Makefile
cvs rdiff -u -r1.33 -r1.34 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.46 -r1.47 src/games/gomoku/main.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/Makefile
diff -u src/games/gomoku/Makefile:1.9 src/games/gomoku/Makefile:1.10
--- src/games/gomoku/Makefile:1.9	Mon May 16 21:48:45 2022
+++ src/games/gomoku/Makefile	Sat May 21 14:55:26 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.9 2022/05/16 21:48:45 rillig Exp $
+#	$NetBSD: Makefile,v 1.10 2022/05/21 14:55:26 rillig Exp $
 #	@(#)Makefile	8.1 (Berkeley) 7/24/94
 
 PROG=	gomoku
@@ -11,5 +11,6 @@ CPPFLAGS+=	${DEBUG:D-DDEBUG}
 
 LINTFLAGS+=	-w	# treat warnings as errors
 LINTFLAGS+=	-T	# strict bool mode
+LINTFLAGS+=	-e	# strict enum checks
 
 .include <bsd.prog.mk>

Index: src/games/gomoku/gomoku.h
diff -u src/games/gomoku/gomoku.h:1.33 src/games/gomoku/gomoku.h:1.34
--- src/games/gomoku/gomoku.h:1.33	Sat May 21 12:29:34 2022
+++ src/games/gomoku/gomoku.h	Sat May 21 14:55:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: gomoku.h,v 1.33 2022/05/21 12:29:34 rillig Exp $	*/
+/*	$NetBSD: gomoku.h,v 1.34 2022/05/21 14:55:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -59,14 +59,13 @@
 #define EMPTY	2
 #define BORDER	3
 
-/* return values for makemove() */
+/* return values for makemove, readinput */
 #define MOVEOK	0
 #define RESIGN	1
 #define ILLEGAL	2
 #define WIN	3
 #define TIE	4
 #define SAVE	5
-
 #define PT(x, y)	((x) + (BSZ + 1) * (y))
 
 /*

Index: src/games/gomoku/main.c
diff -u src/games/gomoku/main.c:1.46 src/games/gomoku/main.c:1.47
--- src/games/gomoku/main.c:1.46	Sat May 21 14:23:10 2022
+++ src/games/gomoku/main.c	Sat May 21 14:55:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.46 2022/05/21 14:23:10 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.47 2022/05/21 14:55:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -36,7 +36,7 @@
 __COPYRIGHT("@(#) Copyright (c) 1994\
  The Regents of the University of California.  All rights reserved.");
 /*	@(#)main.c	8.4 (Berkeley) 5/4/95	*/
-__RCSID("$NetBSD: main.c,v 1.46 2022/05/21 14:23:10 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.47 2022/05/21 14:55:26 rillig Exp $");
 
 #include <sys/stat.h>
 #include <curses.h>
@@ -51,9 +51,11 @@ __RCSID("$NetBSD: main.c,v 1.46 2022/05/
 
 #include "gomoku.h"
 
-#define USER	0		/* get input from standard input */
-#define PROGRAM	1		/* get input from program */
-#define INPUTF	2		/* get input from a file */
+enum input_source {
+	USER,			/* get input from standard input */
+	PROGRAM,		/* get input from program */
+	INPUTF			/* get input from a file */
+};
 
 bool	interactive = true;	/* true if interactive */
 int	debug;			/* > 0 if debugging */
@@ -102,7 +104,7 @@ main(int argc, char **argv)
 	char fname[PATH_MAX];
 	char *user_name;
 	int color, curmove, i, ch;
-	int input[2];
+	enum input_source input[2];
 
 	/* Revoke setgid privileges */
 	setgid(getgid());
@@ -235,6 +237,7 @@ again:
 			curmove = readinput(inputfp);
 			if (curmove != ILLEGAL)
 				break;
+			/* Switch to another input source. */
 			switch (test) {
 			case 0: /* user versus program */
 				input[color] = USER;

Reply via email to