Module Name:    src
Committed By:   rillig
Date:           Sun May 15 22:56:20 UTC 2022

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

Log Message:
gomoku: inline macros BSZ1, BSZ2, BSZ3, BSZ4

These macro names didn't convey any meaning, so replace them with their
replacement text, to have fewer identifiers to worry about.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/games/gomoku/bdinit.c
cvs rdiff -u -r1.21 -r1.22 src/games/gomoku/bdisp.c
cvs rdiff -u -r1.24 -r1.25 src/games/gomoku/gomoku.h
cvs rdiff -u -r1.30 -r1.31 src/games/gomoku/main.c
cvs rdiff -u -r1.15 -r1.16 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.10 src/games/gomoku/bdinit.c:1.11
--- src/games/gomoku/bdinit.c:1.10	Sun May 15 22:00:11 2022
+++ src/games/gomoku/bdinit.c	Sun May 15 22:56:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdinit.c,v 1.10 2022/05/15 22:00:11 rillig Exp $	*/
+/*	$NetBSD: bdinit.c,v 1.11 2022/05/15 22:56:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "from: @(#)bdinit.c	8.2 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: bdinit.c,v 1.10 2022/05/15 22:00:11 rillig Exp $");
+__RCSID("$NetBSD: bdinit.c,v 1.11 2022/05/15 22:56:20 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -57,7 +57,7 @@ bdinit(struct spotstr *bp)
 
 	/* mark the borders as such */
 	sp = bp;
-	for (i = BSZ2; --i >= 0; sp++) {
+	for (i = 1 + BSZ + 1; --i >= 0; sp++) {
 		sp->s_occ = BORDER;			/* top border */
 		sp->s_flags = BFLAGALL;
 	}
@@ -65,8 +65,8 @@ bdinit(struct spotstr *bp)
 	/* fill entire board with EMPTY spots */
 	memset(frames, 0, sizeof(frames));
 	cbp = frames;
-	for (j = 0; ++j < BSZ1; sp++) {			/* for each row */
-		for (i = 0; ++i < BSZ1; sp++) {		/* for each column */
+	for (j = 0; ++j < BSZ + 1; sp++) {		/* for each row */
+		for (i = 0; ++i < BSZ + 1; sp++) {	/* for each column */
 			sp->s_occ = EMPTY;
 			sp->s_flags = 0;
 			sp->s_wval = 0;
@@ -145,8 +145,8 @@ bdinit(struct spotstr *bp)
 	}
 
 	/* mark the borders as such */
-	for (i = BSZ1; --i >= 0; sp++) {
-		sp->s_occ = BORDER;		/* bottom border */
+	for (i = BSZ + 1; --i >= 0; sp++) {
+		sp->s_occ = BORDER;			/* bottom border */
 		sp->s_flags = BFLAGALL;
 	}
 

Index: src/games/gomoku/bdisp.c
diff -u src/games/gomoku/bdisp.c:1.21 src/games/gomoku/bdisp.c:1.22
--- src/games/gomoku/bdisp.c:1.21	Sun May 15 22:08:05 2022
+++ src/games/gomoku/bdisp.c	Sun May 15 22:56:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdisp.c,v 1.21 2022/05/15 22:08:05 rillig Exp $	*/
+/*	$NetBSD: bdisp.c,v 1.22 2022/05/15 22:56:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)bdisp.c	8.2 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: bdisp.c,v 1.21 2022/05/15 22:08:05 rillig Exp $");
+__RCSID("$NetBSD: bdisp.c,v 1.22 2022/05/15 22:56:20 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -85,7 +85,7 @@ void
 cursfini(void)
 {
 
-	move(BSZ4, 0);
+	move(BSZ + 4, 0);
 	clrtoeol();
 	refresh();
 	echo();
@@ -101,19 +101,19 @@ bdisp_init(void)
 	int i, j;
 
 	/* top border */
-	for (i = 1; i < BSZ1; i++) {
+	for (i = 1; i < BSZ + 1; i++) {
 		move(0, 2 * i + 1);
 		addch(letters[i]);
 	}
 	/* left and right edges */
-	for (j = BSZ1; --j > 0; ) {
+	for (j = BSZ + 1; --j > 0; ) {
 		move(20 - j, 0);
 		printw("%2d ", j);
-		move(20 - j, 2 * BSZ1 + 1);
+		move(20 - j, 2 * (BSZ + 1) + 1);
 		printw("%d ", j);
 	}
 	/* bottom border */
-	for (i = 1; i < BSZ1; i++) {
+	for (i = 1; i < BSZ + 1; i++) {
 		move(20, 2 * i + 1);
 		addch(letters[i]);
 	}
@@ -165,10 +165,10 @@ bdisp(void)
 	int i, j, c;
 	struct spotstr *sp;
 
-	for (j = BSZ1; --j > 0; ) {
-		for (i = 1; i < BSZ1; i++) {
-			move(BSZ1 - j, 2 * i + 1);
-			sp = &board[i + j * BSZ1];
+	for (j = BSZ + 1; --j > 0; ) {
+		for (i = 1; i < BSZ + 1; i++) {
+			move(BSZ + 1 - j, 2 * i + 1);
+			sp = &board[i + j * (BSZ + 1)];
 			if (debug > 1 && sp->s_occ == EMPTY) {
 				if (sp->s_flags & IFLAGALL)
 					c = '+';
@@ -197,11 +197,11 @@ bdump(FILE *fp)
 	/* top border */
 	fprintf(fp, "   A B C D E F G H J K L M N O P Q R S T\n");
 
-	for (j = BSZ1; --j > 0; ) {
+	for (j = BSZ + 1; --j > 0; ) {
 		/* left edge */
 		fprintf(fp, "%2d ", j);
-		for (i = 1; i < BSZ1; i++) {
-			sp = &board[i + j * BSZ1];
+		for (i = 1; i < BSZ + 1; i++) {
+			sp = &board[i + j * (BSZ + 1)];
 			if (debug > 1 && sp->s_occ == EMPTY) {
 				if (sp->s_flags & IFLAGALL)
 					c = '+';
@@ -250,10 +250,10 @@ ask(const char *str)
 {
 	int len = strlen(str);
 
-	move(BSZ4, 0);
+	move(BSZ + 4, 0);
 	addstr(str);
 	clrtoeol();
-	move(BSZ4, len);
+	move(BSZ + 4, len);
 	refresh();
 }
 
@@ -336,7 +336,7 @@ get_coord(void)
 	nx = curx;
 	ny = cury;
 	for (;;) {
-		mvprintw(BSZ3, (BSZ - 6) / 2, "(%c %d) ",
+		mvprintw(BSZ + 3, (BSZ - 6) / 2, "(%c %d) ",
 		    'A' + ((curx > 7) ? (curx + 1) : curx), cury + 1);
 		BGOTO(cury, curx);
 
@@ -434,8 +434,8 @@ get_coord(void)
 			MEVENT	myevent;
 
 			getmouse(&myevent);
-			if (myevent.y >= 1 && myevent.y <= BSZ1 &&
-			    myevent.x >= 3 && myevent.x <= (2 * BSZ + 1)) {
+			if (myevent.y >= 1 && myevent.y <= BSZ + 1 &&
+			    myevent.x >= 3 && myevent.x <= 2 * BSZ + 1) {
 				curx = (myevent.x - 3) / 2;
 				cury = BSZ - myevent.y;
 				return PT(curx,cury);
@@ -453,7 +453,7 @@ get_coord(void)
 			return SAVE;
 		case ' ':
 		case '\r':
-			(void)mvaddstr(BSZ3, (BSZ - 6) / 2, "      ");
+			(void)mvaddstr(BSZ + 3, (BSZ - 6) / 2, "      ");
 			return PT(curx + 1, cury + 1);
 		}
 

Index: src/games/gomoku/gomoku.h
diff -u src/games/gomoku/gomoku.h:1.24 src/games/gomoku/gomoku.h:1.25
--- src/games/gomoku/gomoku.h:1.24	Sun May 15 22:41:51 2022
+++ src/games/gomoku/gomoku.h	Sun May 15 22:56:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: gomoku.h,v 1.24 2022/05/15 22:41:51 rillig Exp $	*/
+/*	$NetBSD: gomoku.h,v 1.25 2022/05/15 22:56:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994
@@ -40,13 +40,9 @@
 
 /* board dimensions */
 #define BSZ	19
-#define BSZ1	(BSZ + 1)
-#define BSZ2	(BSZ + 2)
-#define BSZ3	(BSZ + 3)
-#define BSZ4	(BSZ + 4)
-#define BAREA	(BSZ2 * BSZ1 + 1)
+#define BAREA	((1 + BSZ + 1) * (BSZ + 1) + 1)
 
-#define TRANSCRIPT_COL	(2 * BSZ4)
+#define TRANSCRIPT_COL	(2 * (BSZ + 4))
 
 /* interactive curses stuff */
 #define BGOTO(y, x)	move(BSZ - (y), 2 * (x) + 3)
@@ -56,8 +52,8 @@
 #define FSZ2	(BSZ-4)
 #define FAREA	(FSZ1*FSZ2 + FSZ2*FSZ2 + FSZ1*FSZ2 + FSZ2*FSZ2)
 
-#define MUP	(BSZ1)
-#define MDOWN	(-BSZ1)
+#define MUP	(BSZ + 1)
+#define MDOWN	(-(BSZ + 1))
 #define MLEFT	(-1)
 #define MRIGHT	(1)
 
@@ -75,7 +71,7 @@
 #define TIE	4
 #define SAVE	5
 
-#define PT(x, y)	((x) + BSZ1 * (y))
+#define PT(x, y)	((x) + (BSZ + 1) * (y))
 
 /*
  * A 'frame' is a group of five or six contiguous board locations.

Index: src/games/gomoku/main.c
diff -u src/games/gomoku/main.c:1.30 src/games/gomoku/main.c:1.31
--- src/games/gomoku/main.c:1.30	Sun May 15 22:08:05 2022
+++ src/games/gomoku/main.c	Sun May 15 22:56:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.30 2022/05/15 22:08:05 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.31 2022/05/15 22:56:20 rillig 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.30 2022/05/15 22:08:05 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.31 2022/05/15 22:56:20 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -157,7 +157,7 @@ again:
 #endif
 
 		if (inputfp == NULL && test == 0) {
-			move(BSZ3, 0);
+			move(BSZ + 3, 0);
 			printw("Black moves first. ");
 			ask("(B)lack or (W)hite? ");
 			for (;;) {
@@ -176,7 +176,7 @@ again:
 				beep();
 				ask("Please choose (B)lack or (W)hite: ");
 			}
-			move(BSZ3, 0);
+			move(BSZ + 3, 0);
 			clrtoeol();
 		}
 	} else {
@@ -300,7 +300,7 @@ again:
 			bdisp();
 	}
 	if (interactive) {
-		move(BSZ3, 0);
+		move(BSZ + 3, 0);
 		switch (i) {
 		case WIN:
 			if (input[color] == PROGRAM)

Index: src/games/gomoku/stoc.c
diff -u src/games/gomoku/stoc.c:1.15 src/games/gomoku/stoc.c:1.16
--- src/games/gomoku/stoc.c:1.15	Sun May 15 22:08:05 2022
+++ src/games/gomoku/stoc.c	Sun May 15 22:56:20 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: stoc.c,v 1.15 2022/05/15 22:08:05 rillig Exp $	*/
+/*	$NetBSD: stoc.c,v 1.16 2022/05/15 22:56:20 rillig 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.15 2022/05/15 22:08:05 rillig Exp $");
+__RCSID("$NetBSD: stoc.c,v 1.16 2022/05/15 22:56:20 rillig Exp $");
 #endif
 #endif /* not lint */
 
@@ -74,7 +74,8 @@ stoc(int s)
 	for (i = 0; mv[i].m_code >= 0; i++)
 		if (s == mv[i].m_code)
 			return mv[i].m_text;
-	snprintf(buf, sizeof(buf), "%c%d", letters[s % BSZ1], s / BSZ1);
+	snprintf(buf, sizeof(buf), "%c%d",
+	    letters[s % (BSZ + 1)], s / (BSZ + 1));
 	return buf;
 }
 

Reply via email to